Announcements

Announcing the AssemblyAI Go SDK

We're excited to announce the release of our AssemblyAI SDK for Go!

Announcing the AssemblyAI Go SDK

In this post, you'll learn how to get started with integrating AssemblyAI into your Go applications. For a more step-by-step introduction to transcribing audio using the Go SDK, check out how to Transcribe an audio file in our docs.

Getting started

You can install the SDK directly from GitHub, using go get. The SDK supports Go modules and follows the Go module versioning strategy.

The AssemblyAI Go SDK provides a NewClient function that returns an authenticated client.

client := aai.NewClient("<YOUR_API_KEY>")

Transcribing audio files from URL

If you have an audio file available through a URL, you can transcribe it directly using the TranscribeFromURL method.

transcript, err := client.Transcripts.TranscribeFromURL(context.TODO(), audioURL, &aai.TranscriptOptionalParams{
	SpeakerLabels: aai.Bool(true),
})

You can access the transcribed text, along with other attributes from the Transcript object.

fmt.Println(*transcript.Text)

Transcribing local audio files

If you have the audio file available locally, you can transcribe it using TranscribeFromReader(). The SDK uploads the audio to AssemblyAI and deletes it once the transcription has finished.

f, err := os.Open("audio.mp3")

transcript, err := client.Transcripts.TranscribeFromReader(context.TODO(), f, &aai.TranscriptOptionalParams{
	SpeakerLabels: aai.Bool(true),
})

Using LeMUR to build LLM apps on voice data

The Go SDK also supports LeMUR, a framework for building LLM apps on voice data. You can generate text based on one or more transcripts as the context for your prompts.

res, err := client.LeMUR.Task(context.TODO(), aai.LeMURTaskParams{
	Prompt: aai.String("Provide a brief summary of the transcript."),
	LeMURBaseParams: aai.LeMURBaseParams{
		TranscriptIDs: []string{"6vx40qv20c...", "6nln9cne61...", "6nlnyw17wy..."},
	},
})

fmt.Println(*res.Response)

Improving the developer experience

We aim to provide the best Developer Experience when using our APIs, and we believe that the best way to integrate with AssemblyAI is through our many SDKs. 

While you can implement your own client libraries directly from our REST API and WebSocket API, the new Go client library also provides high-level operations for common use cases like polling and real-time transcription.

For more examples, and to learn more about the AssemblyAI SDK for Go, check out the GitHub repository.