Skip to content

Commit

Permalink
feat(google-speech): support SSML (#12031)
Browse files Browse the repository at this point in the history
* feat(google-speech): support SSML

* change
  • Loading branch information
davidvitora committed Jul 25, 2022
1 parent 27ceaaa commit b53ddce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/google-speech/src/backend/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ export class GoogleSpeechClient {
): Promise<Uint8Array | string | undefined> {
debugTextToSpeech(`Received text to convert into audio: ${text}`)

const hasSSML = !!text.match(/<speak>.*<\/speak>/g).length

const request: ISynthesizeSpeechRequest = {
input: { text },
input: hasSSML ? { ssml: text } : { text },
voice: { languageCode: this.languageCode(language), ssmlGender: this.config.voiceSelection },
audioConfig: { audioEncoding: 'MP3' } // Always return .mp3 files since it's one of the most recognized audio file type
}
Expand Down

0 comments on commit b53ddce

Please sign in to comment.