Skip to content

Commit a8ceb1b

Browse files
authored
Added Text to Speech project
This is text to Speech converter project using python. with utilization of ML. This project uses IBM Api keys Before running you should have to add respective crendentials in project to run the applications.
1 parent ebd2328 commit a8ceb1b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

TextToSpeech.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from ibm_watson import TextToSpeechV1
2+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
3+
4+
apikey = 'kPjbJKGTSd_eXGSckUA51-DHnteasGj6MAGhbUaPtjf0'
5+
url = 'https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/5feb4f10-875f-42b4-853c-36b5100563da'
6+
7+
8+
# Setup Service
9+
authenticator = IAMAuthenticator(apikey)
10+
# New TTS Service
11+
tts = TextToSpeechV1(authenticator=authenticator)
12+
# Set Service URL
13+
tts.set_service_url(url)
14+
15+
16+
#reading a file
17+
with open('text/ishabh.txt', 'r') as f:
18+
text = f.readlines()
19+
text = [line.replace('\n', '') for line in text]
20+
text = ''.join(str(line) for line in text)
21+
22+
with open('speech./ishabh.mp3', 'wb') as audio_file:
23+
res = tts.synthesize(text, accept='audio/mp3',
24+
voice='en-US_EmilyV3Voice').get_result()
25+
audio_file.write(res.content)

0 commit comments

Comments
 (0)