Use the Ruby SDK with Qwen-LiveTranslate-Realtime to translate a Chinese recording into English and print the translation.
Prerequisites
Download dashscope-1.2.0.gem and run gem install --local ./dashscope-1.2.0.gem to install the SDK. Set the DASHSCOPE_API_KEY environment variable to an API key from Singapore.
Quick start
Save the example as example.rb and run ruby example.rb.
SDK reference
| Option | Description |
|---|---|
model, url | Translation model ID and Realtime WebSocket endpoint. |
source_language, target_language | Source and target languages. |
voice | Voice for translated audio. Choose a voice supported by the model. |
connect and use pump to read events. Wait for session.updated before sending audio with append_audio. Read completed translations in on_translation_completed. Call finish to wait for the last segment.
Use 16 kHz, 16-bit, mono raw PCM input. Choose source_language and target_language supported by the selected model.