"""Voice path check without a microphone: each command is spoken by Lumi's own TTS, heard by the whisper server (the one the robot uses), and read as Lumi reads what it hears. The reading of the heard text must be the reading of the typed text. Needs the whisper server (started by the API); nothing moves. .venv/bin/python tests/voice_check.py # all mission cases, English and Korean .venv/bin/python tests/voice_check.py 50 # the first 50 only .venv/bin/python tests/voice_check.py failed # only the ones in logs/voice_check.log Units are spoken as words ("1 m" -> "1 meter"), as people say them; in Korean also the markers and numbers ("p3로" -> "피쓰리로" or "피삼으로", "1미터" -> "일 미터": the TTS reads "p3" and "1" in Korean badly); the words of a message may be spelled differently by whisper ("canceled"), only that a message is there counts. Failures go to logs/voice_check.log.""" import re import sys import time import zlib from pathlib import Path import numpy as np from assistant import steps from audio import ears, mouth from tests.steps_cases import CASES as C1 from tests.steps_cases2 import CASES as C2 from tests.steps_cases5 import CASES as C5 ROOT = Path(__file__).resolve().parents[1] M = ["home", "PInit", "Wp", "a", "b", "dock2", "exit", "final"] + [f"p{i}" for i in range(1, 11)] PROMPT = None # a whisper prompt to try instead of ears.PROMPT (VOICE_PROMPT=... in the environment) KO_EN = ["", "원", "투", "쓰리", "포", "파이브", "식스", "세븐", "에잇", "나인", "텐"] KO_SINO = ["영", "일", "이", "삼", "사", "오", "육", "칠", "팔", "구", "십"] def spoken(text): """How a person says the command: units as words; in Korean markers and numbers in Hangul, the way people say them (English or Korean digits, chosen by the text, so both are heard).""" t = re.sub(r"(\d)\s*cm\b", r"\1 centimeters", text) t = re.sub(r"(\d)\s*m\b", lambda m: m.group(1) + (" meter" if m.group(1) == "1" else " meters"), t) t = re.sub(r"(\d)\s*m(?=[가-힣\s]|$)", r"\1미터 ", t) if not re.search(r"[가-힣]", t): return t en = zlib.crc32(text.encode()) % 2 t = re.sub(r"(? 1 else None main(int(arg) if arg and arg.isdigit() else arg)