Skip to main content

Text-to-Speech

This example uses the text-to-speech node from the Sherpa extension. The generated speech audio is rendered in real-time on the device's speaker.

{
"type": "RealTimeGraphRenderer",
"config": {
"graph": {
"config": {
"sampleRate": 16000,
"bufferSize": 512
},
"nodes": [
{
"id": "ttsNode",
"type": "Sherpa.SherpaTTSNode"
},
{
"id": "monoToMultiChannelNode",
"type": "MonoToMultiChannel"
}
],
"connections": [
{
"sourceNode": "ttsNode",
"destinationNode": "monoToMultiChannelNode"
},
{
"sourceNode": "monoToMultiChannelNode",
"destinationNode": "outputNode"
}
]
}
}
}

To generate speech with the TTS node, call the synthesize action and provide the desired text as a parameter.

auto result = SwitchboardV3::callAction("ttsNode", "synthesize", { { "text", text } });