I Hate Voice Notes (Transcribing speech using OpenAI Whisper)
Listening to WhatsApp voice notes can be inconvenient or time-consuming. Some people love them, some people hate them.
Curiously, these tastes vary across cultures, for example in Argentina people prefer communicating using voice notes.
Be that as it may, being able to transcribe a voice note you received on WhatsApp with very low friction can be quite useful.
Enter OpenAI Whisper. OpenAI released this two weeks ago and made me wonder if I could scratch my own itch by building a transcriber bot.
There were two potential obstacles:
- How difficult is it to build a WhatsApp bot and retrieve the audio?
- How difficult is it to deploy Whisper?
This turned out to be fairly easy to test. You can set up a test account and use the API easily. Documentation is ok. It probably took me less than an hour to be able to receive a voice note and extract the OGG audio using API requests.
There’s a catch: Encryption. When you send a voice note to the business number it’s not end-to-end encrypted. So there are privacy implications.
Kudos to OpenAI to make it very easy to run. The github repo with instructions is here: https://github.com/openai/whisper.
On my Mac it was:
1 2 3 $ brew install ffmpeg $ pip install git+https://github.com/openai/whisper.git $ whisper audio.ogg
Here’s a voice note I received from a property agent:
The Whisper result:
“I’ve been the owner of the property just phoned me this morning to say that the property has been sold. She got a cash offer yesterday which is accepted. So yeah, I’m actually taking it off the market right now. But a very nice property. Okay, see you Monday. Bye.”
The only thing Whisper got wrong is the initial “Hi Ben”, which it transcribed as “I’ve been”. And with a South African accent. Impressive.
There are 3 components:
- The WhatsApp WebHook API (NodeJS + Express).
- A queue (Redis).
- A Python worker.
When a WhatsApp message is received, it is pushed on to the Redis queue, and the Python worker transcribes it and send the message back to the originator via the WhatsApp API.
I deployed it open Digital Ocean as a Docker app with no issues. You will need 2GB of memory though.
Here it is integrated into WhatsApp. I just forward any voice note to the bot account and it will produce a transcription:
It is remarkable what a solo developer can build in a few days using freely available AI models. A few years ago this would take a team and I don’t know how many months of work.
If you’re interested in trying it out, please visit https://ihatevoicenotes.com and add your contact details so I can let you know when it’s ready.
P.S. I’ve available for hire. Reach out at firstname.lastname@example.org.