#!/usr/bin/env bash set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" source "$HERE/lib.sh" source "${ENV_FILE:-$STATE/env}" out="$STATE/audio/talk.wav" mkdir -p "$STATE/audio" [ -s "$out" ] || python3 - "$out" <<'PY' import sys, wave, struct, math, random random.seed(7) rate, seconds = 48000, 30 w = wave.open(sys.argv[1], "wb"); w.setnchannels(1); w.setsampwidth(2); w.setframerate(rate) frames, low, phase = [], 0.0, 0.0 for i in range(rate * seconds): t = i / rate talking = (t % 2.5) < 1.5 syllable = abs(math.sin(math.pi * 4 * t)) pitch = 120 + 30 * math.sin(2 * math.pi * 0.7 * t) phase += 2 * math.pi * pitch / rate voiced = sum(math.sin(k * phase) / k for k in range(1, 12)) low += 0.2 * (random.uniform(-1, 1) - low) v = (0.6 * voiced + 0.4 * low) * syllable * (1 if talking else 0) frames.append(struct.pack("/dev/null || true; exit 0' TERM while true; do pw-play --target 0 -P '{ node.name = harness-talk }' "$out" & player=$! sleep 0.3 pw-link harness-talk:output_MONO harness-mic:input_FL || true pw-link harness-talk:output_MONO harness-mic:input_FR || true wait "$player" || true done