Skip to content

Commit fdb275e

Browse files
SSML Emotion mixing update (#185)
* SSML Emotion mixing update * fix voice name
1 parent 44a21e8 commit fdb275e

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed
539 KB
Binary file not shown.

tts-basics-customize-ssml.ipynb

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,18 @@
278278
"- `volume=\"x-loud\"`\n",
279279
"- `volume=\"default\"`\n",
280280
"\n",
281+
"#### Emotion Attribute\n",
281282
"\n",
282-
"Let’s look at an example showing the pitch, rate, and volume customizations for Riva TTS:"
283+
"Riva supports emotion mixing in beta with the emotion attribute as described in the SSML specs. The emotion attribute overwrites the default subvoice emotion in the request and supports mixing weight in floating range of [0.0, 1.0]. Mixing weight tags `xlow`, `low`, `medium`, `very` and `extreme` are supported. Currently emotion mixing is only supported in RadTTS++ model.\n",
284+
"\n",
285+
"When an emotion is selected it is mixed in with neutral according to the specified weight to quantize it. For example, happy with a mixing weight of 0.5 is happy extreme mixed in with neutral in 1:1 ratio to get happy:0.5.\n",
286+
"\n",
287+
"The emotion attribute is expressed in the following formats:\n",
288+
"\n",
289+
"- `emotion=\"sad:1.0,fearful:0.7\"`\n",
290+
"- `emotion=\"happy:extreme,calm:low\"`\n",
291+
"\n",
292+
"Let’s look at an example showing the pitch, rate and volume customizations for Riva TTS:"
283293
]
284294
},
285295
{
@@ -329,7 +339,7 @@
329339
"cell_type": "markdown",
330340
"metadata": {},
331341
"source": [
332-
"Here are more examples showing the effects of changes in pitch and rate attribute values on the generated audio:"
342+
"Here are more examples showing the effects of changes in pitch, rate and emotion attribute values on the generated audio:"
333343
]
334344
},
335345
{
@@ -392,6 +402,45 @@
392402
"<audio controls src=\"https://raw.githubusercontent.com/nvidia-riva/tutorials/stable/audio_samples/tts_samples/ssml_sample_8.wav\" type=\"audio/ogg\"></audio>\n"
393403
]
394404
},
405+
{
406+
"cell_type": "code",
407+
"execution_count": null,
408+
"metadata": {},
409+
"outputs": [],
410+
"source": [
411+
"# Note: This code segment uses the beta radtts model which supports emotion mixing, in case of other models the emotions will be ignored except set via voice_name.\n",
412+
"\n",
413+
"req_emotion = { \n",
414+
" \"language_code\" : \"en-US\",\n",
415+
" \"encoding\" : riva.client.AudioEncoding.LINEAR_PCM , # LINEAR_PCM and OGGOPUS encodings are supported\n",
416+
" \"sample_rate_hz\" : sample_rate_hz, # Generate 44.1KHz audio\n",
417+
" \"voice_name\" : \"English-US-RadTTSpp.Male.happy\" # The name of the voice to generate\n",
418+
"}\n",
419+
"\n",
420+
"ssml_text=\"\"\"<speak> I am happy.<prosody emotion=\"sad:very\"> And now, I am sad.</prosody><prosody emotion=\"angry:extreme\"> This makes me angry.</prosody><prosody emotion=\"calm:extreme\"> And now, I am calm.</prosody></speak>\"\"\"\n",
421+
"print(\"SSML Text: \", ssml_text)\n",
422+
"\n",
423+
"\n",
424+
"req_emotion[\"text\"] = ssml_text\n",
425+
"# Request to Riva TTS to synthesize audio\n",
426+
"resp = riva_tts.synthesize(**req_emotion)\n",
427+
"\n",
428+
"# Playing the generated audio from Riva TTS request\n",
429+
"audio_samples = np.frombuffer(resp.audio, dtype=np.int16)\n",
430+
"ipd.display(ipd.Audio(audio_samples, rate=sample_rate_hz))\n"
431+
]
432+
},
433+
{
434+
"cell_type": "markdown",
435+
"metadata": {},
436+
"source": [
437+
"#### Expected results if you run the tutorial:\n",
438+
"\n",
439+
"`I am happy.<prosody emotion=\"sad:very\"> And now, I am sad.</prosody><prosody emotion=\"angry:extreme\"> This makes me angry.</prosody><prosody emotion=\"calm:extreme\"> And now, I am calm.</prosody>`\n",
440+
"\n",
441+
"<audio controls src=\"https://raw.githubusercontent.com/nvidia-riva/tutorials/stable/audio_samples/tts_samples/ssml_sample_15.wav\" type=\"audio/ogg\"></audio> "
442+
]
443+
},
395444
{
396445
"cell_type": "markdown",
397446
"metadata": {},

0 commit comments

Comments
 (0)