Export the voice notes from the chat (or receive them through your WhatsApp Business integration) and you’ll have .ogg files. Meta’s Cloud API docs say WhatsApp voice messages are .ogg files encoded with the Opus codec. Phone recordings are often .m4a. BroadNet’s transcription endpoint accepts WAV and MP3, so convert first.
1. Convert one file
ffmpeg -i voice-note.ogg -ar 16000 -ac 1 voice-note.wav
-ar 16000 -ac 1 makes 16 kHz mono audio, the conversion BroadNet’s docs use for voice notes and phone recordings. The same command works for .m4a. 16 kHz mono 16-bit WAV is 32,000 bytes a second, so the 26,214,400-byte file cap holds about 13 minutes. For longer recordings, the audio splitter works out how many chunks you need and writes the ffmpeg commands.
2. Transcribe a whole folder
import os, pathlib, subprocess
from openai import OpenAI
client = OpenAI(base_url="https://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
for src in sorted(pathlib.Path("voice-notes").glob("*.ogg")):
wav = src.with_suffix(".wav")
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", str(src), "-ar", "16000", "-ac", "1", str(wav)], check=True)
with open(wav, "rb") as audio:
text = client.audio.transcriptions.create(
model="broadnet/cohere-transcribe-arabic",
file=audio,
language="ar", # use "en", "es", ... with broadnet/cohere-transcribe
).text
src.with_suffix(".txt").write_text(text, encoding="utf-8")
print(src.name, "->", text[:60])
Each .txt lands next to its voice note. To run the same steps automatically on every incoming WhatsApp Business message, see the n8n WhatsApp voice note workflow.
Cost
A one-minute voice note costs $0.0042 in Arabic or $0.002 with the 14-language model. Audio and transcripts are not retained after the request; see zero data retention.
Troubleshooting
-
Latin letters instead of Arabic: add
language="ar". BroadNet’s docs say to always sendlanguage. -
413 error: the file is over 26,214,400 bytes (25 MiB). Split long recordings into 10-minute WAV pieces:
ffmpeg -i long-note.ogg -ar 16000 -ac 1 -f segment -segment_time 600 part-%03d.wav -
400 or 422 on the upload: check the file really is WAV or MP3 and not an
.oggrenamed to.wav. Run the ffmpeg conversion. -
ffmpeg: command not found: install ffmpeg from your package manager (for exampleapt install ffmpegorbrew install ffmpeg). -
429 error: pay-as-you-go keys allow 4 requests at once; process files in a small pool. See all BroadNet error codes.
More detail on the model, formats and accuracy: the Arabic speech-to-text guide. To compare what other providers charge per audio minute, see the open speech-to-text API price index, with a source and date for every price. For background on why 16 kHz is enough for speech, see sample rate.
