You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Speech-Service/includes/how-to/speech-synthesis/go.md
+142Lines changed: 142 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -328,4 +328,146 @@ Next, you need to change the speech synthesis request to reference your XML file
328
328
> [!NOTE]
329
329
> To set the voice without using SSML, you can set the property on `SpeechConfig` by using `speechConfig.SetSpeechSynthesisVoiceName("en-US-JennyNeural")`.
330
330
331
+
## Subscribe to synthesizer events
331
332
333
+
You might want more insights about the text-to-speech processing and results. For example, you might want to know when the synthesizer starts and stops, or you might want to know about other events encountered during synthesis.
334
+
335
+
While using the [SpeechSynthesizer](https://pkg.go.dev/github.com/Microsoft/cognitive-services-speech-sdk-go/speech#SpeechSynthesizer) for text-to-speech, you can subscribe to the events in this table:
336
+
337
+
[!INCLUDE [Event types](events.md)]
338
+
339
+
Here's an example that shows how to subscribe to events for speech synthesis. You can follow the instructions in the [quickstart](../../../get-started-text-to-speech.md?pivots=go), but replace the contents of that `speech-synthesis.go` file with the following Go code.
The rainbow has seven colors: <bookmark mark='colors_list_begin'/>Red, orange, yellow, green, blue, indigo, and violet.<bookmark mark='colors_list_end'/>.
438
+
</voice>
439
+
</speak>`, speechSynthesisVoiceName)
440
+
441
+
// Synthesize the SSML
442
+
fmt.Printf("SSML to synthesize: \n\t%s\n", ssml)
443
+
task:= speechSynthesizer.SpeakSsmlAsync(ssml)
444
+
445
+
varoutcome speech.SpeechSynthesisOutcome
446
+
select {
447
+
case outcome = <-task:
448
+
case<-time.After(60 * time.Second):
449
+
fmt.Println("Timed out")
450
+
return
451
+
}
452
+
defer outcome.Close()
453
+
if outcome.Error != nil {
454
+
fmt.Println("Got an error: ", outcome.Error)
455
+
return
456
+
}
457
+
458
+
if outcome.Result.Reason == common.SynthesizingAudioCompleted {
0 commit comments