AI agents · Recipes
Sequence story calls
The order of the story tools, the add_lines stacking trap, reworking lines, mixing and the open studio.
The order an agent calls the story tools in, and the traps between them. A story is a persistent script: each line has a lane, a start time and, once read, a sound. For a complete worked example, see Voice a scene. Arguments and results are in Voice and story tools.
Before you begin
- The agent is connected over Streamable HTTP. The stdio bridge has no story tools.
- At least one text-to-speech model is installed:
list_modelsshows one withtask: "tts".
Build and read a story
Call
soundbox.list_voicesand choose a voiceidfor each speaker.Call
soundbox.list_modelsand read thedeliverylist of each voice'smodel_id.Call
soundbox.create_storywith atitle, and a story-widedeliveryif the script needs one.The result carries
story_idandopen_in_studio.Call
soundbox.add_linesonce with every line in order.In a new story, the lines are laid end to end on their lanes as they are read.
Call
soundbox.speak_storywith thestory_idand nomodel.Each line is read on its own voice's model. The call blocks until every silent line is read, one at a time.
Call
soundbox.get_storyand check that every spoken line hasvoiced: true. Pauses have no audio and stayvoiced: false.Give the user the
open_in_studiolink.
Add lines to a story that already has audio
A spoken line has no length until it is read, so add_lines cannot place a line after another unread line.
Warning
Lines appended together to a lane that already has audio all get the same start_s: the end of the lane's last
voiced clip. After speak_story they play on top of each other.
To avoid it, do one of these:
- Give each new line its own
start_sin theadd_linescall. - After
speak_story, callsoundbox.get_story, read each new line'sduration_s, and move the lines apart withsoundbox.update_lineandstart_s.
Change a line
Call
soundbox.update_linewith the newtext,voice_idordelivery.The old audio stays until the line is read again.
Call
soundbox.speak_storywith thestory_id.Only lines without audio are read. Pass
regenerate: trueonly to read every line again.
To shorten a clip without losing audio, set duration_s or trim_start_s with update_line. To cut a read line into
two clips, call soundbox.split_line; the words stay with the first clip.
Mix and export
- Call
soundbox.get_storyto see each lane and its clips. - Call
soundbox.mix_trackto name, mute, solo or set the gain of a lane. - Call
soundbox.add_deviceto put an effect on a lane, thensoundbox.set_devicewith the returneddeviceid to change it. - Optional: call
soundbox.export_storyfor one mixed file.
export_story renders each lane's devices into the mixdown, the same as the studio's playback. Bypassed devices are left
out.
Edit the studio the user has open
- Call
soundbox.studio_context, and use only the lane numbers, clip ids and voice ids it returns. - Call
soundbox.studio_applywith the actions and a shortsummaryin the user's words. The actions are in the studio action vocabulary. - If the result's
held_deletesis more than 0, ask the user, then send the same deletes withallow_delete: true. - If you sent
generate_cliporspeak_lines, callsoundbox.studio_contextagain after a few seconds to see the clips fill in.
What's next
- Voice a scene: every call for a two-character scene.
- Troubleshoot agent calls: errors and what to do about them.