forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added text file transcribing functionality
- Loading branch information
1 parent
3b15d25
commit b1c8ce1
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello world, this audio was created using GTTS module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from gtts import gTTS | ||
import os | ||
|
||
# Enter the name of your text file | ||
mytextfile = "hello.txt" | ||
|
||
# Specify the language in which you want your audio | ||
language = "en" | ||
|
||
# Get the contents of your file | ||
with open(mytextfile, 'r') as f: | ||
mytext = f.read() | ||
f.close() | ||
|
||
# Create an instance of gTTS class | ||
myobj = gTTS(text=mytext, lang=language, slow=False) | ||
|
||
# Method to create your audio file in mp3 format | ||
myobj.save("hello.mp3") | ||
print("Audio Saved") | ||
|
||
# This will play your audio file | ||
os.system("mpg321 hello.mp3") |