我正在尝试使用 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文件,那么如何将该语音文件发送给用户呢?
您正在寻找的方法sendVoice
在官方 API 文档中被调用。对于 PTB,它是Bot.send_voice
. 另请参阅有关在 PTB 中处理文件的Message.reply_voice
快捷方式和此wiki 条目。
免责声明:我目前是python-telegram-bot
.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句