diff --git a/readme.md b/readme.md index 78f4a72..fe32218 100755 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/requirements.txt b/requirements.txt index beee86c..bc6efa0 100755 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ PyYAML==3.11 requests==2.12.4 wheel==0.24.0 lxml==3.8.0 +gtts==1.1.8 \ No newline at end of file diff --git a/scripts/35_text_to_audio.py b/scripts/35_text_to_audio.py new file mode 100644 index 0000000..052889c --- /dev/null +++ b/scripts/35_text_to_audio.py @@ -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")