All Text-to-Speech code samples

This page contains code samples for Text-to-Speech. To search and filter code samples for otherGoogle Cloud products, see theGoogle Cloud sample browser.

List available voices

Shows how to list the available voices.

View in documentation

Pass text to the Text-to-Speech API

Demonstrates how to pass text to the Text-to-Speech API to synthesize audio.

View in documentation

Read SSML from a text file

Read SSML from a text file.

Synthesize from a string of text

Demonstrates synthesizing from a string of text.

Synthesize plain text

Demonstrates how to pass text to the Text-to-Speech API to synthesize audio.

Synthesize SSML

Demonstrates how to use SSML with the Text-to-speech API.

View in documentation

Synthesize text with audio profiles

Synthesize text, specifying an audio profile to optimize the synthetic speech for playback on different types of hardware.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.