【问题标题】:Send voice command to telegram bot using python-telegram-bot Package使用 python-telegram-bot 包向电报机器人发送语音命令
【发布时间】:2021-07-13 17:23:33
【问题描述】:

我正在尝试使用带有 python-telegram-bot 包的 python 构建一个电报机器人,并且它使用文本命令现在我尝试向用户发送语音命令..

我的代码喜欢

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文件,那么如何将那个语音文件发送给用户呢?

【问题讨论】:

  • 好的,这似乎是一个关于模块使用的超级基本问题,我感觉电报机器人模块的文档包括发送语音消息,你看过文档吗?
  • 你到底有什么不明白的?以下是您可能需要的一些文档:python-telegram-bot.readthedocs.io/en/stable/…

标签: python bots python-telegram-bot


【解决方案1】:

您要查找的方法在official API docs 中称为sendVoice。对于 PTB,它是 Bot.send_voice。另请参阅 Message.reply_voice 快捷方式和此 wiki entry 关于在 PTB 中处理文件的信息。


免责声明:我目前是python-telegram-bot 的维护者。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-05
    • 2018-05-17
    • 2020-10-01
    • 2021-06-11
    • 1970-01-01
    • 2021-08-22
    • 2021-12-06
    • 1970-01-01
    相关资源
    最近更新 更多