Skip to content

huntingphi/voice-to-note

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

🎼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.

Whatsapp Bot Screenshot

Set up

Requirements

Local development

After the above requirements have been met:

  1. Clone this repository and cd into it
git clone https://github.com/huntingphi/voice-to-note.git
cd voice-to-note
  1. Install dependencies
pip install -r requirements.txt
  1. 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.

  1. Run the application
python lambda_function.py
  1. Expose locally running server

Use a tool such as ngrok to expose the server running locally to the web.

  1. 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
  1. 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

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages