diff --git a/audio_getter.py b/audio_getter.py index 05475ed..e2ab133 100644 --- a/audio_getter.py +++ b/audio_getter.py @@ -60,7 +60,7 @@ class StreamAudioGetter(): def __init__(self, url: str, direct_url: bool, format: str, cookies: str, frame_duration: float): - print("Opening stream {}".format(url)) + print("Opening stream: {}".format(url)) self.ffmpeg_process, self.ytdlp_process = _open_stream(url, direct_url, format, cookies) self.byte_size = round(frame_duration * SAMPLE_RATE * 2) # Factor 2 comes from reading the int16 stream as bytes diff --git a/gpt_translator.py b/gpt_translator.py index 7a2d7bd..23e24ce 100644 --- a/gpt_translator.py +++ b/gpt_translator.py @@ -83,8 +83,8 @@ def work(self, input_queue: queue.SimpleQueue[TranslationTask], current_task = None while True: if current_task: - if current_task.translated_text or datetime.utcnow( - ) - current_task.start_time > timedelta(seconds=self.timeout): + if (current_task.translated_text or datetime.utcnow( + ) - current_task.start_time > timedelta(seconds=self.timeout)): if current_task.translated_text: # self.history_messages.append({"role": "user", "content": current_task.transcribed_text}) self.history_messages.append({ @@ -96,15 +96,15 @@ def work(self, input_queue: queue.SimpleQueue[TranslationTask], else: print("Translation timeout or failed: {}".format( current_task.transcribed_text)) - output_queue.append(current_task) + output_queue.put(current_task) current_task = None - if current_task is None and not input_queue.empty(): - current_task = input_queue.get() - current_task.start_time = datetime.utcnow() - thread = threading.Thread(target=_translate_by_gpt, - args=(self.client, current_task, self.prompt, - self.model, self.history_messages)) - thread.daemon = True - thread.start() + if current_task is None and not input_queue.empty(): + current_task = input_queue.get() + current_task.start_time = datetime.utcnow() + thread = threading.Thread(target=_translate_by_gpt, + args=(self.client, current_task, self.prompt, + self.model, self.history_messages)) + thread.daemon = True + thread.start() time.sleep(0.1)