Port the original #27 detected-language pipeline onto the verified PR #39 prerequisite while preserving the current-main conversation instrument and host continuity changes. Keep voice selection server-side with no user selector or client voice field. Reuse 207c16ab only for its stricter exact-code trust boundary, omitting malformed or absent language so Piper defaults to Amy.
29 lines
896 B
Python
29 lines
896 B
Python
"""Pinned local-command STT envelope anchor used by image-patch tests."""
|
|
|
|
import contextlib
|
|
from pathlib import Path
|
|
|
|
|
|
class _Logger:
|
|
def info(self, *args):
|
|
return None
|
|
|
|
|
|
logger = _Logger()
|
|
|
|
|
|
def _transcribe_local_command(file_path, normalized_model, output_dir):
|
|
try:
|
|
with contextlib.nullcontext(output_dir):
|
|
txt_files = sorted(Path(output_dir).glob("*.txt"))
|
|
transcript_text = txt_files[0].read_text(encoding="utf-8").strip()
|
|
logger.info(
|
|
"Transcribed %s via local STT command (%s, %d chars)",
|
|
Path(file_path).name,
|
|
normalized_model,
|
|
len(transcript_text),
|
|
)
|
|
return {"success": True, "transcript": transcript_text, "provider": "local_command"}
|
|
except OSError as error:
|
|
return {"success": False, "transcript": "", "error": str(error)}
|