from pathlib import Path
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
def read_text(path: str) -> str:
|
return (ROOT / path).read_text(encoding="utf-8")
|
|
|
def require(condition: bool, message: str) -> None:
|
if not condition:
|
raise SystemExit(message)
|
|
|
def main() -> None:
|
app = read_text("main/application.cc")
|
header = read_text("main/application.h")
|
mqtt = read_text("main/boards/sening-xiaozhi-s3/mqtt.h")
|
|
require(
|
"void PauseSdCardMp3ForVoice();" in header,
|
"Application must declare a helper for pausing SD card MP3 before voice interaction",
|
)
|
require(
|
"void ResumeSdCardMp3AfterVoice();" in header,
|
"Application must declare a helper for resuming SD card MP3 after voice interaction",
|
)
|
require(
|
"bool resume_sdcard_mp3_after_voice_ = false;" in header,
|
"Application must track SD card MP3 paused specifically for voice interaction",
|
)
|
require(
|
"void Application::PauseSdCardMp3ForVoice()" in app,
|
"Application must implement SD card MP3 pause before voice interaction",
|
)
|
require(
|
"PauseSdCardMp3();\n resume_sdcard_mp3_after_voice_ = true;" in app,
|
"voice pause helper must remember that playback should resume later",
|
)
|
require(
|
"void Application::ResumeSdCardMp3AfterVoice()" in app,
|
"Application must implement SD card MP3 resume after voice interaction",
|
)
|
require(
|
"ResumeSdCardMp3AfterVoice();\n display->SetStatus(Lang::Strings::STANDBY);" in app,
|
"idle state must resume SD card MP3 before returning to standby UI",
|
)
|
require(
|
"PauseSdCardMp3ForVoice();\n SetDeviceState(kDeviceStateConnecting);" in app,
|
"manual listening must pause SD card MP3 before opening the voice channel",
|
)
|
require(
|
"PauseSdCardMp3ForVoice();\n audio_service_.EncodeWakeWord();" in app,
|
"wake-word voice invoke must pause SD card MP3 before encoding/sending voice",
|
)
|
finish_tts = app.split("void Application::FinishTtsResponse()", 1)[1].split("void Application::ScheduleTtsAudio", 1)[0]
|
require(
|
"ResumeSdCardMp3AfterVoice();" in finish_tts,
|
"TTS playback completion must resume SD card MP3 paused for voice before waiting for idle",
|
)
|
require(
|
"sdcard_mp3_stop_requested_ = true;" in app and "BoardMqtt_StopPlaylistPlayback();" in app,
|
"self.mp3.stop must terminate the MQTT playlist as well as the local MP3",
|
)
|
require(
|
"sdcard_mp3_stop_requested_ = true;\n BoardMqtt_StopPlaylistPlayback();" in app,
|
"self.mp3.stop must call the playlist stop API from the MCP handler",
|
)
|
require(
|
"void BoardMqtt_StopPlaylistPlayback(void);" in mqtt,
|
"MQTT header must expose a public playlist stop API",
|
)
|
|
|
if __name__ == "__main__":
|
main()
|