Saarthi is a Flask application that acts as a voice assistant and chatbot. Users can call a designated IVR (Interactive Voice Response) number and interact with Saarthi by speaking. The application converts the user's speech to text using transcription, processes the text input using OpenAI's ChatGPT API, generates a response, and converts the response back to speech using Twilio. The conversation continues until the user hangs up the call.
- Call an IVR number and interact with Saarthi using speech input
- Convert user's speech to text using transcription
- Process user's text input using OpenAI's ChatGPT API
- Generate a response based on the user's input
- Convert the response to speech using Twilio
- Continue the conversation until the user hangs up the call
Before running the application, ensure you have the following:
- Python 3.x installed
- Twilio account and phone number with voice capabilities
- OpenAI API key
- Flask and other required dependencies installed (check requirements.txt)
-
Clone the repository: git clone https://github.com/RoyalMamba/MeraSaarthi.git
-
Change into the project directory: cd MeraSaarthi
-
Install the required dependencies: pip install -r requirements.txt
-
Set up the environment variables:
ACCOUNT_SID
: Your Twilio account SIDAUTH_TOKEN
: Your Twilio authentication tokenOPENAI_API
: Your OpenAI API key
- Start the Flask application: python main.py
-
Ensure the Flask application is running.
-
Configure your Twilio phone number's voice URL to point to the deployed URL or ngrok URL followed by
/call
. For example: https://your-app-url.com/call
Note:
It is recommended to run the code in an Online Integrated Development Environment such as Replit because Twilio works on webhooks and running it on localhost won't work until we use ngrok to create a tunnel -
Call the Twilio phone number and interact with Saarthi by speaking. Calling won't be available if the user does not have a preminum account hence the can call it via endpoint to initiate a call from the server.
-
Saarthi will convert your speech to text using transcription, process it using the ChatGPT API, generate a response, and convert it back to speech using Twilio.
-
Continue the conversation with Saarthi until you hang up the call.
-
You can customize the welcome message, voice prompts, and conversation flow by modifying the respective TwiML responses in the
main.py
file. -
The behavior of the ChatGPT API can be modified to fine-tune the responses generated by Saarthi. Refer to the OpenAI documentation for more details on customizing the chat model.
Contributions to Saarthi are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
For more details about the research and development of Saarthi, refer to the RESEARCH file.