Skip to main content

Sherpa TTS Node

SherpaTTS node is responsible for converting text into natural-sounding speech using advanced text-to-speech algorithms.


Configuration​

text (Optional)​

Type: String

Initial text to synthesize.


Values​

Inherits values from its parent, SingleBusAudioSourceNode.


Actions​

Inherits actions from its parent, SingleBusAudioSourceNode.

loadModel​

Loads a Sherpa model from the provided paths.

NameTypeDescription
modelPathStringPath to the sherpa model file.
tokensPathStringPath to the sherpa tokens.
dataPathStringPath to the sherpa data folder.

synthesize​

Starts rendering of text as audio.

Parameters​

NameTypeDescription
textStringThe text to synthesize.

Events​

Inherits events from its parent, SingleBusAudioSourceNode.


Example

This example generates speech audio and renders it in real-time on the device's speaker.

{
"type": "Realtime",
"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 = Switchboard::callAction("ttsNode", "synthesize", { { "text", text } });