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.
You could try to use ffmpeg to convert from ogg
to wav
by executing the following command line using python's module subprocess.
import subprocess
src_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")
Try this
import soundfile as sf
data, samplerate = sf.read(input_ogg)
sf.write(output_wav, data, samplerate)