WhisperingGPT is a cutting-edge Speech Translation API that leverages the power of OpenAI's Whisper and GPT-3.5 models to provide highly accurate and fluent translations.
- Install the required dependencies
pip3 install -r requirements.txt
- Set the OpenAI API Key as an environment variable
export OPENAI_API_KEY=<your-api-key>
Start the API server using the following command:
uvicorn main:app
This will start the API server at http://127.0.0.1:8000
To translate an audio file, make a POST
request to /translate_speech
endpoint as shown below:
import requests
endpoint = "http://127.0.0.1:8000/translate_speech"
payload = {"file": open("audio.wav", "rb"), "target_language": "hindi"}
response = requests.post(endpoint, json=payload)
print(response.json())
This will return a JSON response containing the translated text in the target language.
To transcribe an audio file, make a POST
request to /transcribe
endpoint as shown below:
import requests
endpoint = "http://127.0.0.1:8000/transcribe"
payload = {"file": open("audio.wav", "rb")}
response = requests.post(endpoint, json=payload)
print(response.json())
This will return a JSON response containing the transcription of the audio file.
To translate text, make a POST
request to /translate
endpoint as shown below:
import requests
endpoint = "http://127.0.0.1:8000/translate"
payload = {"text": "Hello, how are you?", "target_language": "hindi"}
response = requests.post(endpoint, json=payload)
print(response.json())
This will return a JSON response containing the translated text in the target language.
A deploy.sh shell script is provided to deploy the WhisperingGPT API on EC2 inside a Docker container.
Before using the script, you need to have the following:
- AWS CLI installed and configured on your machine
- An EC2 key pair that you will use to connect to your instance
- The local path to your EC2 key pair
- The ID of a security group that you want to use for your instance
- Your OpenAI API Key
- Set the required variables
export KEY=<your-ec2-key>
export KEY_PATH=</path/to/your-ec2-key.pem>
export SECURITY_GROUP_ID=<security-group-id>
- Add your OpenAI API Key by replacing
<your-openai-api-key>
with your API key and
run the below command in your terminal from the root of this repo:
perl -i -pe 's/docker run -e OPENAI_API_KEY= -d -p 8000:8000 whisperinggpt/docker run -e OPENAI_API_KEY=<your-openai-api-key> -d -p 8000:8000 whisperinggpt/ if $.==9' user_data.txt
- Run the script as shown below:
bash deploy.sh
This project is licensed under the MIT License - see LICENSE for details.