Skip to content

Latest commit

 

History

History
78 lines (62 loc) · 3.42 KB

README.md

File metadata and controls

78 lines (62 loc) · 3.42 KB

Google Cloud Text-To-Speech API Java examples

The Cloud Text To Speech API enables you to generate and customize synthesized speech from text or SSML.

These samples show how to list all supported voices, synthesize raw text, and synthesize a file.

Prerequisites

Download Maven

To get started, download and install it.

Setup

  • Create a project with the Google Cloud Console, and enable the TextToSpeech API.

  • Set up authentication. For example, from the Cloud Console, create a service account, download its json credentials file, then set the appropriate environment variable:

    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your-project-credentials.json
  • Build the samples

    mvn clean package
    

Quckstart

Synthesize text to an output audio file. Java Code

mvn exec:java -DQuickstart

List Voices

This sample lists all the supported voices. Java Code

mvn exec:java -DListVoices

Synthesize Text

This sample synthesizes text to an output audio file. Java Code

mvn exec:java -DSynthesizeText -Dexec.args='--text "hello"'

This sample synthesizes text with an audio profile to an output audio file. Java Code

mvn exec:java -DSynthesizeText -Dexec.args='--text "hello" "telephony-class-application"'

This sample synthesizes ssml to an output audio file. Java Code

mvn exec:java -DSynthesizeText -Dexec.args='--ssml "<speak>Hello there.</speak>"'

Synthesize File

This sample synthesizes a text file to an output audio file. Java Code

mvn exec:java -DSynthesizeFile -Dexec.args='--text resources/hello.txt'

This sample synthesizes a ssml file to an output audio file. Java Code

mvn exec:java -DSynthesizeFile -Dexec.args='--ssml resources/hello.ssml'