Skip to content

Commit 2291f62

Browse files
committed
sentence level word boundary
1 parent b182e11 commit 2291f62

File tree

2 files changed

+16
-1
lines changed
  • articles/cognitive-services/Speech-Service/includes/how-to/speech-synthesis

2 files changed

+16
-1
lines changed

articles/cognitive-services/Speech-Service/includes/how-to/speech-synthesis/cpp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ int main()
215215

216216
auto speechConfig = SpeechConfig::FromSubscription(speechKey, speechRegion);
217217

218+
// Required for WordBoundary event sentences.
219+
speechConfig->SetProperty(PropertyId::SpeechServiceResponse_RequestSentenceBoundary, "true");
220+
218221
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'>
219222
<voice name = 'en-US-JennyNeural'>
220223
<mstts:viseme type = 'redlips_front' />

articles/cognitive-services/Speech-Service/includes/how-to/speech-synthesis/go.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,17 @@ func visemeReceivedHandler(event speech.SpeechSynthesisVisemeEventArgs) {
388388

389389
func wordBoundaryHandler(event speech.SpeechSynthesisWordBoundaryEventArgs) {
390390
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+
}
391400
fmt.Println("WordBoundary event")
392-
fmt.Printf("\tBoundaryType %d\n", event.BoundaryType)
401+
fmt.Printf("\tBoundaryType %v\n", boundaryType)
393402
fmt.Printf("\tAudioOffset: %dms\n", (event.AudioOffset+5000)/10000)
394403
fmt.Printf("\tDuration %d\n", event.Duration)
395404
fmt.Printf("\tText %s\n", event.Text)
@@ -414,6 +423,9 @@ func main() {
414423
}
415424
defer speechConfig.Close()
416425

426+
// Required for WordBoundary event sentences.
427+
speechConfig.SetProperty(common.SpeechServiceResponseRequestSentenceBoundary, "true")
428+
417429
speechSynthesizer, err := speech.NewSpeechSynthesizerFromConfig(speechConfig, audioConfig)
418430
if err != nil {
419431
fmt.Println("Got an error: ", err)

0 commit comments

Comments
 (0)