File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ ## Text To Audio
2+
3+ ### We are using gtts module for conversion
4+
5+ Requirements: pip install gtts
6+
7+ #### Flow
8+
9+ gtts(Google Text To Speech)
10+
11+ 1 . Initialise the variable for your text ("mytext" line 6 in main.py)
12+ 2 . Initialise the variable for language ("language" line 9 in main.py)
13+ 3 . Create an instance of gTTS class ("myobj" line 12 in main.py)
14+ 4 . Call the method save() and pass the filename that you want as a parameter (line 15 in main.py)
15+ 5 . Play the audio file (line 19 in main.py)
16+
17+ #### NOTE
18+ If you make any changes main.py, please mention it in README.md (this file). A better documentation makes the process of development faster.
19+
20+ ---
21+ Author - Saumitra Jagdale
22+
23+
24+
25+
26+
Original file line number Diff line number Diff line change 1+
2+ from gtts import gTTS
3+ import os
4+
5+ # Enter the text in string format which you want to convert to audio
6+ mytext = "Hello World!, this audio is created using GTTS module."
7+
8+ # Specify the language in which you want your audio
9+ language = 'en'
10+
11+ # Create an instance of gTTS class
12+ myobj = gTTS (text = mytext , lang = language , slow = False )
13+
14+ # Method to create your audio file in mp3 format
15+ myobj .save ("hello_world.mp3" )
16+ print ("Audio Saved" )
17+
18+ # This will play your audio file
19+ os .system ("mpg321 welcome.mp3" )
You can’t perform that action at this time.
0 commit comments