This project is a FastAPI-based service designed to handle voice interactions through Twilio with an AI bot.
- Python 3.10+
- Twilio Account with a phone number
- Azure Speech Services Subscription
- Ngrok for local development and testing
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the project root and add the necessary environment variables:TWILIO_ACCOUNT_SID=<your_twilio_account_sid> TWILIO_AUTH_TOKEN=<your_twilio_auth_token> OPENAI_API_KEY=<your_openai_api_key> SPEECH_KEY=<your_azure_speech_key> SPEECH_REGION=<your_azure_speech_region> NGROK_AUTHTOKEN=<your_ngrok_auth_token>
-
Start the FastAPI application and starting the ngrok tunnel:
python main.py
-
Update the ngrok domain from the ngrok website:
listener = ngrok.forward(f"http://localhost:{port}", authtoken_from_env=True, domain="your_ngrok_domain.ngrok-free.app")
- Make a call to your Twilio phone number.
- The call details are processed, and an audio stream is initiated.
- Speech recognition processes the audio stream in real-time.
- Recognized speech is sent to the bot agent, which generates a response.
- The response is sent back through the WebSocket and played to the caller.
This project is licensed under the Apache License 2.0.
For any inquiries or issues, please contact [[email protected]].