diff --git a/buzz/buzz.py b/buzz/buzz.py index d4a7a34b..6f434353 100644 --- a/buzz/buzz.py +++ b/buzz/buzz.py @@ -25,8 +25,11 @@ from buzz.assets import APP_BASE_DIR if getattr(sys, "frozen", False) is False and platform.system() != "Windows": faulthandler.enable() -# Sets stderr to no-op TextIO when None (run as Windows GUI). -# Resolves https://github.com/chidiwilliams/buzz/issues/221 +# Sets stdout/stderr to no-op TextIO when None (run as Windows GUI with --noconsole). +# stdout fix: torch.hub uses sys.stdout.write() for download progress and crashes if None. +# stderr fix: Resolves https://github.com/chidiwilliams/buzz/issues/221 +if sys.stdout is None: + sys.stdout = TextIO() if sys.stderr is None: sys.stderr = TextIO() diff --git a/buzz/file_transcriber_queue_worker.py b/buzz/file_transcriber_queue_worker.py index 1babc641..8e5cf1a8 100644 --- a/buzz/file_transcriber_queue_worker.py +++ b/buzz/file_transcriber_queue_worker.py @@ -53,6 +53,7 @@ if sys.platform == "win32": from demucs import api as demucsApi +from buzz.locale import _ from buzz.model_loader import ModelType from buzz.transcriber.file_transcriber import FileTranscriber from buzz.transcriber.openai_whisper_api_file_transcriber import ( @@ -127,11 +128,19 @@ class FileTranscriberQueueWorker(QObject): separator = None separated = None try: + # Force CPU if specified, otherwise use CUDA if available + force_cpu = os.getenv("BUZZ_FORCE_CPU", "false").lower() == "true" + if force_cpu: + device = "cpu" + else: + import torch + device = "cuda" if torch.cuda.is_available() else "cpu" separator = demucsApi.Separator( + device=device, progress=True, callback=separator_progress_callback, ) - _, separated = separator.separate_audio_file(Path(self.current_task.file_path)) + _origin, separated = separator.separate_audio_file(Path(self.current_task.file_path)) task_file_path = Path(self.current_task.file_path) self.speech_path = task_file_path.with_name(f"{task_file_path.stem}_speech.mp3") @@ -140,6 +149,12 @@ class FileTranscriberQueueWorker(QObject): self.current_task.file_path = str(self.speech_path) except Exception as e: logging.error(f"Error during speech extraction: {e}", exc_info=True) + self.task_error.emit( + self.current_task, + _("Speech extraction failed! Check your internet connection — a model may need to be downloaded."), + ) + self.is_running = False + return finally: # Release memory used by speech extractor del separator, separated diff --git a/buzz/locale/ca_ES/LC_MESSAGES/buzz.po b/buzz/locale/ca_ES/LC_MESSAGES/buzz.po index 679658da..802fbed5 100644 --- a/buzz/locale/ca_ES/LC_MESSAGES/buzz.po +++ b/buzz/locale/ca_ES/LC_MESSAGES/buzz.po @@ -1482,6 +1482,12 @@ msgstr "Afegeix a sobre" msgid "Append and correct" msgstr "Afegeix i corregeix" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Avís de permís d'ajust" diff --git a/buzz/locale/da_DK/LC_MESSAGES/buzz.po b/buzz/locale/da_DK/LC_MESSAGES/buzz.po index f916fc62..957c2c1a 100644 --- a/buzz/locale/da_DK/LC_MESSAGES/buzz.po +++ b/buzz/locale/da_DK/LC_MESSAGES/buzz.po @@ -1473,6 +1473,12 @@ msgstr "Tilføj herover" msgid "Append and correct" msgstr "Tilføj og ret" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Snap tilladelse notifikationer" diff --git a/buzz/locale/de_DE/LC_MESSAGES/buzz.po b/buzz/locale/de_DE/LC_MESSAGES/buzz.po index c7ea808f..d7f2fc6d 100644 --- a/buzz/locale/de_DE/LC_MESSAGES/buzz.po +++ b/buzz/locale/de_DE/LC_MESSAGES/buzz.po @@ -1475,6 +1475,12 @@ msgstr "Oben anhängen" msgid "Append and correct" msgstr "Anhängen und korrigieren" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Snap-Berechtigungsmitteilung" diff --git a/buzz/locale/en_US/LC_MESSAGES/buzz.po b/buzz/locale/en_US/LC_MESSAGES/buzz.po index d6d7e1a0..f614c61b 100644 --- a/buzz/locale/en_US/LC_MESSAGES/buzz.po +++ b/buzz/locale/en_US/LC_MESSAGES/buzz.po @@ -1442,3 +1442,9 @@ msgstr "" #: buzz/settings/recording_transcriber_mode.py:7 msgid "Append and correct" msgstr "" + +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" diff --git a/buzz/locale/es_ES/LC_MESSAGES/buzz.po b/buzz/locale/es_ES/LC_MESSAGES/buzz.po index c9e05f66..fb146e67 100644 --- a/buzz/locale/es_ES/LC_MESSAGES/buzz.po +++ b/buzz/locale/es_ES/LC_MESSAGES/buzz.po @@ -1543,6 +1543,12 @@ msgstr "Añadir arriba" msgid "Append and correct" msgstr "Añadir y corregir" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Aviso de permiso Snap" diff --git a/buzz/locale/it_IT/LC_MESSAGES/buzz.po b/buzz/locale/it_IT/LC_MESSAGES/buzz.po index 4853a48e..26134032 100644 --- a/buzz/locale/it_IT/LC_MESSAGES/buzz.po +++ b/buzz/locale/it_IT/LC_MESSAGES/buzz.po @@ -1484,6 +1484,12 @@ msgstr "Aggiungere sopra" msgid "Append and correct" msgstr "Aggiungere e correggere" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Avviso di autorizzazione Snap" diff --git a/buzz/locale/ja_JP/LC_MESSAGES/buzz.po b/buzz/locale/ja_JP/LC_MESSAGES/buzz.po index e5e67066..4d6e8424 100644 --- a/buzz/locale/ja_JP/LC_MESSAGES/buzz.po +++ b/buzz/locale/ja_JP/LC_MESSAGES/buzz.po @@ -1468,6 +1468,12 @@ msgstr "" msgid "Append and correct" msgstr "" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Snap権限通知" diff --git a/buzz/locale/lv_LV/LC_MESSAGES/buzz.po b/buzz/locale/lv_LV/LC_MESSAGES/buzz.po index 1dc854bb..d3902732 100644 --- a/buzz/locale/lv_LV/LC_MESSAGES/buzz.po +++ b/buzz/locale/lv_LV/LC_MESSAGES/buzz.po @@ -1477,6 +1477,14 @@ msgstr "Jaunie teikumi augšā" msgid "Append and correct" msgstr "Papildināt un labot esošo" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" +"Runas atdalīšana neizdevās! Pārbaudiet interneta savienojumu, iespējams " +"jālejupielādē modelis." + #~ msgid "Snap permission notice" #~ msgstr "Snap atļauju piezīme" diff --git a/buzz/locale/nl/LC_MESSAGES/buzz.po b/buzz/locale/nl/LC_MESSAGES/buzz.po index 745ffb9b..724904af 100644 --- a/buzz/locale/nl/LC_MESSAGES/buzz.po +++ b/buzz/locale/nl/LC_MESSAGES/buzz.po @@ -1474,6 +1474,12 @@ msgstr "Bovenaan toevoegen" msgid "Append and correct" msgstr "Toevoegen en corrigeren" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Snap-rechten" diff --git a/buzz/locale/pl_PL/LC_MESSAGES/buzz.po b/buzz/locale/pl_PL/LC_MESSAGES/buzz.po index 380ad41e..f79442bb 100644 --- a/buzz/locale/pl_PL/LC_MESSAGES/buzz.po +++ b/buzz/locale/pl_PL/LC_MESSAGES/buzz.po @@ -1492,6 +1492,12 @@ msgstr "" msgid "Append and correct" msgstr "" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "ID" #~ msgstr "ID" diff --git a/buzz/locale/pt_BR/LC_MESSAGES/buzz.po b/buzz/locale/pt_BR/LC_MESSAGES/buzz.po index db6d0fbe..1e37df69 100644 --- a/buzz/locale/pt_BR/LC_MESSAGES/buzz.po +++ b/buzz/locale/pt_BR/LC_MESSAGES/buzz.po @@ -1478,6 +1478,12 @@ msgstr "Acrescentar acima" msgid "Append and correct" msgstr "Acrescentar e corrigir" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Aviso de permissão do Snap" diff --git a/buzz/locale/uk_UA/LC_MESSAGES/buzz.po b/buzz/locale/uk_UA/LC_MESSAGES/buzz.po index 597c47ef..f12ab79c 100644 --- a/buzz/locale/uk_UA/LC_MESSAGES/buzz.po +++ b/buzz/locale/uk_UA/LC_MESSAGES/buzz.po @@ -1470,6 +1470,12 @@ msgstr "" msgid "Append and correct" msgstr "" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "Попередження щодо дозволів Snap" diff --git a/buzz/locale/zh_CN/LC_MESSAGES/buzz.po b/buzz/locale/zh_CN/LC_MESSAGES/buzz.po index 773cbbe6..27ce95c6 100644 --- a/buzz/locale/zh_CN/LC_MESSAGES/buzz.po +++ b/buzz/locale/zh_CN/LC_MESSAGES/buzz.po @@ -1492,6 +1492,12 @@ msgstr "增加上方" msgid "Append and correct" msgstr "增加并纠正" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "Snap permission notice" #~ msgstr "快照权限通知" diff --git a/buzz/locale/zh_TW/LC_MESSAGES/buzz.po b/buzz/locale/zh_TW/LC_MESSAGES/buzz.po index 52c19593..a1d78091 100644 --- a/buzz/locale/zh_TW/LC_MESSAGES/buzz.po +++ b/buzz/locale/zh_TW/LC_MESSAGES/buzz.po @@ -1484,6 +1484,12 @@ msgstr "" msgid "Append and correct" msgstr "" +#: buzz/file_transcriber_queue_worker.py:161 +msgid "" +"Speech extraction failed! Check your internet connection — a model may need " +"to be downloaded." +msgstr "" + #~ msgid "ID" #~ msgstr "ID"