Announcement

Introducing the AssemblyAI Ruby SDK

We are thrilled to release the AssemblyAI Ruby SDK. You can use the SDK to transcribe audio, use our audio intelligence model, and apply LLMs to your audio data using LeMUR.

Ruby code to transcribe an audio file using the Ruby SDK

We are thrilled to release the AssemblyAI Ruby SDK, making it easier to use the latest Speech AI models from AssemblyAI with Ruby. Use the SDK to transcribe audio, analyze audio using our audio intelligence models, and apply LLMs to your audio data using LeMUR.

Here are a couple of examples showcasing the Ruby SDK.

1. Transcribe an audio file

require 'assemblyai'

client = AssemblyAI::Client.new(api_key: 'YOUR_API_KEY')

transcript = client.transcripts.transcribe(
  audio_url: 'https://storage.googleapis.com/aai-docs-samples/nbc.mp3'
)

abort transcript.error if transcript.status == AssemblyAI::Transcripts::TranscriptStatus::ERROR

puts transcript.text

You can also transcribe a local file, as shown here.

uploaded_file = client.files.upload(file: '/path/to/your/file')
transcript = client.transcripts.transcribe(
  audio_url: uploaded_file.upload_url
)

Learn how to transcribe audio files by following the step-by-step instructions in our docs.

2. Use LeMUR to build LLM apps on voice data

response = client.lemur.task(
  transcript_ids: [transcript.id],
  prompt: 'Summarize this transcript.'
)

puts response.response

Learn how to use LLMs with audio data using LeMUR in our docs.

3. Use audio intelligence models

transcript = client.transcripts.transcribe(
  audio_url: 'https://storage.googleapis.com/aai-docs-samples/nbc.mp3',
  sentiment_analysis: true
)

abort transcript.error if transcript.status == AssemblyAI::Transcripts::TranscriptStatus::ERROR

transcript.sentiment_analysis_results.each do |result|
  puts result.text
  puts result.sentiment
  puts result.confidence
  printf("%<start>d - %<end>d\n", start: result.start, end: result.end_)
end

Learn more about our audio intelligence models in our docs.

Get started with the Ruby SDK

You can find installation instructions and more information in the README of the Ruby SDK GitHub repository. File an issue or contact us with any feedback.