How to convert Telegram voice in a wave file in python

后端 未结 2 421
长发绾君心
长发绾君心 2021-01-25 02:34

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.         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-01-25 03:02

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

提交回复
热议问题