Skip to content

Added text file transcribing functionality #1531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion text-to-audio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ gtts(Google Text To Speech)
4. Call the method save() and pass the filename that you want as a parameter (line 15 in main.py)
5. Play the audio file (line 19 in main.py)

#### Transcribe a text file

1. Initialise the name of your text file ("mytextfile" line 5 in text-file-to-audio.py)
2. Initialise the variable for language ("language" line 8 in text-file-to-audio.py)
3. Read the contents of your text file and initilise the contents to a variable. ("mytext" line 12 in text-file-to-audio.py)
4. Create an instance of gTTS class ("myobj" line 16 in text-file-to-audio.py)
5. Call the method save() and pass the filename that you want as a parameter (line 19 in text-file-to-audio.py)
6. Play the audio file (line 23 in text-file-to-audio.py)

#### NOTE
If you make any changes main.py, please mention it in README.md (this file). A better documentation makes the process of development faster.

---
Author - Saumitra Jagdale
Author - Saumitra Jagdale, Vardhaman Kalloli



Expand Down
1 change: 1 addition & 0 deletions text-to-audio/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello world, this audio was created using GTTS module.
23 changes: 23 additions & 0 deletions text-to-audio/text-file-to-audio.py
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")