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)}
|