Telegram Bot API: voice message audio spectrogram is missing. A bug?

Viewed 1636

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?

enter image description here

$ 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)?

1 Answers

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

Related