Repository navigation
feat(http): stream a WAV over POST /play while the robot talks #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
392a4ca
feat(http): stream WAV audio to the speaker with POST /play
Mechazawa d6c996e
feat(anim): drive animation from an X-Anim timeline during POST /play
Mechazawa 054a198
feat(anim): script the eyes from the X-Anim timeline
Mechazawa 698c89c
feat(integrations): add a play command for agent-driven animations
Mechazawa 4f31b08
docs(http): document POST /play and its X-Anim timeline
Mechazawa 4650b34
feat(integrations): add a Claude Code skill for speaking and performing
Mechazawa dac754a
Merge remote-tracking branch 'origin/main' into feat/stream-audio
Mechazawa 8611360
feat(scripts): speak in the robot's voice with word timings for /play
Mechazawa 3410452
refactor(anim): reuse shared helpers in the /play timeline and script…
Mechazawa 8cdee58
refactor(integrations): share robot fetch plumbing between anim and play
Mechazawa 40d817a
refactor(scripts): load Kokoro only when say.py synthesizes
Mechazawa 4571001
refactor(anim): run /play timelines through a Scripted mode and tickR…
Mechazawa 882595a
refactor(integrations): ship say.py inside the tiny-engineer-play skill
Mechazawa 17d9885
feat(integrations): perform a line with cues from one chordsheet string
Mechazawa 3448bd2
refactor(firmware): one eye-mode accessor and tickRobot() in its own …
Mechazawa 519659b
refactor(integrations): table-driven chordsheet checks and shared voi…
Mechazawa 3da1f8f
feat(anim): add a talking animation
Mechazawa e7d3309
refactor(http): run one named animation during POST /play
Mechazawa 2b9754b
Merge remote-tracking branch 'origin/main' into feat/stream-audio
Mechazawa 508459a
fix(http): only read the /play path argument on the named route
Mechazawa cf775e2
refactor(http): derive the /play allowlist from the animation registry
Mechazawa 68e0c0c
Merge remote-tracking branch 'origin/main' into feat/stream-audio
Mechazawa 25c5be7
feat(integrations): add a tiny-engineer-play skill for every agent pl…
Mechazawa e8f32cd
fix(integrations): harden /play inputs and resume talking after a can…
Mechazawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { robotFetch } from "./post.js"; | ||
|
|
||
| // The robot answers once the clip has finished playing. | ||
| const PLAY_TIMEOUT_MS = 10 * 60 * 1000; | ||
|
|
||
| /** | ||
| * @param {string[]} argv arguments after `play` | ||
| * @returns {{ wavPath?: string, name?: string, url?: string, error?: string }} | ||
| */ | ||
| export function parsePlayArgs(argv) { | ||
| /** @type {{ wavPath?: string, name?: string, url?: string }} */ | ||
| const opts = {}; | ||
|
|
||
| for (let i = 0; i < argv.length; i++) { | ||
| const arg = argv[i]; | ||
|
|
||
| if (arg === "--name" || arg === "--url") { | ||
| const value = argv[++i]; | ||
| if (!value || value.startsWith("-")) return { error: `${arg} requires a value` }; | ||
| opts[arg.slice(2)] = value; | ||
| continue; | ||
| } | ||
| if (arg.startsWith("-") || opts.wavPath) return { error: `Unknown argument: ${arg}` }; | ||
| opts.wavPath = arg; | ||
| } | ||
|
|
||
| if (!opts.wavPath) return { error: "play needs a WAV file" }; | ||
| return opts; | ||
| } | ||
|
|
||
| /** | ||
| * POST a WAV to /play (or /play/<name>). Resolves with the robot's reply. | ||
| * @param {{ baseUrl: string, wav: Uint8Array, name?: string, token?: string | null }} request | ||
| * @returns {Promise<{ ok: boolean, body: string }>} | ||
| */ | ||
| export async function postPlay({ baseUrl, wav, name, token }) { | ||
| const response = await robotFetch( | ||
| baseUrl, | ||
| name ? `/play/${encodeURIComponent(name)}` : "/play", | ||
| { | ||
| method: "POST", | ||
| headers: { "Content-Type": "audio/wav" }, | ||
| body: wav, | ||
| signal: AbortSignal.timeout(PLAY_TIMEOUT_MS), | ||
| }, | ||
| token, | ||
| ); | ||
|
|
||
| return { ok: response.ok, body: await response.text() }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.