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