This commit is contained in:
2024-09-20 14:19:16 +02:00
parent b3121aaaf2
commit b025790b3d
+10 -14
View File
@@ -126,10 +126,11 @@ class SRBuffer(voice_recv.AudioSink):
class Transcriber(commands.Cog):
def __init__(self, bot):
def __init__(self, bot, worker, queue):
self.bot = bot
self.threads = []
self.comm_queue = Queue()
self.comm_queue = queue
self.worker = worker
self.wsink = SRBuffer(self.comm_queue)
async def transcribe(self,file_url):
config = aai.TranscriptionConfig(speaker_labels=True, language_code="pl")
@@ -156,7 +157,7 @@ class Transcriber(commands.Cog):
logger.info(self.bot.voice_clients)
self.output_handler.work = True
self.output_handler.scan_loop.start()
self.worker.start()
vc.listen(self.wsink)
@tasks.loop(seconds=0.5)
@@ -208,27 +209,22 @@ class Transcriber(commands.Cog):
self.output_handler.work = False
self.check_data.stop()
self.worker.stop()
await ctx.voice_client.disconnect()
def transcribe_output_queue():
def transcribe_output_queue(queue):
while True:
time.sleep(10.0)
queue.get()
logger.info("PING")
async def setup(bot):
logger = logging.getLogger("discord")
logger.info("Loading voice transcribed module phase one")
threads = []
threads.append(threading.Thread(target=transcribe_output_queue))
worker = threading.Thread(target=transcribe_output_queue)
logger.info("Loading voice transcribed phase two")
for worker in threads:
worker.start()
queue = Queue()
logger.info("Loading voice transcribed module phase three")
await bot.add_cog(Transcriber(bot))
await bot.add_cog(Transcriber(bot, worker, queue))
logger.info("Loading voice transcribed module done")
# 1. zapisuj kwestie człowieka do pliku w którym będzie można stwierdzić kto co powiedział (callback z basicaudio + write z wavesinka). Zamykaj plik i wysyłaj do transkrypcji w momencie ciszy dłuższej niż 0.5s. Jeśli człowiek nadaje cały czas dawaj sygnał że nie można go transkrybować - i wyłaczaj zapis.