diff --git a/buzz/transcriber/recording_transcriber.py b/buzz/transcriber/recording_transcriber.py index 1c409e48..81c223f1 100644 --- a/buzz/transcriber/recording_transcriber.py +++ b/buzz/transcriber/recording_transcriber.py @@ -101,7 +101,7 @@ class RecordingTranscriber(QObject): ) # This was commented out as it was causing issues. On the other hand some users are reporting errors without - # this. It is possible isseus were present in older model versions without some config files and now are fixed + # this. It is possible issues were present in older model versions without some config files and now are fixed # # Fix for large-v3 https://github.com/guillaumekln/faster-whisper/issues/547#issuecomment-1797962599 # if self.transcription_options.model.whisper_model_size in {WhisperModelSize.LARGEV3, WhisperModelSize.LARGEV3TURBO}: diff --git a/buzz/widgets/recording_transcriber_widget.py b/buzz/widgets/recording_transcriber_widget.py index ad6b2933..c4cf42d8 100644 --- a/buzz/widgets/recording_transcriber_widget.py +++ b/buzz/widgets/recording_transcriber_widget.py @@ -1,6 +1,7 @@ import os import re import enum +import requests import logging import datetime import sounddevice @@ -66,6 +67,8 @@ class RecordingTranscriberWidget(QWidget): super().__init__(parent) self.sounddevice = custom_sounddevice or sounddevice + self.upload_url = os.getenv("BUZZ_UPLOAD_URL", "") + if flags is not None: self.setWindowFlags(flags) @@ -471,6 +474,18 @@ class RecordingTranscriberWidget(QWidget): elif self.transcriber_mode == RecordingTranscriberMode.APPEND_AND_CORRECT: self.process_transcription_merge(text, self.transcripts, self.transcription_text_box, self.transcript_export_file) + # Upload to server + if self.upload_url: + try: + requests.post( + url=self.upload_url, + json={"kind": "transcript", "text": text}, + headers={'Content-Type': 'application/json'}, + timeout=15 + ) + except Exception as e: + logging.error(f"Transcript upload failed: {str(e)}") + def on_next_translation(self, text: str, _: Optional[int] = None): if len(text) == 0: return @@ -504,6 +519,18 @@ class RecordingTranscriberWidget(QWidget): elif self.transcriber_mode == RecordingTranscriberMode.APPEND_AND_CORRECT: self.process_transcription_merge(text, self.translations, self.translation_text_box, self.translation_export_file) + # Upload to server + if self.upload_url: + try: + requests.post( + url=self.upload_url, + json={"kind": "translation", "text": text}, + headers={'Content-Type': 'application/json'}, + timeout=15 + ) + except Exception as e: + logging.error(f"Translation upload failed: {str(e)}") + def stop_recording(self): if self.transcriber is not None: self.transcriber.stop_recording() diff --git a/docs/docs/preferences.md b/docs/docs/preferences.md index 10cc3b1d..b50fe922 100644 --- a/docs/docs/preferences.md +++ b/docs/docs/preferences.md @@ -99,4 +99,6 @@ Defaults to [user_cache_dir](https://pypi.org/project/platformdirs/). **BUZZ_MERGE_REGROUP_RULE** - Custom regroup merge rule to use when combining transcripts with word-level timings. More information on available options [in stable-ts repo](https://github.com/jianfch/stable-ts?tab=readme-ov-file#regrouping-methods). Available since `1.3.0` -**BUZZ_DISABLE_TELEMETRY** - Buzz collects basic OS name and architecture usage statistics to better focus development efforts. This variable lets disable collection of these statistics. Example usage `BUZZ_DISABLE_TELEMETRY=true`. Available since `1.3.0` \ No newline at end of file +**BUZZ_DISABLE_TELEMETRY** - Buzz collects basic OS name and architecture usage statistics to better focus development efforts. This variable lets disable collection of these statistics. Example usage `BUZZ_DISABLE_TELEMETRY=true`. Available since `1.3.0` + +**BUZZ_UPLOAD_URL** - Live recording transcripts and translations can be uploaded to a server for display on the web. Set this variable to the desired upload url. You can use [buzz-transcription-server](https://github.com/raivisdejus/buzz-transcription-server) as a server. Buzz will upload the following `json` via `POST` requests - `{"kind": "transcript", "text": "Sample transcript"}` or `{"kind": "translation", "text": "Sample translation"}`. Example usage `BUZZ_UPLOAD_URL=http://localhost:5000/upload`. Available since `1.3.0`