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)?
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
I tried the IBM Watson Text to Speech curl example, it produced a .wav file. I also generated an .mp3, and .ogg files. none of them would play a sound output. I am using Windows 10.
curl -X POST -u "apikey:{my apikey}" --header "Content-Type: application/json" --data "text:hello world" --output hello_world.ogg "{my url}/v1/synthesize/"
If your audio files are not playing, then the chances are that they are not audio files. You are directing any output into your "audio" files, this includes any error messages. If you cat or browse an "audio" file, you will see that it contains text indicating why an audio file was not generated.
I guess this is a duplicate of Having issues with IBM Watson TTS using Curl
Answer update
Re: your comment - That error is typical of a json conversion error. Looking at the API documentation - https://cloud.ibm.com/apidocs/text-to-speech#synthesize - the API is expecting the input data in a json format.
ie.
--data "{\"text\":\"Hello world\"}"
I'm trying to send voice message thorough SendVoice method but it sends the voice as a simple ogg file ( not playable ).
https://api.telegram.org/bot<token>/sendVoice?chat_id=x&voice=http://majidamiri.com/up/5.ogg
In the Telegram API SendVoice it points that the file should be in .ogg opus format , so I converted a mp3 file to opus ogg by ffmpeg with this code :
<?php $myConvert = exec('ffmpeg.exe -i 1.mp3 -acodec libopus -b:a 64k -vbr off -compression_level 10 5.ogg'); ?>
And again like before it sends it as file.
My ogg Link : https://majidamiri.com/up/5.ogg
Can you help me with this issue ?
Thank you all .
I finally made this work, with the help of Telegram support. This is an example with all the flags needed:
ffmpeg -i test.mp3 -ac 1 -map 0:a -codec:a opus -b:a 128k -vbr off -ar 24000 test.ogg
Tested on both Android and Telegram web.
I am working on ffmpeg live streaming, where in i need to encrypt Live Streams. I am trying to figure out the same. I worked with AES, but it works only on a stored file. Can I use https or rtmpe etc by using private keys, SSL certificates etc? Anybody who is working on the same, kindly share your thoughts.
Eg : I am streaming my live cam feed using
ffmpeg -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm
I want to take stream1 as Input and Encrypt it continuously. And at the other end I want to decrypt and Play.
I am working on a RoR website and i upload media files (like mp3,pdf,images and video) on the website. Website is hosted on AWS and i am using S3 bucket to upload the media files.
When i upload a video firstly save the video in public folder of my project on AWS instance where my website is hosted and then create the thumbnail of that video using FFMPEG and get the duration using ffmpeg-streamio and remove this video after creating thumbnail. It's working fine until uploading large video but when i try to upload large video it through an error i. e.
Errno::ENOMEM (Cannot allocate memory - /usr/local/bin/ffmpeg -i /var/www/html/proj/public/13/NVC_trim.mov):
path = "public/" + #admin.id.to_s + "/" + params[:video].original_filename
dirpath = "public/" + #admin.id.to_s
FileUtils.mkdir_p dirpath
aFile = File.new(path, "w")
aFile.write(open(params[:video]).read)
aFile.close
system"/usr/local/bin/ffmpeg -itsoffset -4 -i /var/www/html/proj/#{path} -vcodec mjpeg -vframes 1 -an -f rawvideo /var/www/html/proj/#{dirpath}/thumb.png"
#calculate video duration
FFMPEG.ffmpeg_binary = '/usr/local/bin/ffmpeg'
movie = FFMPEG::Movie.new("/var/www/html/proj/#{path}")
Am i missing something in the code?
Any idea or help in this will be highly appreciated.
Thanks in advance :)
When I try to upload an uncompressed json file, it works fine; but when I try a gzipped version of the same json file, the job would fail with lexical error resulted from failure to parse the json content.
I gzipped the json file with the gzip command from Mac OSX 10.8 and I have set the sourceFormat to: "NEWLINE_DELIMITED_JSON".
Did I do something incorrectly or gzipped json file should be processed differently?
I believe that using the multipart/related request it is not possible to submit binary data (such as the compressed file. However, if you don't want to use uncompressed data, you may be able to use resumable upload.
What language are you coding in? The python jobs.insert() api takes a media upload parameter, which you should be able to give a filename to in order to do resumable upload (which sends your job metadata and new table data as separate streams). I was able to use this to upload a compressed file.
This is what bq.py uses, so you could look at the source code here.
If you aren't using python, the googleapis client libraries for other languages should have similar functionality.
You can upload gzipped files to Google Cloud Storage, and BigQuery will be able to ingest it with a load job:
https://developers.google.com/bigquery/loading-data-into-bigquery#loaddatagcs