Use the Ruby SDK with Qwen-Audio-TTS to synthesize speech from text and save it as a WAV file.
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.
SDK reference
| Option | Description |
|---|---|
model, url, voice | Model ID, WebSocket endpoint, and a voice supported by the model. |
format, sample_rate | Output audio format and sample rate. |
synthesize accepts text segments and returns the complete audio. To receive audio as you send text, register on_audio and call start, send_text, and stop.
Choose a voice supported by the model. Follow the model limits for format and sample_rate. Read usage or usage_text when synthesis completes.