File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,20 @@ gtts(Google Text To Speech)
14144 . Call the method save() and pass the filename that you want as a parameter (line 15 in main.py)
15155 . Play the audio file (line 19 in main.py)
1616
17+ #### Transcribe a text file
18+
19+ 1 . Initialise the name of your text file ("mytextfile" line 5 in text-file-to-audio.py)
20+ 2 . Initialise the variable for language ("language" line 8 in text-file-to-audio.py)
21+ 3 . Read the contents of your text file and initilise the contents to a variable. ("mytext" line 12 in text-file-to-audio.py)
22+ 4 . Create an instance of gTTS class ("myobj" line 16 in text-file-to-audio.py)
23+ 5 . Call the method save() and pass the filename that you want as a parameter (line 19 in text-file-to-audio.py)
24+ 6 . Play the audio file (line 23 in text-file-to-audio.py)
25+
1726#### NOTE
1827If you make any changes main.py, please mention it in README.md (this file). A better documentation makes the process of development faster.
1928
2029---
21- Author - Saumitra Jagdale
30+ Author - Saumitra Jagdale, Vardhaman Kalloli
2231
2332
2433
Original file line number Diff line number Diff line change 1+ Hello world, this audio was created using GTTS module.
Original file line number Diff line number Diff line change 1+ from gtts import gTTS
2+ import os
3+
4+ # Enter the name of your text file
5+ mytextfile = "hello.txt"
6+
7+ # Specify the language in which you want your audio
8+ language = "en"
9+
10+ # Get the contents of your file
11+ with open (mytextfile , 'r' ) as f :
12+ mytext = f .read ()
13+ f .close ()
14+
15+ # Create an instance of gTTS class
16+ myobj = gTTS (text = mytext , lang = language , slow = False )
17+
18+ # Method to create your audio file in mp3 format
19+ myobj .save ("hello.mp3" )
20+ print ("Audio Saved" )
21+
22+ # This will play your audio file
23+ os .system ("mpg321 hello.mp3" )
You can’t perform that action at this time.
0 commit comments