feat: the brain can change the box's speaker volume
"Speak up" and "too loud" now work: the reply tool takes louder, in percentage points, and the button service nudges the speaker's softvol before it speaks that reply, so the person hears the change at once. The box keeps the level between 10% and 80% (body/mixer.py). No new port or key: the volume changes only with a reply, in a conversation someone is listening to. Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
cf503ac247
commit
5191ee9931
11 files changed
+146
-21
No files matched your search
+6
-4
@@ -13,7 +13,7 @@ While the brain looks through the camera (../look.js), the box taps and flashes
|
||||
One event loop, no threads. Only _script_io() imports authority (the DisciplinedPython
|
||||
recipe); main() narrows it into the parts, each of which gets only what it needs:
|
||||
button and light (gpio.py, button.py, light.py), mics (hearing.py), speaker and voice
|
||||
(voice.py), hear and brain (brain.py), status (status.py), and the look signal.
|
||||
(voice.py), the volume (mixer.py), hear and brain (brain.py), status (status.py), and the look signal.
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
@@ -27,6 +27,7 @@ from gpio import HatLines
|
||||
from hearing import ARECORD_ARGS, Mics
|
||||
from light import Light
|
||||
from look_signal import LookSignal
|
||||
from mixer import Mixer
|
||||
from status import Status, ignore, poster
|
||||
from voice import Speaker, Voice
|
||||
|
||||
@@ -46,14 +47,14 @@ def activated_socket(environ, getpid, socket):
|
||||
|
||||
async def main(argv, environ, getpid, cwd, request_lines, socket, create_subprocess_exec, open_connection,
|
||||
start_unix_server, sleep, monotonic, now):
|
||||
"""box.py APLAY ARECORD ESPEAK HEAR_CLIENT SPEAK_CLIENT SPEECH_URL ASK_CLIENT ASK_URL EARCONS STATE_DIR [STATUS_URL]
|
||||
"""box.py APLAY AMIXER ARECORD ESPEAK HEAR_CLIENT SPEAK_CLIENT SPEECH_URL ASK_CLIENT ASK_URL EARCONS STATE_DIR [STATUS_URL]
|
||||
|
||||
HEAR_CLIENT SPEECH_URL < clip prints its transcript; SPEAK_CLIENT SPEECH_URL < text prints
|
||||
a WAV of it; ASK_CLIENT ASK_URL CONVERSATION < text prints the brain's answer as JSON lines.
|
||||
EARCONS is a directory of WAVs (voice.EARCONS); STATE_DIR keeps the latest clip.
|
||||
STATUS_URL, if any, is a status page, told of each conversation and look, with a heartbeat.
|
||||
"""
|
||||
(aplay, arecord, espeak, hear_client, speak_client, speech_url, ask_client, ask_url,
|
||||
(aplay, amixer, arecord, espeak, hear_client, speak_client, speech_url, ask_client, ask_url,
|
||||
earcons, state_dir, *status_url) = argv[1:]
|
||||
command = partial(Command, create_subprocess_exec)
|
||||
loop = asyncio.get_running_loop()
|
||||
@@ -63,6 +64,7 @@ async def main(argv, environ, getpid, cwd, request_lines, socket, create_subproc
|
||||
loop.add_reader(lines.fileno(), lambda: button.feed(lines.read_edges()))
|
||||
light = Light(lines.set_led, monotonic, sleep)
|
||||
speaker = Speaker(command(aplay, "-q", "-D", "speaker"), cwd / earcons)
|
||||
mixer = Mixer(command(amixer, "-c", "voicehat"))
|
||||
mics = Mics(command(arecord, *ARECORD_ARGS), keep=(cwd / state_dir / "clip.wav").write_bytes)
|
||||
hear = Hear(command(hear_client, speech_url))
|
||||
voice = Voice(command(speak_client, speech_url), command(espeak, "--stdout"), speaker, button)
|
||||
@@ -88,7 +90,7 @@ async def main(argv, environ, getpid, cwd, request_lines, socket, create_subproc
|
||||
logging.info(f"{convo}: a conversation starts")
|
||||
note("conversation")
|
||||
await converse(convo, partial(mics.listen, button=button), hear.transcribe, brain.ask,
|
||||
voice.speak, speaker.play, light.mics, light.thinking, brain.end,
|
||||
voice.speak, speaker.play, mixer.louder, light.mics, light.thinking, brain.end,
|
||||
logging.info, note)
|
||||
button.pressed() # presses during goodbye don't start another
|
||||
for task in background:
|
||||
|
||||
Reference in new issue
Block a user