Text to Speech REST
An overview of the Deepgram JavaScript SDK and Deepgram text-to-speech.
The Deepgram JavaScript SDK now works in both server and browser environments. A proxy configuration is required for browser environments (see the section below).
Installing the SDK
Initializing the SDK
Make a Deepgram Text-to-Speech Request
Once the SDK is initialized, you can make a request to convert text into speech.
Audio Output Streaming
Deepgram’s TTS API allows you to start playing the audio as soon as the first byte is received. This section provides examples to help you stream the audio output efficiently.
Single Text Source Payload
The following example demonstrates how to stream the audio as soon as the first byte arrives for a single text source.
Chunked Text Source Payload
This example shows how to chunk the text source by sentence boundaries and stream the audio for each chunk consecutively.
Where to Find Additional Examples
The SDK repository has a good collection of text-to-speech examples. The README contains links to them. Each example below attempts to provide different options for transcribing an audio source.
Some Example(s):
- Hello World - examples/node-speak