Skip to content

Commit 4b41da5

Browse files
committed
Additional fixes for recording transcriber
1 parent a42536d commit 4b41da5

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

buzz/transcriber/recording_transcriber.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def start(self):
302302
next_text: str = result.get("text")
303303

304304
# Update initial prompt between successive recording chunks
305-
initial_prompt += next_text
305+
initial_prompt = next_text
306306

307307
logging.debug(
308308
"Received next result, length = %s, time taken = %s",
@@ -315,7 +315,11 @@ def start(self):
315315

316316
except PortAudioError as exc:
317317
self.error.emit(str(exc))
318-
logging.exception("")
318+
logging.exception("PortAudio error during recording")
319+
return
320+
except Exception as exc:
321+
logging.exception("Unexpected error during recording")
322+
self.error.emit(str(exc))
319323
return
320324

321325
self.finished.emit()
@@ -361,7 +365,11 @@ def stop_recording(self):
361365
self.is_running = False
362366
if self.process and self.process.poll() is None:
363367
self.process.terminate()
364-
self.process.wait(timeout=5)
368+
try:
369+
self.process.wait(timeout=5)
370+
except subprocess.TimeoutExpired:
371+
self.process.kill()
372+
logging.warning("Whisper server process had to be killed after timeout")
365373

366374
def start_local_whisper_server(self):
367375
# Reduce verbose HTTP client logging from OpenAI/httpx
@@ -466,4 +474,7 @@ def start_local_whisper_server(self):
466474
def __del__(self):
467475
if self.process and self.process.poll() is None:
468476
self.process.terminate()
469-
self.process.wait(timeout=5)
477+
try:
478+
self.process.wait(timeout=5)
479+
except subprocess.TimeoutExpired:
480+
self.process.kill()

buzz/widgets/audio_meter_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ def update_amplitude(self, amplitude: float):
7676
self.current_amplitude = max(
7777
amplitude, self.current_amplitude * self.SMOOTHING_FACTOR
7878
)
79-
self.repaint()
79+
self.update()

buzz/widgets/recording_transcriber_widget.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def __init__(
213213
self.presentation_options_bar.hide()
214214
self.copy_actions_bar = self.create_copy_actions_bar()
215215
layout.addWidget(self.copy_actions_bar) # Add at the bottom
216-
self.copy_actions_bar.hide()
216+
self.copy_actions_bar.hide()
217217

218218
def create_presentation_options_bar(self) -> QWidget:
219219
"""Crete the presentation options bar widget"""
@@ -297,15 +297,15 @@ def create_copy_actions_bar(self) -> QWidget:
297297
layout = QHBoxLayout(bar)
298298
layout.setContentsMargins(5, 5, 5, 5)
299299
layout.setSpacing(10)
300-
300+
301301
layout.addStretch() # Push button to the right
302-
302+
303303
self.copy_transcript_button = QPushButton(_("Copy"), bar)
304304
self.copy_transcript_button.setToolTip(_("Copy transcription to clipboard"))
305305
self.copy_transcript_button.clicked.connect(self.on_copy_transcript_clicked)
306306
layout.addWidget(self.copy_transcript_button)
307-
308-
return bar
307+
308+
return bar
309309

310310
def on_copy_transcript_clicked(self):
311311
"""Handle copy transcript button click"""
@@ -340,7 +340,7 @@ def on_copy_transcript_clicked(self):
340340

341341
self.copy_transcript_button.setText(_("Copied!"))
342342
QTimer.singleShot(2000, lambda: self.copy_transcript_button.setText(_("Copy")))
343-
343+
344344
def on_show_presentation_clicked(self):
345345
"""Handle click on 'Show in new window' button"""
346346
if self.presentation_window is None or not self.presentation_window.isVisible():
@@ -870,6 +870,7 @@ def stop_recording(self):
870870

871871
def on_transcriber_finished(self):
872872
self.reset_record_button()
873+
# Restart amplitude listener now that the transcription stream is closed
873874
self.reset_recording_amplitude_listener()
874875

875876
def on_transcriber_error(self, error: str):

0 commit comments

Comments
 (0)