Use the Ruby SDK with Sambert to synthesize speech from text and save it as an MP3 file.
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.
SDK reference
| Option | Description |
|---|---|
model, url | Model ID and WebSocket endpoint. The model ID also selects the voice. |
format, sample_rate | Choose an output format and sample rate supported by the model. |
synthesize waits for the audio. To receive audio chunks, register on_audio, then call start(text) and wait_finished.
Select the voice through model. Use an audio format and sample rate supported by the model.