Home → Blog → Voice message transcription: Telegram, WhatsApp and other messengers
Voice message transcription: Telegram, WhatsApp and other messengers
Voice messages are convenient for the sender and inconvenient for everybody else: you cannot skim them, search them or read them in a meeting. Automatic transcription fixes that — here is how to wire it into a bot or a business process.
How voice messages differ from ordinary recordings
Three properties matter here:
- The ogg/opus container. Telegram and WhatsApp compress voice into opus. You do not need to convert it in advance — the service takes the file as it is.
- Very short duration. A typical message is between three seconds and a minute. The shorter the clip, the less context the model has.
- Spontaneous speech. Broken sentences, street noise and filler words all end up in the transcript, because what is recognised is what was actually said.
Sending a voice message for transcription
The file goes exactly as the messenger delivered it:
from openai import OpenAI
client = OpenAI(base_url="https://voicesscribe.com/v1", api_key="your key")
with open("voice_message.ogg", "rb") as f:
text = client.audio.transcriptions.create(model="whisper-1", file=f).text
print(text)
The format is detected from the contents of the file rather than from its extension, so a wrong file name will not break recognition.
A bot that answers a voice message with text
The flow is simple: receive the voice message, download the file, send it for transcription, post the text back to the chat.
async def on_voice(message, bot):
file = await bot.download(message.voice.file_id) # ogg/opus
text = client.audio.transcriptions.create(
model="whisper-1", file=("voice.ogg", file), language="en",
).text
await message.reply(text or "Could not make out any speech")
The answer comes back in the same request, so the user gets the text a couple of seconds after sending the message.
Short clips: how to raise accuracy
Two- and three-second recordings are the hard case: there is little context and language detection can slip. Three techniques that almost always help:
- State the language explicitly —
language="en". Auto-detection is switched off and the errors on short phrases disappear. - Describe the expected content through
prompt. For confirmation codes:prompt="A four-digit confirmation code". - Check the confidence. The
verbose_jsonresponse carries the language probability: a low value is a signal to review that message.
Multilingual streams
If messages arrive in different languages, there is nothing to configure: the language is detected from the audio and 99 languages are supported. The verbose_json response returns the detected language, which is a convenient way to route conversations between agents.
One caveat: the language is decided from the beginning of the recording. If somebody starts in English and switches to Spanish, the transcript continues in “English mode” — those messages are better handled separately.
Silence and empty recordings
Some voice messages turn out to be empty: an accidental tap, a dropped connection, background noise with no speech. In those cases the service returns an empty string rather than invented sentences — built-in filters cut the typical neural-network hallucinations such as closing credits and “thanks for watching”.
In code it is enough to check for an empty string and not show the user a meaningless answer.
Try it on your own recordings. Sign-up takes a minute, and the free minutes are enough to judge the quality.
Get a free API keyFrequently asked questions
Do I have to convert ogg to wav before sending?
No. The file is accepted in whatever format the messenger produced: ogg, opus, mp3, m4a, wav and other common formats.
Which languages work best for voice messages?
English, Spanish, German and other widely spoken languages are recognised with the highest quality, and 99 languages are supported in total. For a single-language stream it is still better to state the language explicitly.
How long does a voice message take to transcribe?
A usual message of up to a minute is processed in one or two seconds, and the answer is returned in the same request.
What comes back if there is no speech in the recording?
An empty text. The service does not invent content where there is none.
Is there a file size limit?
Yes, 25 MB per request. For voice messages that is a huge margin: in opus, that size is several hours of speech.
Related reading
- How to transcribe a call recording to text — A step-by-step guide to turning phone call recordings into text through an API in minutes: Python and C# samples, response formats and the errors you will meet.
- Automatic SRT and VTT subtitles from video and webinars — How to get ready-made timed subtitles from a webinar or a video: extracting the audio track, SRT versus VTT, code samples and fixes for the usual problems.
- How to improve speech-to-text accuracy: eight practical fixes — Eight changes that actually move transcription quality: audio preparation, language hints, the prompt parameter, chunking, formats, and how to measure word error rate.