Repository navigation
Release v0.122.0: spoken replies on a call are shaped for the phone band - #146
Merged
Merged
Conversation
switchboard-tts runs the handset announcements' mastering (announce_asterisk, v0.121.0) on espeak-ng's output: one ffmpeg process to the band and 8 kHz, then the speech level set to the built-in prompts' -15 dBFS under a -1 dBFS limiter. ffmpeg gets 3 s per reply (the callers allow the whole synthesis 20 s and espeak alone 15); a run past it pauses the mastering for 10 minutes across processes (a file's mtime in /tmp). Any failure speaks the reply exactly as before, byte for byte, with one Log tab line per start that the three callers now pass on after a successful reply too. announce_asterisk gains an optional per-call timeout; announcements keep their 10 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e order, tests - The callers no longer capture switchboard-tts's stderr: it is theirs, the add-on journal, so the once-per-start note lands even when a hangup ends the AGI first (Asterisk SIGHUPs the AGI's own pid). Their stdout, the AGI channel, goes to /dev/null. The forwarding added in the previous commit is gone, and agi_speech's callers now show switchboard-tts's lines too. - _pause opens with O_NONBLOCK and moves the mtime of a regular file only, so a FIFO at the pause file cannot block a reply. - Native byte order throughout (wave already swaps); ffmpeg gets an s16le copy. - Tests: a mastered reply is checked without a real ffmpeg, a second timeout restarts the pause, the link check uses a fresh target, a FIFO, the real import through MASTER_DIR, an error in switchboard-tts's own part, the callers' subprocess arguments, and the note landing after the caller is gone. - Docs: how-its-built dates the shaping per path; the example log line has no caller prefix; CHANGELOG says where switchboard-tts's lines now appear. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…paths, how-its-built - The test helpers build and compare native-order PCM, as wave reads and writes it, and feed _master_speech the s16le copy switchboard-tts makes. - The MASTER_DIR import test points PAUSE_FILE and NOTED_FILE at tmp_path, so it never reads or writes the machine's own /tmp markers. - how-its-built: recognition and the spoken replies run as the asterisk user; handset announcements are rendered by the web UI, which runs as root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeQL py/overly-permissive-file. Nothing reads either file's contents: the pause is the file's mtime (lstat), the note marker only has to exist, and both are made and checked by the same user (the AGIs' uid 100). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spoken replies on a call are shaped for the phone band
Everything the voice features say that has no recording goes through
switchboard-tts(espeak-ng): the directory (411), the lights menu (43), dial-a-status (45), the announce line (46), the wake-up weather and calendar, and the voice assistant (47). Since 0.121.0 the handset announcements are mastered for the 300–3400 Hz band every phone here hears (all G.711 µ-law, wired and SIP). This release runs the same code on the spoken replies.What changed
switchboard-ttspasses espeak-ng's mono 16-bit output toannounce_asterisk._master_speech, loaded from the web UI's directory so the two cannot drift apart. That is one ffmpeg process (band shaping and the resampler to 8 kHz), then the gain to -15 dBFS and the -1 dBFS limiter._resample_unmastered./tmpfile opened withO_NOFOLLOW|O_NONBLOCK; only a regular file's mtime is moved. A link, a FIFO, a non-regular file, or a stamp dated in the future counts as no pause, and none of them can block a reply./tmpmarker withO_CREAT|O_EXCL|O_NOFOLLOW, then writes its line. Each add-on start is a new container with an empty/tmp. If the marker cannot be created, every fallback logs.agi_speech.say,switchboard-assistant.agi,switchboard-automation.agi) no longer captureswitchboard-tts's stderr. It inherits theirs, which is Asterisk's stderr, the add-on journal, soswitchboard-ttswrites its lines there itself./dev/null, because the AGI's stdout is the command channel and Asterisk ends an AGI at its EOF.switchboard-tts's lines, now show them.switchboard-ttsnever writes the text to stderr, and an existing privacy test pins that.announce_asteriskgains an optional per-calltimeout(defaultNone, which meansMASTER_TIMEOUT_S, so announcements keep 10 s) and a_TIMED_OUTconstant.Review
Two review rounds, each with an adversarial verifier per lens.
Checked in the target environment before merge
The live add-on, running as uid 100 (the AGIs' user) under its AppArmor profile, with Python 3.12.16 (
audioop) and ffmpeg 6.1.2. The new code was copied into a private test folder:switchboard-ttswrites anything: the line still lands in that caller's stderr.Tests
tests/test_tts_mastering.py, 23 tests:_master_speech's;MASTER_DIR;subprocess.runarguments (stdout to/dev/null, stderr not captured);A mutation check with ffmpeg hidden from
PATHand a green baseline killed all 15 mutants. They covered dropped mastered audio, a lost pause update, a followed link, a wrongMASTER_DIR, a missingsys.pathinsert, a narrowed guard, a missingO_NONBLOCKorO_EXCL, the 10 s limit, text in stderr, callers capturing stderr or inheriting stdout, and the announcements' default limit.Full suite: 1564 passed, 30 skipped.
Docs
## 0.122.0, with 0.113.0 rotated into the archive.🤖 Generated with Claude Code