Go Live Text-to-Speech Starter
This example app demonstrates how to use the Deepgram Text-to-Speech API over WebSockets with Go.
The flow of this sample is:
- A websocket is opened from the UI to the backend Go component
- Text is sent over a websocket to the backend component
- If a connection has not been established to Deepgram, create a websocket connection using the Python SDK and send the text to convert to audio
- An audio byte response with synthesized text-to-speech is returned and forward back through the WebSocket created by the UI
- Those audio bytes are then played by the media device contained within your browser
What is Deepgram?
Deepgram’s (opens in new tab) voice AI platform provides APIs for speech-to-text, text-to-speech, and full speech-to-speech voice agents. Over 200,000+ developers use Deepgram to build voice AI products and features.
Sign-up to Deepgram
Before you start, it's essential to generate a Deepgram API key to use in this project. Sign-up now for Deepgram and create an API key (opens in new tab).
Quickstart
Manual
Follow these steps to get started with this starter application.
Clone the repository
Go to GitHub and clone the repository (opens in new tab).
Install dependencies
Install the project dependencies.
go mod tidy
Set your Deepgram API key
If using bash, this can be done in your ~/.bash_profile like so:
export DEEPGRAM_API_KEY="YOUR_DEEPGRAM_API_KEY"
Run the Go Application
If you have set your DEEPGRAM_API_KEY environment variable, start the Backend go application using this command:
go run main.go
If you haven't, this could also be done by a simple export before executing your Go application:
DEEPGRAM_API_KEY="YOUR_DEEPGRAM_API_KEY" go run main.go
Open the UI in a Browser
To open the Frontend UI, just navigate to http://localhost:3000.
Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Security Policy (opens in new tab) details the procedure for contacting Deepgram.
Getting Help
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue in this repository (opens in new tab)
- Join the Deepgram Github Discussions Community (opens in new tab)
- Join the Deepgram Discord Community (opens in new tab)
Author
License
This project is licensed under the MIT license. See the LICENSE (opens in new tab) file for more info.