Created
September 19, 2020 19:01
-
-
Save stevemar/f176be0c4cb7aded98998c143640d6b8 to your computer and use it in GitHub Desktop.
Text to speech example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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