Skip to content

Commit

Permalink
Added text file transcribing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
seriesscar committed Jun 12, 2022
1 parent 3b15d25 commit b1c8ce1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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")

0 comments on commit b1c8ce1

Please sign in to comment.