Skip to content

Audio

Convert text to speech

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)
ParameterTypeRequiredDescription
modelstr:heavy_check_mark:TTS model name
inputstr:heavy_check_mark:Text to convert to speech
voicestring (alloy, echo, fable, onyx, nova, shimmer):heavy_check_mark:Voice type
response_formatstring (mp3, opus, aac, flac, wav, pcm):heavy_minus_sign:N/A
speedfloat:heavy_minus_sign:Speech speed
retriesobject:heavy_minus_sign:Configuration to override the default retry behavior of the client.

CreateAudioSpeechResponse

Error TypeStatus CodeContent Type
errors.BadRequestError400application/json
errors.AuthenticationError401application/json
errors.PermissionDeniedError403application/json
errors.UnprocessableEntityError422application/json
errors.RateLimitError429application/json
errors.InternalServerError500application/json
errors.ServiceUnavailableError503application/json
errors.R9SDefaultError4XX, 5XX*/*

Transcribe speech to text

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)
ParameterTypeRequiredDescription
filestring:heavy_check_mark:Audio file to transcribe
modelstr:heavy_check_mark:Model name
languagestr:heavy_minus_sign:Audio language (ISO-639-1 format)
promptstr:heavy_minus_sign:Optional text prompt
response_formatstring (json, text, srt, verbose_json, vtt):heavy_minus_sign:N/A
temperaturefloat:heavy_minus_sign:N/A
timestamp_granularitiesArray<string (word, segment)>:heavy_minus_sign:Timestamp granularity
retriesobject:heavy_minus_sign:Configuration to override the default retry behavior of the client.

CreateAudioTranscriptionResponse

Error TypeStatus CodeContent Type
errors.BadRequestError400application/json
errors.AuthenticationError401application/json
errors.PermissionDeniedError403application/json
errors.UnprocessableEntityError422application/json
errors.RateLimitError429application/json
errors.InternalServerError500application/json
errors.ServiceUnavailableError503application/json
errors.R9SDefaultError4XX, 5XX*/*

Translate speech to English text

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)
ParameterTypeRequiredDescription
filestring:heavy_check_mark:Audio file to translate
modelstr:heavy_check_mark:Model name
promptstr:heavy_minus_sign:Optional text prompt
response_formatstring:heavy_minus_sign:N/A
temperaturefloat:heavy_minus_sign:N/A
retriesobject:heavy_minus_sign:Configuration to override the default retry behavior of the client.

CreateAudioTranslationResponse

Error TypeStatus CodeContent Type
errors.BadRequestError400application/json
errors.AuthenticationError401application/json
errors.PermissionDeniedError403application/json
errors.UnprocessableEntityError422application/json
errors.RateLimitError429application/json
errors.InternalServerError500application/json
errors.ServiceUnavailableError503application/json
errors.R9SDefaultError4XX, 5XX*/*