// Performs the list voices request. resp, err := client.ListVoices(ctx, &texttospeechpb.ListVoicesRequest{}) if err != nil { return err }
for _, voice := range resp.Voices { // Display the voice's name. Example: tpc-vocoded fmt.Fprintf(w, "Name: %v\n", voice.Name)
// Display the supported language codes for this voice. Example: "en-US" for _, languageCode := range voice.LanguageCodes { fmt.Fprintf(w, " Supported language: %v\n", languageCode) }
<speak> Here are <say-asinterpret-as="characters">SSML</say-as> samples. I can pause <breaktime="3s"/>. I can play a sound <audiosrc="https://www.example.com/MY_MP3_FILE.mp3">didn't get your MP3 audio file</audio>. I can speak in cardinals. Your number is <say-asinterpret-as="cardinal">10</say-as>. Or I can speak in ordinals. You are <say-asinterpret-as="ordinal">10</say-as> in line. Or I can even speak in digits. The digits for ten are <say-asinterpret-as="characters">10</say-as>. I can also substitute phrases, like the <subalias="World Wide Web Consortium">W3C</sub>. Finally, I can speak a paragraph with two sentences. <p><s>This is sentence one.</s><s>This is sentence two.</s></p> </speak>
// Perform the text-to-speech request on the text input with the selected // voice parameters and audio file type. req := texttospeechpb.SynthesizeSpeechRequest{ // Set the text input to be synthesized. Input: &texttospeechpb.SynthesisInput{ InputSource: &texttospeechpb.SynthesisInput_Ssml{Ssml: text}, }, // Build the voice request, select the language code ("en-US") and the SSML // voice gender ("neutral"). Voice: &texttospeechpb.VoiceSelectionParams{ LanguageCode: "en-US", SsmlGender: texttospeechpb.SsmlVoiceGender_FEMALE, }, // Select the type of audio file you want returned. AudioConfig: &texttospeechpb.AudioConfig{ AudioEncoding: texttospeechpb.AudioEncoding_MP3, }, }