前提・実現したいこと
glitchを使ってテキストを読み上げるdiscord botを作りたいと思っています
現在botはオンラインなのですが、反応が返ってきません
何が問題なのでしょうか、とりあえずVCに入るようにしたいです
コードは色々なところから借りています
発生している問題・エラーメッセージ
glitchのログにエラーは多分出てないです 以下ログです
Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: discord.py[voice] in ./.local/lib/python3.7/site-packages (1.6.0) Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in ./.local/lib/python3.7/site-packages (from discord.py[voice]) (3.7.3) Requirement already satisfied: PyNaCl<1.5,>=1.3.0 in ./.local/lib/python3.7/site-packages (from discord.py[voice]) (1.4.0) Requirement already satisfied: async-timeout<4.0,>=3.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.0.1) Requirement already satisfied: multidict<7.0,>=4.5 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (5.1.0) Requirement already satisfied: yarl<2.0,>=1.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (1.6.3) Requirement already satisfied: attrs>=17.3.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (20.3.0) Requirement already satisfied: chardet<4.0,>=2.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.0.4) Requirement already satisfied: typing-extensions>=3.6.5 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.7.4.3) Requirement already satisfied: cffi>=1.4.1 in ./.local/lib/python3.7/site-packages (from PyNaCl<1.5,>=1.3.0->discord.py[voice]) (1.14.4) Requirement already satisfied: six in ./.local/lib/python3.7/site-packages (from PyNaCl<1.5,>=1.3.0->discord.py[voice]) (1.15.0) Requirement already satisfied: pycparser in ./.local/lib/python3.7/site-packages (from cffi>=1.4.1->PyNaCl<1.5,>=1.3.0->discord.py[voice]) (2.20) Requirement already satisfied: idna>=2.0 in ./.local/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.1)
該当のソースコード
python
1import asyncio 2import re 3from aquestalk import * 4import discord 5from discord.ext import commands 6 7bot = commands.Bot(command_prefix='.') 8 9@bot.event 10async def on_ready(): 11 print("ready") 12 13@bot.command() 14async def s(ctx): 15 #voicechannelを取得 16 vc = ctx.author.voice.channel 17 #voicechannelに接続 18 await vc.connect() 19 20@bot.command() 21async def e(ctx): 22 await vc.disconnect() 23 24@bot.event 25async def on_message(message): 26 # bot自身のメッセージは何もしない 27 if message.author.bot: 28 return 29 30 # ユーザーidが含まれる場合ユーザー名に変換する 31 pattern = r"<@!(?P<user_id>\d+)>" 32 m = re.match(pattern, message.content) 33 if m: 34 user_name = bot.get_user(int(m.group("user_id"))).name 35 message.content = re.sub(pattern, user_name, message.content) 36 37 # URLは省略する 38 pattern = r"https?://[\w/:%#$&?()~.=+\-]+" 39 m = re.match(pattern, message.content) 40 if m: 41 message.content = re.sub(pattern, 'URL省略', message.content) 42 43 # 喋っている途中は待つ 44 while voice_client.is_playing(): 45 await asyncio.sleep(0.5) 46 47 # wavファイルに変換 48 aq = aquestalk.load('f1') 49 wav = aq.synthe("message.content") 50 type(wav) 51 52 # wavファイルをボイチャに流す 53 source = discord.FFmpegPCMAudio(wav) 54 voice_client.play(source) 55 56 await bot.process_commands(message) 57 58bot.run()
json
1{ 2 "install": "pip3 install -U discord.py[voice]", 3 "start": "python3 discordbot.py" 4}
あなたの回答
tips
プレビュー