Skip to content
← Back to Community
A quick guide to the gTTS Library.
Profile icon
LoganSpong

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') tts.save('hello.mp3')

Step 4:

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

Voters
Profile icon
KennethAwom
Profile icon
programmeruser
Profile icon
RowanYarnell
Profile icon
Nebuchannezar
Profile icon
RiccardoGuerra
Profile icon
SpaMight
Profile icon
HarshGadiya
Profile icon
ShivankChhaya
Profile icon
RaidTheWeb
Profile icon
studentAlfredAl
Comments
hotnewtop
Profile icon
RaidTheWeb

@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

Profile icon
RaidTheWeb

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

Profile icon
LoganSpong

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

Profile icon
EthanClark2

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

Profile icon
LoganSpong

@EthanClark2 os.chdir(folder) should work.

Profile icon
ShivankChhaya

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

Profile icon
LoganSpong

@ShivankChhaya Right. It is python

Profile icon
studentAlfredAl

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

Profile icon
LoganSpong

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

Profile icon
LoganSpong

@studentAlfredAl Did it work?

Profile icon
studentAlfredAl

I did, it was good :) @LoganSpong