SDKs overview

AssemblyAI offers a suite of Software Development Kits (SDKs) and client libraries designed to facilitate interaction with its speech-to-text and audio intelligence APIs. These SDKs are available across multiple programming languages, providing idiomatic interfaces for common tasks such as submitting audio for transcription, retrieving results, and configuring advanced audio intelligence features. The primary goal of these libraries is to reduce the boilerplate code required to interact with the AssemblyAI API reference directly, allowing developers to focus on application logic.

The official SDKs support both asynchronous transcription, where audio files are processed over time and results are retrieved later, and real-time transcription, which enables live audio streams to be processed as they occur. This dual support accommodates a range of use cases, from batch processing of recorded media to interactive voice applications. Beyond basic transcription, the SDKs also provide access to AssemblyAI's Audio Intelligence features, which include capabilities such as speaker diarization, sentiment analysis, topic detection, and content moderation, enhancing the raw transcription with semantic understanding.

Official SDKs by language

AssemblyAI maintains official SDKs for several popular programming languages. These libraries are developed and supported by AssemblyAI to ensure compatibility with the latest API versions and features. Each SDK aims to provide a native developer experience within its respective language ecosystem, adhering to common conventions for package management and API interaction.

Language Package Name Install Command Example Maturity
Python assemblyai pip install assemblyai Generally Available
Node.js assemblyai npm install assemblyai Generally Available
Go github.com/AssemblyAI/assemblyai-go-sdk go get github.com/AssemblyAI/assemblyai-go-sdk Generally Available
Ruby assemblyai-ruby gem install assemblyai-ruby Generally Available
Java com.assemblyai:assemblyai-java-sdk (Maven/Gradle dependency) Generally Available
C# AssemblyAI.Client dotnet add package AssemblyAI.Client Generally Available

Installation

Installing an AssemblyAI SDK typically involves using the standard package manager for the chosen programming language. The process is designed to be straightforward, allowing developers to quickly add the library to their project dependencies. Below are common installation instructions for the officially supported languages.

Python

To install the Python SDK, use pip, the Python package installer. This command fetches the latest version of the assemblyai package from the Python Package Index (PyPI).

pip install assemblyai

Node.js

For Node.js projects, the SDK is available via npm, the Node Package Manager. Execute the following command in your project directory:

npm install assemblyai

Go

Go developers can add the AssemblyAI Go SDK to their project using the go get command. This command will download and install the package:

go get github.com/AssemblyAI/assemblyai-go-sdk

Ruby

The Ruby SDK is distributed as a RubyGems gem. Install it using the gem command:

gem install assemblyai-ruby

Java

For Java projects, the AssemblyAI SDK is typically integrated using build automation tools like Maven or Gradle. You would add the dependency to your project's pom.xml (Maven) or build.gradle (Gradle) file. For example, using Maven:

<dependency>
    <groupId>com.assemblyai</groupId>
    <artifactId>assemblyai-java-sdk</artifactId>
    <version>[LATEST_VERSION]</version>
</dependency>

Replace [LATEST_VERSION] with the current version number, which can be found in the AssemblyAI Java SDK documentation.

C#

C# developers can install the SDK using the .NET CLI's dotnet add package command:

dotnet add package AssemblyAI.Client

Quickstart example

The following Python example demonstrates how to use the AssemblyAI SDK to transcribe an audio file from a URL. This snippet illustrates the basic steps: client initialization, submitting a transcription job, and retrieving the results. Before running, ensure you have set your AssemblyAI API key as an environment variable named ASSEMBLYAI_API_KEY.

import assemblyai as aai

aai.settings.api_key = "YOUR_API_KEY" # Replace with your actual API key or set as environment variable

# You can also set the API key via environment variable: ASSEMBLYAI_API_KEY
# aai.settings.api_key = os.getenv("ASSEMBLYAI_API_KEY")

# URL of the audio file to transcribe
AUDIO_URL = "https://storage.googleapis.com/aai-web-samples/news.mp4"

# Configure transcription request with optional features
config = aai.TranscriptionConfig(
    speaker_labels=True,
    sentiment_analysis=True,
    auto_chapters=True
)

# Create a transcriber client
transcriber = aai.Transcriber()

print(f"Submitting audio for transcription: {AUDIO_URL}")

# Submit the audio file for transcription
transcript = transcriber.transcribe(AUDIO_URL, config)

# Check transcription status and print results
if transcript.status == aai.TranscriptStatus.error:
    print(f"Error: {transcript.error}")
else:
    print("Transcription successful!")
    print(f"Text: {transcript.text}")

    if transcript.chapters:
        print("\nChapters:")
        for chapter in transcript.chapters:
            print(f"- {chapter.gist} ({chapter.start}ms - {chapter.end}ms)")

    if transcript.sentiment_analysis_results:
        print("\nSentiment Analysis:")
        for result in transcript.sentiment_analysis_results:
            print(f"- {result.text}: {result.sentiment}")

    if transcript.utterances:
        print("\nSpeaker Labels (Utterances):")
        for utterance in transcript.utterances:
            print(f"- Speaker {utterance.speaker}: {utterance.text}")

This example demonstrates how to request speaker labels, sentiment analysis, and automatic chapter generation, showcasing some of the Audio Intelligence features accessible through the SDK. More detailed examples and feature guides are available in the AssemblyAI developer documentation.

Community libraries

While AssemblyAI provides official SDKs, the broader developer community may also contribute third-party libraries or wrappers. These community-driven projects can offer alternative language support, specific integrations, or different architectural approaches. Developers should exercise due diligence when using community libraries, as their maintenance, security, and compatibility with the latest AssemblyAI API versions may vary.

For example, a developer might create a Flask extension for easy integration into Python web applications, or a custom client in a language not officially supported. Such projects are often found on platforms like GitHub or through language-specific package repositories. It is advisable to consult the official AssemblyAI documentation and community forums for recommendations or discussions regarding third-party tools. Always verify the source and reputation of any unofficial library before incorporating it into production systems to ensure it meets project requirements for reliability and security, consistent with general software development best practices for dependency management.