Skip to content
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

added a script to convert text to audio file #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
1. **32_stock_scraper.py**: Get stock prices
1. **33_country_code.py**: Convert country code to country name
1. **34_git_all_repos.py**: Clone all repositories from a public user or organization on Github. Usage: `python git_all_repos.py users USER_NAME` or `python git_all_repos.py orgs ORG_NAME`
1. **35_text_to_audio.py**: Convert text to audio file using gtts module
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ PyYAML==3.11
requests==2.12.4
wheel==0.24.0
lxml==3.8.0
gtts==1.1.8
19 changes: 19 additions & 0 deletions scripts/35_text_to_audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from gtts import gTTS
import os

# Enter the text in string format which you want to convert to audio
mytext = "Hello World!, this audio is created using GTTS module."

# Specify the language in which you want your audio
language = 'en'

# 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_world.mp3")
print("Audio Saved")

# This will play your audio file
os.system("mpg321 welcome.mp3")