Skip to main content

Qwen-Audio-ASR Ruby SDK

Use the Ruby SDK with Qwen-Audio-ASR to transcribe a local recording and print the recognized text.

Prerequisites

Install the Ruby SDK and configure your API key. Replace WorkspaceId with your workspace ID in Singapore and use an API key from the same region.

Quick start

Save the example as example.rb and run ruby example.rb.
require 'dashscope'

client = DashScope::Transcription::FlashFileTranscriber.new(
  url: 'https://WorkspaceId.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation'
)
request = DashScope::Transcription::FlashFileTranscriber::Request.new(
  model: 'qwen-audio-3.1-asr-flash',
  audio: 'input.wav',
  format: 'wav'
)
puts client.transcribe(request).text

SDK reference

OptionDescription
url, http_timeoutHTTPS endpoint and HTTP timeout in seconds.
model, audioModel ID and audio input in the request.
format, sample_rateAudio format and sample rate. Set the actual sample rate for raw PCM.
See the API reference for model-specific values and limits. transcribe waits for the final sentence. To read intermediate results, call transcribe_streaming and read text and sentence from each Result. Pass a file path in audio. This example uses WAV. See the model API reference for other audio formats and limits.