Welcome Turk Hack Team Members, I'm sure python is great and we can use python to make it greater.
We'll examine some of the best libraries in python today. The most important, we'll turn Texts to Speech.
espeak
The program espeak is a simple speech synthesizer which converst written text into spoken voice. The espeak program does sound a bit robotic, but its simple enough to build a basic program. It's still useful.
The codes which we will need is given below:
Using Google
We already know that Google uses a better voice. So it's way too better to use google TTS.
For this program you need the module gTTS installed as well as the program mpg123.
This will output spoken voice/an mp3 file. That's all.
Thanks for reading my article. I wish you all a great day. Take care.
We'll examine some of the best libraries in python today. The most important, we'll turn Texts to Speech.
espeak
The program espeak is a simple speech synthesizer which converst written text into spoken voice. The espeak program does sound a bit robotic, but its simple enough to build a basic program. It's still useful.
The codes which we will need is given below:
Kod:
import subprocess
def execute_unix(inputcommand):
p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
return output
a = "Say something beep boop"
# create wav file
# w = 'espeak -w temp.wav "%s" 2>>/dev/null' % a
# execute_unix(w)
# tts using espeak
c = 'espeak -ven+f3 -k5 -s150 --punct="<characters>" "%s" 2>>/dev/null' % a
execute_unix(c)
Using Google
We already know that Google uses a better voice. So it's way too better to use google TTS.
For this program you need the module gTTS installed as well as the program mpg123.
Kod:
[COLOR="PaleGreen"][I]# need gTTS and mpg123
# pip install gTTS
# apt install mpg123
from gtts import gTTS
import os
# define variables
s = "escape with plane"
file = "file.mp3"
# initialize tts, create mp3 and play
tts = gTTS(s, 'en')
tts.save(file)
os.system("mpg123 " + file)[/I][/COLOR]
This will output spoken voice/an mp3 file. That's all.
Thanks for reading my article. I wish you all a great day. Take care.