Generate a spoken line and add it as a sound
add_speechConvert text to speech offline, attach it to a Scratch sprite as a sound, and get duration plus mouth-loop count to time talking animation.
Instructions
Synthesizes speech with the machine's offline text-to-speech engine and attaches it to a sprite as a Scratch sound — no network, no file needed. Returns the sound's duration and a ready-made mouth-loop repeat count, so the talking animation can be timed to the audio. Use {"play_sound": name} (not play_sound_until_done) before the mouth loop so the animation runs while the audio plays.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Sound name used by play_sound. Defaults to a slug of the text | |
| rate | No | Speed multiplier, 0.5 (slow) to 2.0 (fast), default 1 | |
| text | Yes | The line to speak. Split long speeches into one call per line | |
| voice | No | "male", "female", or part of a voice name such as "george". Call list_voices to see what exists | |
| target | Yes | The sprite that speaks. Put the sound on the speaking sprite, not the Stage | |
| volume | No | 0 to 100, default 100 | |
| trim_silence | No | Trim dead air at both ends, default true |