python-sdk
python-sdk copied to clipboard
TÜRKISCH
from ibm_watson import TextToSpeechV1 from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
API-Schlüssel und URL
api_key = 'YpLeRYV8e7P5sagmcze3MMby1cNHwrTp7_-erVFGk57E' url = 'https://api.eu-de.text-to-speech.watson.cloud.ibm.com/instances/8c338054-1e65-458f-b0fc-907823ccf233'
Authentifizierung
authenticator = IAMAuthenticator(api_key) text_to_speech = TextToSpeechV1( authenticator=authenticator ) text_to_speech.set_service_url(url)
Text, der in Sprache umgewandelt werden soll
text = "Kalbinde memleketi taşıyanlarla Kupa yolunda çeyrek finaldeyiz. EESIA bizim çocuklara başarılar diler."
Text in Sprache umwandeln (männliche türkische Stimme)
response = text_to_speech.synthesize( text, voice='tr-TR_EmirV3Voice', # Beispiel für eine männliche türkische Stimme accept='audio/mp3' ).get_result()
Speichern der Audiodatei
with open('output.mp3', 'wb') as audio_file: audio_file.write(response.content)