🎼Voice-to-Note🤖
How it works
This is a Whatsapp bot that, given audio, will use Google's Cloud Speech-to-Text to extract the text and send it back to the user. When a message comes in, the file containing the audio is fetched through twilio from an s3 bucket and sent to the Google Speech Recognition API. The result is returned to the flask server and the flask server then sends it back to the user.
How to use it
Connect to the sandbox bot and start sending it audio or voice notes, its as easy as that!
Demo
Feel free to connect to my sandbox by sending a WhatsApp message from your device to +1 415 523 8886 with code join terrible-shop.
Set up
Requirements
Local development
After the above requirements have been met:
- Clone this repository and
cdinto it
git clone https://github.com/huntingphi/voice-to-note.git
cd voice-to-note- Install dependencies
pip install -r requirements.txt- Set your environment variables
You need to have your Google Cloud API Key in a file stored locally. Replace [PATH] with the path of the JSON file that contains your service account key.
export GOOGLE_APPLICATION_CREDENTIALS="[PATH TO API]"See Twilio Account Settings to locate the necessary environment variables.
- Run the application
python lambda_function.py- Expose locally running server
Use a tool such as ngrok to expose the server running locally to the web.
- Pass the public-facing url to the Twilio whatsapp webhooks
You'll find this on the Sandbox Configuration page. If your public url is https://notarealurl.com then your settings will be as follows:
| WHEN A MESSAGE COMES IN | https://notarealurl.com/bot-receiver | HTTP Post |
|---|---|---|
| STATUS CALLBACK URL | https://notarealurl.com/bot-status | HTTP Post |
- Connect to the sandbox
You should now be able to send it voice notes or audio files!
Tests
No tests are present as yet.
Cloud deployment
Additionally to trying out this application locally, you can deploy it to a variety of host services.
This was the route I followed, see this guide
If you follow the guide, using this repository as the root folder, it should allow you to deploy to the cloud.
Once the flask server is running, select the lambda running the server and set the environment variables as shown in the steps above in the AWS console. Proceed to follow the local development steps from step 6 onward.
Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.
License
Disclaimer
No warranty expressed or implied. Software is as is.
