Learn to Code via Tutorials on Repl.it!

← Back to all posts
A quick guide to the gTTS Library.
LoganSpong (55)

Ok, have you ever wanted a voice in your repl?
I'm here to help. This is..

gTTS for people who don't have time!

gTTS stands for Google Text-to-Speech. It's that voice you hear in Google Translate and other Google apps and products use it as well.

Ok! I know you guys just want to see the code, so let's get on with it!

Step 1: Install the gTTS library.

from gtts import gTTS

Step 2: Declare what you want it to say.

from gtts import gTTS
tts = gTTS('Hello gTTS')

Step 3: Save that .mp3 file.

from gtts import gTTS
tts = gTTS('Hello gTTS')

Step 4:

Run the program. In your "files" sidebar, you should see something like: hello.mp3.
Play it!

RaidTheWeb (76)

@LoganSpong here is an idea for your aspiring mind, try make a python library that uses the gTTS library and the new repl.it audio library to allow actual tts. Good luck and once again good job

RaidTheWeb (76)

I fact now that I think about it maybe I might make something like that. owo

LoganSpong (55)

@RaidTheWeb Repl.it "play" function only allows .wav and .aiff files. Not .mp3 files. But good idea anyways!

EthanClark2 (0)

How do I get the file to save into a folder?

LoganSpong (55)

@EthanClark2 os.chdir(folder) should work.

ShivankChhaya (240)

Nice! What language is this in? By my guess, I have a feeling it is python because of the importing format.

studentAlfredAl (449)

You continue to amaze me! Great job and keep it up :)

LoganSpong (55)

@studentAlfredAl Thanks! Also, if you like my posts, check out My emoticon dictonary project