def make_stop()

in wearable/main.py [0:0]


def make_stop(state: State) -> Callable[[], None]:
    """Returns a function with a state-closure for transcribing audio."""

    def stop() -> None:
        state.arecord.terminate()
        state.arecord.wait()
        state.dots[0] = get_rgb("black")

        with set_dot(state.dots, 1, get_rgb("green")):
            transcription = transcribe_audio(state.recording)
            logging.info(f"{transcription=}")

        with set_dot(state.dots, 2, get_rgb("blue")):
            gemini = get_gemini_response(transcription)
            logging.info(f"{gemini=}")

        with set_dot(state.dots, 1, get_rgb("green")):
            synthesis = generate_audio(gemini)
            # Prime the bluetooth device with a second a silence; to
            # avoid the bump, consider concatenating.
            subprocess.run(["paplay", "silence.wav"], check=True)
            subprocess.run(["paplay", synthesis], check=True)

    return stop