Skip to content

hmi-utwente/google-cloud-tts-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

A simple demo that uses the Google Cloud Text-To-Speech API in JavaScript. Try it out! (Tested in Firefox)

Setup

  1. Create your personal Google Could API key. Make sure billing is enabled on your account (there should be a 12-month trial with some free credits if you sign up for the first time).
  2. Optional: Add your API key to js/api-key.js to have it automatically filled in the input field. WARNING - Do not commit your API key in git! Make sure you tell git to ignore changes to this file: git update-index --skip-worktree js/api-key.js

Using the demo

  1. Clone this repo, open the index.html in a browser.
  2. Enter the API key in the web page and press the "Submit" button.
  3. Select the preferred language, gender and voice (WaveNet voices typically sound better than Standard voices).
  4. Enter some text and press the "Speak" button.
  5. You should now hear the spoken audio.

Using this code in your project

We use the REST API. There are two asynchronous functions in scripts/main.js that actually make the REST calls:

  1. retrieveAvailableVoices() -> This requests the available voices
  2. retrieveSpeechAudio(textToSpeak) -> This requests the synthesised audio for the given text and selected voice. Audio is returned as MP3 encoded as base64. There are also options for setting the pitch and speed. The API also supports SSML instead of basic text.

You are free to use code from this demo in your project according to the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published