forge
Explore
Log in

Don't you dare go Hollow

yumush

Clone
★ 0

0 watching0 forksRustAGPL-3.06.8 MiB27ceb05Tahinli7 hours ago399 commits

talk.sh32 lines, 1.2 KiBHistoryRawDownload
1#!/usr/bin/env bash
2set -euo pipefail
3STATE="${HARNESS_STATE:-/tmp/claude-1000/yumush-harness}"
4source "${ENV_FILE:-$STATE/env}"
5out="$STATE/audio/talk.wav"
6mkdir -p "$STATE/audio"
7[ -s "$out" ] || python3 - "$out" <<'PY'
8import sys, wave, struct, math, random
9random.seed(7)
10rate, seconds = 48000, 30
11w = wave.open(sys.argv[1], "wb"); w.setnchannels(1); w.setsampwidth(2); w.setframerate(rate)
12frames, low, phase = [], 0.0, 0.0
13for i in range(rate * seconds):
14 t = i / rate
15 talking = (t % 2.5) < 1.5
16 syllable = abs(math.sin(math.pi * 4 * t))
17 pitch = 120 + 30 * math.sin(2 * math.pi * 0.7 * t)
18 phase += 2 * math.pi * pitch / rate
19 voiced = sum(math.sin(k * phase) / k for k in range(1, 12))
20 low += 0.2 * (random.uniform(-1, 1) - low)
21 v = (0.6 * voiced + 0.4 * low) * syllable * (1 if talking else 0)
22 frames.append(struct.pack("<h", int(max(-1, min(1, 0.35 * v)) * 32767)))
23w.writeframes(b"".join(frames))
24PY
25while true; do
26 pw-play --target 0 -P '{ node.name = harness-talk }' "$out" &
27 player=$!
28 sleep 0.3
29 pw-link harness-talk:output_MONO harness-mic:input_FL || true
30 pw-link harness-talk:output_MONO harness-mic:input_FR || true
31 wait "$player" || true
32done