Skip to content

Play or generate speech from text using WaveNets in Google Cloud Platform

License

Notifications You must be signed in to change notification settings

tano297/WaveNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WaveNet

Simple scripts to generate audio from text using Google Cloud and WaveNets

This code uses the Python API to access the Text-to-speech service from Google Cloud. There is a 1 million character limit in the free requests for wavenets, so use them wisely.

Step 0: Setting up:

Download and install dependencies:

$ sudo apt install python3-dev python3-pip
$ sudo pip3 install --upgrade pip
$ sudo pip3 install --upgrade google-cloud-texttospeech playsound

Step 1: Credentials

Follow this link to:

  • Generate a Google Cloud Platform profile,
  • Enable billing (won't be charged unless it's over a million requests a month)
  • Enable the speech API
  • Set up authentication
  • Download the credentials

This will result in a JSON file with your API private key, which you need to store in the "credentials" directory. Do NOT share this file with anybody, as it contains a private key. Anybody with this file can impersonate you in google cloud platform. For security, I added all JSON files to .gitignore.

Step 2: Test the system

Running the script "text-to-speech.py", will generate a single ".mp3" file that contains an example audio. If this works, your JSON file is correctly downloaded and placed in the repo.

Step 3: Generate YOUR text

By replacing the text inside the "text.txt" file, and rerunning the "text-to-speech.py" script, your text will be converted to speech through Google WaveNet magic.

The "text.txt" file will be parsed line to line, and separate ".mp3" files will be generated for each line. This allows us to move them around more easily within video editors.

The only parameter I felt necessary to change was the speed of the voice, which is modulated by the "speak_rate" parameter at the beginning of the script.

Alternative Usage:

If you instead want the computer to SAY something, instead of saving it, you can do it using the "say.py" script like this:

$ ./say.py -t "Hello, I'm a cool PhD student"

About

Play or generate speech from text using WaveNets in Google Cloud Platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages