Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ionic-bond committed Dec 21, 2023
1 parent 9374f67 commit a47fbb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion audio_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions gpt_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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)

0 comments on commit a47fbb5

Please sign in to comment.