Learn R Programming

openaistream (version 0.2.0)

audio: audio Class

Description

To turn audio into text or text into audio

Arguments

Super class

openaistream::openai -> audio

Methods

Inherited methods


Method speech()

Generates audio from the input text.

Usage

audio$speech(
  model = "tts-1",
  input,
  voice = "alloy",
  stream = F,
  num = 100,
  ...,
  verbosity = 0
)

Arguments

model

character Required. One of the available TTS models: tts-1 or tts-1-hd

input

character Required. The text to generate audio for. The maximum length is 4096 characters.

voice

character Required. The voice to use when generating the audio. Supported voices are alloy, echo, fable, onyx, nova, and shimmer.

stream

logical. Using the stream call, it will return raw data of the specified length, which can be saved in the set format such as mp3, etc. For details, please see the examples.

num

The num parameter controls the number of raw entries returned by a stream in one go. Note that this is different from the n parameter, which specifies the number of results returned. For detailed information on the n parameter, please refer to OpenAI's API documentation.

...

Additional parameters as required by the OpenAI API.For example:response_format;speed....

verbosity

numeric. Verbosity level for the API call(0:no output;1:show headers; 2:show headers and bodies;3: show headers, bodies, and curl status messages.).

Returns

The audio file content.


Method transcription()

Transcribes audio into the input language.

Usage

audio$transcription(path, model = "whisper-1", ..., verbosity = 0)

Arguments

path

character Required. The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

model

character Required. ID of the model to use. Only whisper-1 is currently available.

...

Additional parameters as required by the OpenAI API.For example:language;prompt;response_format;temperature....

verbosity

numeric. Verbosity level for the API call(0:no output;1:show headers; 2:show headers and bodies;3: show headers, bodies, and curl status messages.).

Returns

The transcribed text.


Method translation()

Translates audio into English.

Usage

audio$translation(path, model = "whisper-1", ..., verbosity = 0)

Arguments

path

character Required. The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

model

character Required. ID of the model to use. Only whisper-1 is currently available.

...

Additional parameters as required by the OpenAI API.For example:prompt;response_format;temperature....

verbosity

numeric. Verbosity level for the API call(0:no output;1:show headers; 2:show headers and bodies;3: show headers, bodies, and curl status messages.).

Returns

The transcribed text.


Method clone()

The objects of this class are cloneable with this method.

Usage

audio$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.