Q&A
実現したいこと
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OpusNotLoaded: をなおしたい
前提
replitというサイトを使ってクラウド上でdiscordの読み上げbotを作っています
実機のWindows10での動作確認ではちゃんと動きました
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 229, in wrapped ret = await coro(*args, **kwargs) File "main.py", line 525, in test2 ctx.voice_client.play(discord.FFmpegPCMAudio("output.mp3")) File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/voice_client.py", line 609, in play self.encoder = opus.Encoder() File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/opus.py", line 323, in __init__ _OpusStruct.get_opus_version() File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/opus.py", line 316, in get_opus_version raise OpusNotLoaded() discord.opus.OpusNotLoaded The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1349, in invoke await ctx.command.invoke(ctx) File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1023, in invoke await injected(*ctx.args, **ctx.kwargs) # type: ignore File "/home/runner/discordbot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 238, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OpusNotLoaded:
該当のソースコード
python
1 2from discord.ext import commands 3from gtts import gTTS 4 5 6@bot.command(name=mycommands['readaloud']['name'], 7 aliases=mycommands['readaloud']['aliases']) 8async def Readaloud(ctx, Usertext): 9 10 #ボイチャに入っているか確認 11 if ctx.author.voice == None: 12 await ctx.send("ボイスチャンネルに参加していません") 13 return 14 if ctx.voice_client == None: 15 await ctx.author.voice.channel.connect() 16 await ctx.send("ボイスチャンネルに接続しました") 17 else: 18 await ctx.voice_client.move_to(ctx.author.voice.channel) 19 20 # #usernameを取得 21 user_name = ctx.author.name + "からのメッセージ、" 22 #生成 23 24 tts = gTTS(user_name + Usertext, lang='ja') 25 26 tts.save('output.mp3') 27 await ctx.send("生成完了") 28 29 #再生 30 ctx.voice_client.play(discord.FFmpegPCMAudio("output.mp3"))
補足情報(FW/ツールのバージョンなど)
Python 3.8.12
使用しているサイト https://replit.com/
回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2023/03/25 12:18
2023/03/27 07:56
2023/04/02 09:01
2023/04/03 07:50
2023/04/04 06:31