How To Convert Telegram Voice In A Wave File In Python
I'm trying to save a Telegram voice file in a wave audio file using soundfile library: def ReceiveVoice(bot, update, user_data): voice = bot.getFile(update.message.voice.file_i
Solution 1:
You could try to use ffmpeg to convert from ogg
to wav
by executing the following command line using python's module subprocess.
importsubprocesssrc_filename='captured.ogg'
dest_filename = 'output.wav'
process = subprocess.run(['ffmpeg', '-i', src_filename, dest_filename])
if process.returncode != 0:
raise Exception("Something went wrong")
Solution 2:
Try this
import soundfile as sf
data, samplerate = sf.read(input_ogg)
sf.write(output_wav, data, samplerate)
Post a Comment for "How To Convert Telegram Voice In A Wave File In Python"