Skip to content

Instantly share code, notes, and snippets.

@stevemar
Created September 19, 2020 19:01
Show Gist options
  • Save stevemar/f176be0c4cb7aded98998c143640d6b8 to your computer and use it in GitHub Desktop.
Save stevemar/f176be0c4cb7aded98998c143640d6b8 to your computer and use it in GitHub Desktop.
Text to speech example
from ibm_watson import TextToSpeechV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
## Text to Speech
authenticator = IAMAuthenticator('guDxxxxxxxxoZ')
text_to_speech = TextToSpeechV1(
authenticator=authenticator
)
text_to_speech.set_service_url('https://api.us-south.text-to-speech.watson.cloud.ibm.com/instances/b6fcdc7dxxxxx9715e6')
with open('hello_world.wav', 'wb') as audio_file:
audio_file.write(
text_to_speech.synthesize(
'Hack MIT is the greatest hackathon event, ever!',
voice='en-US_AllisonV3Voice',
accept='audio/wav'
).get_result().content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment