python - discord.py bot 连接到语音通道但 OpusNotLoaded,以及 discord.opus.load_opus() 的问题
问题描述
我正在尝试将我的机器人连接到语音通道,然后播放 mp3 文件。
这是我的原始代码:
@client.command(name='voice', case_insensitive=True)
async def voice(context):
channel = context.author.voice.channel
await channel.connect()
guild = context.guild
voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=guild)
voice_client.play(discord.FFmpegPCMAudio('voices/bonjour.mp3', executable='/Users/rimelmallah/Desktop/Python/ffmpeg'), after=None)
我收到了这个错误:discord.opus.OpusNotLoaded
所以我在最后一行之前添加了这行代码:discord.opus.load_opus()
当我这样做时,我得到了这个错误:TypeError: load_opus() missing 1 required positional argument: 'name'
所以我尝试将我的代码行修改为:discord.opus.load_opus('opus')
这次我收到以下错误:OSError: dlopen(opus, 6): image not found
我试图从这个链接安装 Opus:https
://opus-codec.org/release/stable/2019/04/12/libopus-1_3_1.html
但它没有用。
解决方案
文档说name
是The filename of the shared library.
. load_opus()
如果库与您的 python 文件不在同一目录中,则您必须为函数提供确切的名称,可能还带有文件路径。
该文件应该被称为
libopus-0-x64.dll
但是,有一些事情需要注意。查看文档以获取更多信息
推荐阅读
- charts - Power BI 自定义模式窗口
- python - 在 Python Jinja 模板中的 for 循环内应用 if 语句
- testing - 如何在flask-restul资源方法中模拟函数调用
- angular6 - angular6中如何实现社交分享?
- ios - 如何在 Swift 中创建包含字符串部分和字节数据的新数据?
- mysql - mysql - 将列增加 1 并重新索引它有多贵
- javascript - 正则表达式的拆分字符串在 javascript 中无法正常工作
- c++ - 断开 qt 计时器以进行单元测试
- python - 如何在文本小部件 tkinter 中突出显示最后添加的文本
- css - 在桌面 PC 上,首先加载移动 css,然后切换到桌面版本