Andrew
Andrew

Reputation: 846

Send voice command to telegram bot using python-telegram-bot Package

I am try to build a telegram bot using python with python-telegram-bot Package and its working with text commands now i try to send a voice command to user ..

my code like

def start(update, context):
engine = pyttsx3.init()
engine.save_to_file('welcome to this bot', 'voice.mp3')
engine.runAndWait()

#return update.message.reply_text('hi i am bot with your friend')

the mp3 file is generated , Then how to send that voice file to user any way ?

Upvotes: 1

Views: 3896

Answers (1)

CallMeStag
CallMeStag

Reputation: 7050

The method you're looking for is called sendVoice in the official API docs. for PTB, it's Bot.send_voice. See also the Message.reply_voice shortcut and this wiki entry about working with files in PTB.


Disclaimer: I'm currently the maintainer of python-telegram-bot.

Upvotes: 5

Related Questions