Skip to main content

Paraformer Ruby SDK for file transcription

Use the Ruby SDK with Paraformer to submit an accessible recording URL for asynchronous transcription.

Prerequisites

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

Quick start

Save the example as example.rb and run ruby example.rb '<recording URL>'.
require 'dashscope'

client = DashScope::Transcription::FileTranscriber.new(
  url: 'https://WorkspaceId.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/asr/transcription'
)
request = DashScope::Transcription::FileTranscriber::Request.new(
  model: 'paraformer-v2',
  file_urls: [ARGV.fetch(0)]
)
client.transcribe(request).each { |result| puts result.file.text }

SDK reference

OptionDescription
urlHTTPS endpoint for asynchronous file transcription.
model, file_urlsModel ID and recording URLs in the request.
poll_interval, completion_timeout, http_timeoutPolling interval, task wait limit, and HTTP timeout in seconds.
diarization_enabled, speaker_countEnable diarization or set the speaker count when supported by the model.
See the API reference for model-specific values and limits. Call transcribe once to submit the task, poll its status, and download successful results. To retain the task ID or handle failed subtasks separately, use submit, wait_completion, and download. Pass URLs the service can access in file_urls. Set poll_interval and completion_timeout to control polling and the wait limit. Download results promptly because their URLs expire.