This is an interface to discuss with ChatGPT in text or audio format. When you speak, your voice is converted to text and sent to ChatGPT. When ChatGPT responds, its text is converted to audio and played.
If you write text, then ChatGPT will respond with text.
First, you need to create an account to use the OpenAI API. Once you have an account, you need to create an API key.
Export the API key as an environment variable:
export OPENAI_API_KEY='your-api-key'
Top-up your account with some credits to use the API. One request costs approx. 0.1$ with the current pricing and script configuration.
Create a new environment and install the dependencies:
python -m venv venv
source venv/bin/activate
Check that the OpenAI API key is correctly set:
echo $OPENAI_API_KEY
If nothing is printed, then the API key is not set, and you need to set it again.
Once the API key is set, install the dependencies:
pip install -r requirements.txt
The script can be run with the following command:
python main.py
The commands are as follows:
Command | Description |
---|---|
r | starts recording until silence is detected |
exit | quits the script |
{anything else} | sends the text to ChatGPT |
This project is licensed under the terms of the MIT license.