By Kazuaki Suzuki

2019-01-13 06:02:45 8 Comments

I'm a beginner in coding. I am using the Google Cloud Text to Speech API for Python on a small program I'm using. The function is working and I get the synthesized voice results, but the MP3 file is different from what I need. I chose 'en-GB-Wavenet-C'(British accent female voice) as language_code, but the MP3 file sounds American accent male voice.

I visited Cloud Text to Speech API website( and tried "Speak it" demo. I tried 'en-GB-Wavenet-C' and it sounded British accent female voice.

I would like to know the appropriate code so that I get 'en-GB-Wavenet-C' voice result.

I use Debian 9.3 from Windows Subsystem for Linux.

I use Google Cloud SDK 210.0.0.

Thank you in advance.

Sincerely, Kazu

This is my code:

#!/usr/bin/env python

from import texttospeech
client = texttospeech.TextToSpeechClient()

with open('resources/hello.ssml', 'r') as f:
    ssml =
    input_text = texttospeech.types.SynthesisInput(ssml=ssml)

# Note: the voice can also be specified by name.
# Names of voices can be retrieved with client.list_voices().
voice = texttospeech.types.VoiceSelectionParams(language_code='en-GB-Wavenet-C')

audio_config = texttospeech.types.AudioConfig(

response = client.synthesize_speech(input_text, voice, audio_config)

# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
    print('Audio content written to file "output.mp3"')
# [END tts_synthesize_ssml_file]


@Nikolay Shmyrev 2019-01-13 12:20:20

 voice = texttospeech.types.VoiceSelectionParams(language_code='en-GB-Wavenet-C')

Should be

 voice = texttospeech.types.VoiceSelectionParams(language_code='en-GB', name="en-GB-Wavenet-C")

@Kazuaki Suzuki 2019-01-13 22:33:43

Thank you very much for your quick help. I tried your suggestion. However it didn't solve my problem. This Error message appeared.

@Kazuaki Suzuki 2019-01-13 22:36:34

Traceback (most recent call last): File "", line 17, in <module> response = client.synthesize_speech(input_text, voice, audio_config) File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/go‌​ogle/cloud/texttospe‌​ech_v1/gapic/text_to‌​", line 257, in synthesize_speech request, retry=retry, timeout=timeout, metadata=metadata) File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/go‌​ogle/api_core/gapic_‌​v1/", line 143, in call return wrapped_func(*args, **kwargs)

@Kazuaki Suzuki 2019-01-13 22:37:12

File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/go‌​ogle/api_core/retry.‌​py", line 270, in retry_wrapped_func on_error=on_error, File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/go‌​ogle/api_core/retry.‌​py", line 179, in retry_target return target() File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/go‌​ogle/api_core/timeou‌​", line 214, in func_with_timeout return func(*args, **kwargs)

@Kazuaki Suzuki 2019-01-13 22:37:34

File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/go‌​ogle/api_core/grpc_h‌​", line 59, in error_remapped_callable six.raise_from(exceptions.from_grpc_error(exc), exc) File "/mnt/c/gcp/voice/.venv/local/lib/python2.7/site-packages/si‌​", line 737, in raise_from raise value google.api_core.exceptions.InvalidArgument: 400 Could not find TTS server to handle request for application_id: 'cloud-tts' and trigger_application_id: '' and voice_request: language: "en-gb" name: "cloud-Wavenet-C"

@Kazuaki Suzuki 2019-01-13 22:38:28

Cloud you please help me?

@Nikolay Shmyrev 2019-01-14 09:37:24

Try name="en-GB-Wavenet-C"

@Kazuaki Suzuki 2019-01-15 10:40:45

I got it! The answer is [language_code='en-GB', name="en-GB-Wavenet-C"]. Thank you very much for your help!!!

Related Questions

Sponsored Content

3 Answered Questions

1 Answered Questions

How I can take to human accent (Wavenet or Ssml voices)?

1 Answered Questions

[SOLVED] Google Cloud Text-to-speech word timestamps

1 Answered Questions

Google Cloud Text-to-Speech WaveNet API Character conversion rate

14 Answered Questions

[SOLVED] Google Text-To-Speech API

1 Answered Questions

Text to Speech Conversion for web application

Sponsored Content