I'm developing a Telegram bot and I have a question about sendvoice API to send voice (audio) messages.
I push a OGG file converting from a MP3 source file, using ffmpeg for conversion, with the command:
$ ffmpeg -loglevel panic -i \
/path/to/la_piattaforma_telegram_è_perfetta.mp3 \
-c:a libopus -compression_level 10 -frame_duration 60 -vbr on -application voip \
/path/to/la_piattaforma_telegram_è_perfetta.ogg -y
BTW, the MIME type appears correct:
$ file --mime-type -b \
/path/to/la_piattaforma_telegram_è_perfetta.ogg
audio/ogg
The audio file is correctly played as expected, but the (minor) problem I have is that Telegram client (desktop/android/any) doesn't show the "waveform" (audio spectogram, as that in the blue widget in the image below), instead the waveform is visualized as a single line.
Any idea about how to show the waveform graphic? There is any specific OPUS format required to allow nice visualization?
$ mediainfo /path/to/la_piattaforma_telegram_è_perfetta.ogg
General
Complete name : /path/to/la_piattaforma_telegram_è_perfetta.ogg
Format : Ogg
File size : 5.37 KiB
Duration : 2 s 79 ms
Overall bit rate : 21.2 kb/s
Audio
ID : 1485113069 (0x588506ED)
Format : Opus
Duration : 2 s 79 ms
Channel(s) : 1 channel
Channel positions : Front: C
Sampling rate : 16.0 kHz
Compression mode : Lossy
Writing library : libopus unknown-fixed
The lack of the waveform visualization could be because the audio track is mono (1 channel)?
Suggestions: Ensure the Bot is in the group and as an admin. Try adding a new access token (revoke existing API key and create a new one then replace in plugin settings) If you edited the bot with @BotFather, make sure to restore it to the default settings.
After opening the File Manager, tap the magnifying glass icon to open the search field. Search for Telegram Audio in the search field. Open the Telegram Audio folder. The voice messages in your Telegram are automatically saved in this folder.
Unfortunately, unlike WhatsApp, on Android it is not possible to save Telegram voice messages, but the only solution is to create them and then save them on the PC. You can certainly create audio files from your PC and then download them to your device, but you cannot create one from the message itself.
I solved the issue. It was my fault/bug (mostly). I answer now to my self to share the solution I just found.
Telegram SendVoice API docs states audio file to be sent must be in an .OGG file encoded with OPUS,
so, as described in my question, I used ffmpeg to convert the original (source) file, that was an .MP3, to the .OGG required format.
Unfortunately, for a bug in my program I sent the MP3 original audio instead of the converted OGG :(
Weirdly, Telegram API accept the MP3 audio format WITHOUT errors, but in this case DOES NOT display the spectrogram (showing instead just a continuous line).
Now, by sending the correct .OGG file I get the expected spectrogram!
BTW, to be picky, there is still a MINOR bug on Telegram API, related to the specifications on the API endpoint documentation (sendVoice does accept ALSO .MP3 and not only .OGG files).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With