synthesize
Available since
v1.2.0
Signature:
Speech.synthesize(
text: str,
voice: str = "default",
speed: float = 1.0,
) -> TaskHandle[AudioData]
Description:
Asynchronously synthesize text into speech, return a TaskHandle immediately, and the actual synthesis is performed on a background thread.
Parameters:
Parameters | Type | default value | Description |
|---|---|---|---|
|
| - | Text to be synthesized, maximum 300 characters. |
|
|
| Synthesized voice ID; available voices can be obtained via list_voices (). |
|
|
| Speech synthesis speed multiplier. |
Returns:
TaskHandle[AudioData], see "Tasks and Subscriptions / TaskHandle"
Call handle. result () to wait for the synthesis to complete and obtain the audio data (AudioData, see "Sensor and Status Data / AudioData").
Raises:
ValueError: Thrown in the following cases:
voiceis not a valid voice ID- The text length exceeds the limit
RuntimeError: Speech synthesis call failed (thrown via handle. result ()).
Example:
from boosteros.brain import Speech
from boosteros.robots.booster import BoosterRobot
robot = BoosterRobot()
speech = Speech(robot)
handle = speech.synthesize("The weather is really nice today. Welcome to use the Booster bot.")
audio = handle.result()
print(f"complete: {audio.duration.seconds:.2f}s")
# Example output: complete: 3.45s
audio.save("/tmp/booster_synthesize.wav")