This commit is contained in:
2024-09-19 12:40:30 +02:00
parent 7f57da86f0
commit 554852bc53
+8 -1
View File
@@ -5,6 +5,7 @@ import assemblyai as aai
import discord
from discord.ext import commands, voice_recv
from discord.opus import Decoder as OpusDecoder
from queue import Queue, Empty
# Replace with your API key
aai.settings.api_key = "aa9962f0088a449a9c4ab2361e96cc08"
@@ -126,6 +127,8 @@ class Transcriber(commands.Cog):
self.bot = bot
self._last_member = None
self.wsink = SRBuffer(destination="/home/pi/Conjurer/wav.wav")
self.threads = []
self.comm_queue = Queue()
async def transcribe(file_url):
config = aai.TranscriptionConfig(speaker_labels=True, language_code="pl")
@@ -138,7 +141,11 @@ class Transcriber(commands.Cog):
@commands.hybrid_command(name="transcribe")
async def test(self, ctx):
logger.info("Attempt transcribe")
vc = await ctx.author.voice.channel.connect(cls=voice_recv.VoiceRecvClient)
if ctx.client.voice_clients:
voice_client = ctx.client.voice_clients[0]
if not voice_client.is_connected():
logger.info("Connecting to voice")
vc = await ctx.author.voice.channel.connect(cls=voice_recv.VoiceRecvClient)
logger.info("Connected")
vc.listen(self.wsink)