|
@@ -1,6 +1,7 @@
|
|
|
"""Output sinks for transcripts."""
|
|
"""Output sinks for transcripts."""
|
|
|
|
|
|
|
|
import json
|
|
import json
|
|
|
|
|
+import logging
|
|
|
import wave
|
|
import wave
|
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
@@ -9,6 +10,8 @@ import numpy as np
|
|
|
|
|
|
|
|
from .transcriber import TranscriptResult
|
|
from .transcriber import TranscriptResult
|
|
|
|
|
|
|
|
|
|
+logger = logging.getLogger(__name__)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def write_wav(path: Path, audio: np.ndarray, sample_rate: int) -> None:
|
|
def write_wav(path: Path, audio: np.ndarray, sample_rate: int) -> None:
|
|
|
"""Write float32 mono audio in [-1, 1] to a 16-bit PCM WAV file."""
|
|
"""Write float32 mono audio in [-1, 1] to a 16-bit PCM WAV file."""
|
|
@@ -68,7 +71,11 @@ class TranscriptSink:
|
|
|
|
|
|
|
|
audio_path = None
|
|
audio_path = None
|
|
|
if self.save_audio and audio is not None:
|
|
if self.save_audio and audio is not None:
|
|
|
- audio_path = self._save_audio(audio, reason)
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ audio_path = self._save_audio(audio, reason)
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ # Best-effort side output: a failed save must not drop the transcript.
|
|
|
|
|
+ logger.warning("Failed to save audio for this utterance: %s", e)
|
|
|
|
|
|
|
|
# Stdout line: [HH:MM:SS] (lang) text [rms=0.041 end_of_turn]
|
|
# Stdout line: [HH:MM:SS] (lang) text [rms=0.041 end_of_turn]
|
|
|
if self.stdout:
|
|
if self.stdout:
|