使用 python-telegram-bot 包向电报机器人发送语音命令
Send voice command to telegram bot using python-telegram-bot Package
我正在尝试使用 python 和 python-telegram-bot 包构建一个电报机器人,它使用文本命令,现在我尝试向用户发送语音命令..
我的代码像
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')
生成了mp3文件,那么如何将该语音文件以任何方式发送给用户?
您要查找的方法在 official API docs. for PTB, it's Bot.send_voice
. See also the Message.reply_voice
shortcut and this wiki entry 关于在 PTB 中处理文件中称为 sendVoice
。
免责声明:我目前是 python-telegram-bot
.
的维护者
我正在尝试使用 python 和 python-telegram-bot 包构建一个电报机器人,它使用文本命令,现在我尝试向用户发送语音命令..
我的代码像
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')
生成了mp3文件,那么如何将该语音文件以任何方式发送给用户?
您要查找的方法在 official API docs. for PTB, it's Bot.send_voice
. See also the Message.reply_voice
shortcut and this wiki entry 关于在 PTB 中处理文件中称为 sendVoice
。
免责声明:我目前是 python-telegram-bot
.