I try with python2.7. I installed google-cloud-texttospeech==0.2.0.
And I try with python3.7. AttributeError: module 'google.cloud.texttospeech' has no attribute 'TextToSpeechClient'. Pls help me.
This is my script
# -*- coding: utf-8 -*-"""Synthesizes speech from the input string of text or ssml.Note: ssml must be well-formed according to: https://www.w3.org/TR/speech-synthesis/"""fromgoogle.cloudimporttexttospeech# Instantiates a clientclient=texttospeech.TextToSpeechClient()
# Set the text input to be synthesizedsynthesis_input=texttospeech.types.SynthesisInput(text="Xin chào tôi là tạ minh luận")
# Build the voice request, select the language code ("en-US") and the ssml# voice gender ("neutral")voice=texttospeech.types.VoiceSelectionParams(
language_code='vi-VN',
ssml_gender=texttospeech.enums.SsmlVoiceGender.NEUTRAL)
# Select the type of audio file you want returnedaudio_config=texttospeech.types.AudioConfig(
audio_encoding=texttospeech.enums.AudioEncoding.MP3)
# Perform the text-to-speech request on the text input with the selected# voice parameters and audio file typeresponse=client.synthesize_speech(synthesis_input, voice, audio_config)
# The response's audio_content is binary.withopen('output.mp3', 'wb') asout:
# Write the response to the output file.out.write(response.audio_content)
print('Audio content written to file "output.mp3"')
I try with python2.7. I installed google-cloud-texttospeech==0.2.0.
And I try with python3.7. AttributeError: module 'google.cloud.texttospeech' has no attribute 'TextToSpeechClient'. Pls help me.
This is my script