I want to synthesize text to speech using GCP Text-to-Speech APIs, almost every example I can find writes a new file, I would like to do this while the function is fed text and have it read over the computers speaker. I have been just trying to convert the GCP uploaded code that says hello world. I have not been able to find a way to read it right after it is converted. It seems Watson and Azure have this service but GCP does not?
client = texttospeech.TextToSpeechClient(credentials=credentials)
synthesis_input = texttospeech.types.SynthesisInput(text=string)
voice = texttospeech.types.VoiceSelectionParams(
language_code='en-US',
ssml_gender=texttospeech.enums.SsmlVoiceGender.NEUTRAL)
audio_config = texttospeech.types.AudioConfig(
audio_encoding=texttospeech.enums.AudioEncoding.MP3)
response = client.synthesize_speech(synthesis_input, voice, audio_config)
with open('output.mp3', 'wb') as out:
out.write(response.audio_content)
print('Audio content written to file "output.mp3"')
Any help would be greatly appreciated, I am guessing I am missing some documentation or a simple configuration.