mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
fx
This commit is contained in:
+8
-10
@@ -6,7 +6,6 @@ import discord
|
||||
from discord.ext import commands, voice_recv, tasks
|
||||
from discord.opus import Decoder as OpusDecoder
|
||||
import time
|
||||
import threading
|
||||
# Replace with your API key
|
||||
aai.settings.api_key = "aa9962f0088a449a9c4ab2361e96cc08"
|
||||
discord.opus._load_default()
|
||||
@@ -52,10 +51,6 @@ class WaveWriter:
|
||||
|
||||
def rotate(self):
|
||||
|
||||
logger.info("Before rotation")
|
||||
logger.info(self.file_name_present)
|
||||
logger.info(self.file_name_past)
|
||||
|
||||
self.transcript_file_present.close()
|
||||
self.file_name_past = self.file_name_present
|
||||
if self.present_file_id > 10:
|
||||
@@ -72,9 +67,7 @@ class WaveWriter:
|
||||
self.transcript_file_future.setsampwidth(SAMPLE_WIDTH)
|
||||
self.transcript_file_future.setframerate(SAMPLING_RATE)
|
||||
operation = CommunicationObject(msg_type="send_file",user=self.user,data=[self.file_name_present])
|
||||
logger.info("After rotation")
|
||||
logger.info(self.file_name_present)
|
||||
logger.info(self.file_name_past)
|
||||
logger.info("Item added to queue %s %s", self.queue, operation)
|
||||
|
||||
self.queue.put(operation)
|
||||
|
||||
@@ -109,7 +102,7 @@ class SRBuffer(voice_recv.AudioSink):
|
||||
return False
|
||||
|
||||
def write(self, user, data) -> None:
|
||||
logger.info("DAta write")
|
||||
#logger.info("DAta write")
|
||||
if user:
|
||||
self.wavewriter[str(user.id)][0].writeframes(data.pcm)
|
||||
self.wavewriter[str(user.id)][1] = time.time_ns() #time from last write
|
||||
@@ -131,6 +124,7 @@ class Transcriber(commands.Cog):
|
||||
self.threads = []
|
||||
self.comm_queue = asyncio.Queue()
|
||||
self.wsink = SRBuffer(self.comm_queue)
|
||||
self.worker = None
|
||||
|
||||
@commands.hybrid_command(name="transcribe")
|
||||
async def test(self, ctx):
|
||||
@@ -151,7 +145,7 @@ class Transcriber(commands.Cog):
|
||||
logger.info("Start worker!~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
#ev_loop = asyncio.get_event_loop()
|
||||
run_loop = asyncio.get_running_loop()
|
||||
run_loop.run(self.transcribe_output_queue())
|
||||
self.worker = run_loop.create_task(self.transcribe_output_queue())
|
||||
vc.listen(self.wsink)
|
||||
|
||||
|
||||
@@ -182,6 +176,7 @@ class Transcriber(commands.Cog):
|
||||
elif after.channel is None:
|
||||
logger.info("User %s disconnected from channel %s", user, before.channel.name)
|
||||
operation = CommunicationObject(msg_type="user_cleanup", user=user, data=None)
|
||||
logger.info("Item added to queue %s %s", self.queue, operation)
|
||||
self.comm_queue.put(operation)
|
||||
else:
|
||||
logger.info("User VC status changed %s", user.id)
|
||||
@@ -193,6 +188,8 @@ class Transcriber(commands.Cog):
|
||||
async def stop(self, ctx):
|
||||
self.check_data.stop()
|
||||
stop_token = CommunicationObject("STOP",None,None)
|
||||
logger.info("Item added to queue %s %s", self.queue, stop_token)
|
||||
|
||||
self.comm_queue.put(stop_token)
|
||||
await ctx.voice_client.disconnect()
|
||||
|
||||
@@ -202,6 +199,7 @@ class Transcriber(commands.Cog):
|
||||
transcriber = aai.Transcriber()
|
||||
while True:
|
||||
item = self.queue.get()
|
||||
logger.info("Got %s", item)
|
||||
if item.type == "STOP":
|
||||
logger.info("Queue ended")
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user