I am trying to send a voice message using a local OGG file. The voice message is sent but when trying to play the file in telegram it seems empty. Any idea why ? Here is the code I'm using :
async def audio_received(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_voice(
chat_id=update.effective_chat.id, voice=open("sample-3.ogg", "rb")
)
if __name__ == "__main__":
application = (
ApplicationBuilder()
.token("MY_TOKEN")
.build()
)
audio_handler = MessageHandler(filters.VOICE, audio_received)
application.add_handler(audio_handler)
application.run_polling()
Thanks a lot for your help!
As per Telegram's documentation on sendVoice, the audio files should satisfy the following:
.oggfile,Since you mentioned that the encoding might have solved this issue, I will take the answer again from this answer: