I built a Telegram chatbot using python-telegram-bot
library. The problem is with send voice message from the bot to the user. The voice message plays fine on Android but it doesn't on IOS and MacOS. Here is the code where I convert the audio file and send the voice message.
subprocess.call(["ffmpeg", "-n", "-i", telegram_username+"_response_audio.mp3", "-acodec", "aac", "-ac", "2", "-ar", "44100", telegram_username+"_response_audio.aac"])
await update.message.reply_voice(voice=open(telegram_username+"_response_audio.aac", 'rb'), reply_to_message_id=message_id, duration=audio_duration)
Here is what I tried to fix it:
- Since Telegram uses ogg/oga as default audio file format. So I tried to convert it into ogg format before sending the voice. But that didn't help.
- I also tried different audio formats and codecs. Nothing worked.
Would be grateful if someone point me in the right directions. Thanks