I am writing a simple python program that gets a text file then uses IBM Watson Text To Speech to convert it to audio then play the audio directly using a module such as playsound.
most of the tutorials shows you how to save the result to a file only and not how to pass it so a module to play the audio
from ibm_watson import TextToSpeechV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
authenticator = IAMAuthenticator('{apikey}')
text_to_speech = TextToSpeechV1(
authenticator=authenticator
)
text_to_speech.set_service_url('{url}')
with open('hello_world.wav', 'wb') as audio_file:
audio_file.write(
text_to_speech.synthesize(
'Hello world',
voice='en-US_AllisonVoice',
accept='audio/wav'
).get_result().content)
that's not what i want , I want to be able to play the audio without saving it, how can i do that.