mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-02-21 15:52:07 +00:00
Merge pull request #36 from BassCoder2808/master
Added text to speech scripts
This commit is contained in:
commit
a78aa66654
9
scripts/Text_To_Speech/README.md
Normal file
9
scripts/Text_To_Speech/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Text to Speech
|
||||
This is a simple script that lets you convert text to speech and store it in .mp3 format
|
||||
|
||||
#### Usage
|
||||
|
||||
* Clone the repo
|
||||
* download the requirements
|
||||
* change the input in script.py
|
||||
* run python script.py
|
1
scripts/Text_To_Speech/requirements.txt
Normal file
1
scripts/Text_To_Speech/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
gtts
|
26
scripts/Text_To_Speech/script.py
Normal file
26
scripts/Text_To_Speech/script.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Import the required module for text
|
||||
# to speech conversion
|
||||
from gtts import gTTS
|
||||
|
||||
# This module is imported so that we can
|
||||
# play the converted audio
|
||||
import os
|
||||
|
||||
# The text that you want to convert to audio
|
||||
mytext = 'Welcome to geeksforgeeks!'
|
||||
|
||||
# Language in which you want to convert
|
||||
language = 'en'
|
||||
|
||||
# Passing the text and language to the engine,
|
||||
# here we have marked slow=False. Which tells
|
||||
# the module that the converted audio should
|
||||
# have a high speed
|
||||
myobj = gTTS(text=mytext, lang=language, slow=False)
|
||||
|
||||
# Saving the converted audio in a mp3 file named
|
||||
# welcome
|
||||
myobj.save("welcome.mp3")
|
||||
|
||||
# Playing the converted file
|
||||
os.system("mpg321 welcome.mp3")
|
BIN
scripts/Text_To_Speech/welcome.mp3
Normal file
BIN
scripts/Text_To_Speech/welcome.mp3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user