In this section, you will learn how to use the Jovo SpeechBuilder, a helper class that makes it easier to build speech responses and add variety to your voice app.
- Introduction to the SpeechBuilder
- Add Variety to Your Speech Output
speechBuilder, you can assemble a speech element by adding different types of input. Factory-like methods allow you to add your output subsequently.
The Jovo object (
this) consists of two pre-configured speechBuilder elements:
Alternatively, you can initialize a new speechBuilder object by using
You can see all the features below.
Here is what's currently possible with speechBuilder:
||Add plain text for text-to-speech|
||Add link to audio file and alternative text for Google Assistant. For more information on using audio files, see App Logic > Output > play.|
||Add a break to the output. Make sure to add a unit, e.g. "300ms"|
||Add a text within a sentence tag|
||Reads a number as cardinal|
||Reads a number as ordinal|
||Reads all characters of a provided string|
||Returns the content of the speechBuilder object as a string.|
You can also use speechBuilder to add variety to your speech output. Here are a few things that work:
For any of the speechBuilder methods, you can add an array of elements. The voice app will then pick a random item:
You can also add a condition as a parameter to any speechBuilder method. The output will only added if the condition is true.
Similar to conditions, you can also add probabilities to speechBuilder methods. For example, if you add
0.3, the element will only be added 3 out of 10 times.