This Python script implements a voice-controlled conversational interface by combining audio recording, text-to-speech, and OpenAI's GPT-3.5 Turbo. Users can interact with the AI by speaking into the microphone, and the AI responds with synthesized audio.
- Records user input as an MP3 file
- Transcribes MP3 to text using OpenAI's API
- Generates AI responses with GPT-3.5 Turbo
- Converts text responses to MP3 using OpenAI's TTS API
- Plays synthesized audio in real-time
- Python 3.x
- Required packages:
pathlibopenaipydubpyaudiowavekeyboardtime
- Add your OpenAI API key as an environment variable named
OPENAI_API_KEY. - Run the script:
python aiChatbot.py
- Press and hold the
Shiftkey to start recording audio. - To exit the program, say the word
Exitas the first word during a conversation.
- Adjust settings in the script, such as audio parameters, OpenAI models, and conversation roles.
This project is licensed under the MIT License.
- Special thanks to OpenAI for providing powerful language models.