Skip to content

Commit 250e61f

Browse files
authored
Merge pull request #384 from HaripriyaB/cli_text_to_speech
Text to speech through CLI Python
2 parents a242b48 + 121509e commit 250e61f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Python/Text_To_Speech_Cli/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Text to Speech using CLI - Python
2+
The aim of this program is to convert simple sentence to speech using CLI.
3+
4+
## Library used:
5+
* [gTTS text to speech](https://pypi.org/project/gTTS/) - gTTS is a module and command line utility to save spoken text to mp3. It uses the Google Text to Speech (TTS) API.
6+
7+
## pre-requisites:
8+
Install gTTS as follows(pip/pip3):
9+
10+
`>> pip3 install gTTS`
11+
12+
## Usage:
13+
`>> python cli_text_to_speech.py`
14+
15+
## I/O:
16+
```
17+
Enter a sentence in English: $(input_text)
18+
19+
Audio file saved successfully...
20+
21+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Google Text to Speech API
2+
from gtts import gTTS
3+
4+
# Input sentence from user
5+
input_text = input("Enter a sentence in English: ")
6+
7+
#converting sentence to audio
8+
tts = gTTS(text=input_text, lang='en')
9+
10+
# save the output in to an mp3 file
11+
tts.save("output_audio.mp3")
12+
13+
print("Audio file saved successfully...")

0 commit comments

Comments
 (0)