File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
articles/cognitive-services/Speech-Service/includes/how-to/speech-synthesis Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,9 @@ int main()
215
215
216
216
auto speechConfig = SpeechConfig::FromSubscription(speechKey, speechRegion);
217
217
218
+ // Required for WordBoundary event sentences.
219
+ speechConfig->SetProperty(PropertyId::SpeechServiceResponse_RequestSentenceBoundary, "true");
220
+
218
221
const auto ssml = R"(<speak version='1.0' xml:lang='en-US' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts'>
219
222
<voice name = 'en-US-JennyNeural'>
220
223
<mstts:viseme type = 'redlips_front' />
Original file line number Diff line number Diff line change @@ -388,8 +388,17 @@ func visemeReceivedHandler(event speech.SpeechSynthesisVisemeEventArgs) {
388
388
389
389
func wordBoundaryHandler (event speech .SpeechSynthesisWordBoundaryEventArgs ) {
390
390
defer event.Close ()
391
+ boundaryType := " "
392
+ switch event.BoundaryType {
393
+ case 0 :
394
+ boundaryType = " Word"
395
+ case 1 :
396
+ boundaryType = " Punctuation"
397
+ case 2 :
398
+ boundaryType = " Sentence"
399
+ }
391
400
fmt.Println (" WordBoundary event" )
392
- fmt.Printf (" \t BoundaryType %d \n " , event. BoundaryType )
401
+ fmt.Printf (" \t BoundaryType %v \n " , boundaryType )
393
402
fmt.Printf (" \t AudioOffset: %d ms\n " , (event.AudioOffset +5000 )/10000 )
394
403
fmt.Printf (" \t Duration %d \n " , event.Duration )
395
404
fmt.Printf (" \t Text %s \n " , event.Text )
@@ -414,6 +423,9 @@ func main() {
414
423
}
415
424
defer speechConfig.Close ()
416
425
426
+ // Required for WordBoundary event sentences.
427
+ speechConfig.SetProperty (common.SpeechServiceResponseRequestSentenceBoundary , " true" )
428
+
417
429
speechSynthesizer , err := speech.NewSpeechSynthesizerFromConfig (speechConfig, audioConfig)
418
430
if err != nil {
419
431
fmt.Println (" Got an error: " , err)
You can’t perform that action at this time.
0 commit comments