Adding option to upload live transcripts to a server (#1171)

This commit is contained in:
Raivis Dejus 2025-05-23 14:47:51 +03:00 committed by GitHub
commit 3844fc0ba2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 2 deletions

View file

@ -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}:

View file

@ -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()

View file

@ -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`
**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`