Community Go SDK for Deepgram. Start building with our powerful transcription & speech understanding API.
This SDK only supports hosted usage of api.deepgram.com.
- Deepgram Go SDK
- Getting an API Key
- API Documentation
- Installation
- Requirements
- Quickstarts
- SDK Documentation
- Examples
- Testing
- Development and Contributing
- Getting Help
🔑 To access the Deepgram API you will need a free Deepgram API Key.
This SDK implementation the API documentation found at https://developers.deepgram.com.
To incorporate this SDK into your project's go.mod
file, run the following command from your repo:
go get github.com/deepgram/deepgram-go-sdk
Go (version ^1.18)
This SDK aims to reduce complexity and abtract/hide some internal Deepgram details that clients shouldn't need to know about. However you can still tweak options and settings if you need.
You can find a walkthrough on our documentation site. Transcribing Pre-Recorded Audio can be done using the following sample code:
// context
ctx := context.Background()
//client
c := client.NewWithDefaults()
dg := prerecorded.New(c)
// transcription options
options := PreRecordedTranscriptionOptions{
Punctuate: true,
Diarize: true,
Language: "en-US",
}
// send URL
URL := "https://my-domain.com/files/my-conversation.mp3"
res, err := dg.FromURL(ctx, URL, options)
if err != nil {
log.Fatalf("FromURL failed. Err: %v\n", err)
}
You can find a walkthrough on our documentation site. Transcribing Live Audio can be done using the following sample code:
// options
transcriptOptions := interfaces.LiveTranscriptionOptions{
Language: "en-US",
Punctuate: true,
Encoding: "linear16",
Channels: 1,
Sample_rate: 16000,
}
// create a callback for transcription messages
// for example, you can take a look at this example project:
// https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/streaming/microphone/main.go
// create the client
dgClient, err := client.NewWithDefaults(ctx, transcriptOptions, callback)
if err != nil {
log.Println("ERROR creating LiveTranscription connection:", err)
return
}
// call connect!
wsconn := dgClient.Connect()
if wsconn == nil {
log.Println("Client.Connect failed")
os.Exit(1)
}
We are doing our best to transform the documentation to use native GoDocs which is done in code. This is ideal because:
- The documentation is extracted directly from the code in this repository
- This encourages the documentation in code to be updated and be correct
- Most importantly: This provides a single source of truth. This should be the definative source of documentation for this SDK
We encourage you to view our documentation using https://go.dev. The landing page for the SDK documentation can be found here:
HERE: Go SDK Documentation
For documentation relating to PreRecorded Audio:
- PreRecorded Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/prerecorded
- PreRecorded API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1
- PreRecorded API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1/interfaces
For documentation relating to Live Audio Transcription:
- Live Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/live
- Live API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1
- Live API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1/interfaces
For documentation relating to Manage API:
- Management Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live
- Manage API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/manage/v1
- Manage API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live/v1/interfaces
There are examples for every API call in this SDK. You can find all of these examples in the examples folder at the root of this repo.
These examples provide:
-
PreRecorded Audio Transcription:
- From an Audio File - examples/prerecorded/file
- From an URL - examples/prerecorded/url
- From an Audio Stream - examples/prerecorded/stream
-
Live Audio Transcription:
- From a Microphone - examples/streaming/microphone
- From an HTTP Endpoint - examples/streaming/http
-
Management API exercise the full CRUD operations for each API set:
- Balances - examples/manage/balances
- Invitations - examples/manage/invitations
- Keys - examples/manage/keys
- Members - examples/manage/members
- Projects - examples/manage/projects
- Scopes - examples/manage/scopes
- Usage - examples/manage/usage
To run each example set the DEEPGRAM_API_KEY
as an environment variable, then cd
into each example folder and execute the example: go run main.go
.
TBD
Interested in contributing? We ❤️ pull requests!
To make sure our community is safe for all, be sure to review and agree to our Code of Conduct. Then see the Contribution guidelines for more information.
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: