sdk

package module
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 6 Imported by: 1

README

Deepgram Go SDK

Discord

Official Go SDK for Deepgram. Start building with our powerful transcription & speech understanding API.

API Documentation

This SDK implementation the API documentation found at https://developers.deepgram.com.

Getting an API Key

🔑 To access the Deepgram API you will need a free Deepgram API Key.

Installation

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

Requirements

Go (version ^1.18)

Quickstarts

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.

PreRecorded Audio Transcription Quickstart

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)
}

Live Audio Transcription Quickstart

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)
}

SDK Documentation

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:

For documentation relating to Live Audio Transcription:

For documentation relating to Manage API:

Examples

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:

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.

Testing

TBD

Development and Contributing

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.

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:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples
pkg
api/analyze/v1
This package defines the Analyze API for Deepgram
This package defines the Analyze API for Deepgram
api/live/v1
This package defines the live API for Deepgram
This package defines the live API for Deepgram
api/live/v1/interfaces
This package defines interfaces for the live API
This package defines interfaces for the live API
api/manage/v1
Balances API: https://developers.deepgram.com/reference/get-all-balances https://developers.deepgram.com/reference/get-balance
Balances API: https://developers.deepgram.com/reference/get-all-balances https://developers.deepgram.com/reference/get-balance
api/manage/v1/interfaces
This package provides the types for the Deepgram Manage API.
This package provides the types for the Deepgram Manage API.
api/prerecorded/v1
This package defines the Pre-recorded API for Deepgram
This package defines the Pre-recorded API for Deepgram
api/prerecorded/v1/interfaces
This package provides the types for the Deepgram PreRecorded API.
This package provides the types for the Deepgram PreRecorded API.
api/version
This package handles the versioning in the API for prerecorded endpoint
This package handles the versioning in the API for prerecorded endpoint
audio/microphone
Implementation of a microphone using portaudio
Implementation of a microphone using portaudio
audio/microphone/interfaces
Microphone defines a interface for a Microphone implementation
Microphone defines a interface for a Microphone implementation
audio/replay
Implementation for a replay device.
Implementation for a replay device.
client/analyze
This package provides the prerecorded client implementation for the Deepgram API
This package provides the prerecorded client implementation for the Deepgram API
client/interfaces
This package contains the interface to manage the prerecorded and live/stream interfaces for the Deepgram API
This package contains the interface to manage the prerecorded and live/stream interfaces for the Deepgram API
client/live
This package provides the live/streaming client implementation for the Deepgram API
This package provides the live/streaming client implementation for the Deepgram API
client/prerecorded
This package provides the prerecorded client implementation for the Deepgram API
This package provides the prerecorded client implementation for the Deepgram API
client/rest
This package implements a reusable REST client
This package implements a reusable REST client
client/rest/debug
This package provides API debugging at the REST/HTTP level
This package provides API debugging at the REST/HTTP level
common
This package contains the initialization code for the Deepgram Go SDK
This package contains the initialization code for the Deepgram Go SDK

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL