Audio
Overview
Section titled “Overview”Available Operations
Section titled “Available Operations”- speech - Text to speech
- transcribe - Speech to text
- translate - Speech translation
speech
Section titled “speech”Convert text to speech
Example Usage
Section titled “Example Usage”from r9s import R9S
with R9S(api_key=os.getenv("R9S_API_KEY",""),) as r9_s: res = r9_s.audio.speech( model="speech-2.6-turbo", input="Hello, welcome to our service!", voice="alloy", response_format="mp3", speed=1)
# Handle response print(res)Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
model | str | :heavy_check_mark: | TTS model name |
input | str | :heavy_check_mark: | Text to convert to speech |
voice | string (alloy, echo, fable, onyx, nova, shimmer) | :heavy_check_mark: | Voice type |
response_format | string (mp3, opus, aac, flac, wav, pcm) | :heavy_minus_sign: | N/A |
speed | float | :heavy_minus_sign: | Speech speed |
retries | object | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
Section titled “Response”CreateAudioSpeechResponse
Errors
Section titled “Errors”| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.AuthenticationError | 401 | application/json |
| errors.PermissionDeniedError | 403 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.RateLimitError | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.ServiceUnavailableError | 503 | application/json |
| errors.R9SDefaultError | 4XX, 5XX | */* |
transcribe
Section titled “transcribe”Transcribe speech to text
Example Usage
Section titled “Example Usage”from r9s import R9S
with R9S(api_key=os.getenv("R9S_API_KEY",""),) as r9_s:
res = r9_s.audio.transcribe(file={ "file_name": "example.file", "content": open("example.file", "rb"), }, model="whisper-1", response_format="json", temperature=0)
# Handle response print(res)Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
file | string | :heavy_check_mark: | Audio file to transcribe |
model | str | :heavy_check_mark: | Model name |
language | str | :heavy_minus_sign: | Audio language (ISO-639-1 format) |
prompt | str | :heavy_minus_sign: | Optional text prompt |
response_format | string (json, text, srt, verbose_json, vtt) | :heavy_minus_sign: | N/A |
temperature | float | :heavy_minus_sign: | N/A |
timestamp_granularities | Array<string (word, segment)> | :heavy_minus_sign: | Timestamp granularity |
retries | object | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
Section titled “Response”CreateAudioTranscriptionResponse
Errors
Section titled “Errors”| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.AuthenticationError | 401 | application/json |
| errors.PermissionDeniedError | 403 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.RateLimitError | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.ServiceUnavailableError | 503 | application/json |
| errors.R9SDefaultError | 4XX, 5XX | */* |
translate
Section titled “translate”Translate speech to English text
Example Usage
Section titled “Example Usage”from r9s import R9S
with R9S(api_key=os.getenv("R9S_API_KEY",""),) as r9_s:
res = r9_s.audio.translate(file={ "file_name": "example.file", "content": open("example.file", "rb"), }, model="whisper-1", response_format="json", temperature=0)
# Handle response print(res)Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
file | string | :heavy_check_mark: | Audio file to translate |
model | str | :heavy_check_mark: | Model name |
prompt | str | :heavy_minus_sign: | Optional text prompt |
response_format | string | :heavy_minus_sign: | N/A |
temperature | float | :heavy_minus_sign: | N/A |
retries | object | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
Section titled “Response”CreateAudioTranslationResponse
Errors
Section titled “Errors”| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.AuthenticationError | 401 | application/json |
| errors.PermissionDeniedError | 403 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.RateLimitError | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.ServiceUnavailableError | 503 | application/json |
| errors.R9SDefaultError | 4XX, 5XX | */* |