Learn R Programming

openaiRtools (version 0.2.2)

create_transcription: Transcribe Audio to Text (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and calls client$audio$transcriptions$create().

Usage

create_transcription(file, model = "whisper-1", ...)

Value

A list with $text containing the transcribed text (for default JSON format), or a character string for response_format = "text".

Arguments

file

Character. Required. Path to the local audio file. Supported: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm (max 25 MB).

model

Character. Whisper model. Default: "whisper-1".

...

Additional parameters passed to AudioTranscriptionsClient$create(), such as language, prompt, response_format, temperature, timestamp_granularities.

Examples

Run this code
if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")

# Basic transcription
result <- create_transcription("meeting.mp3")
cat(result$text)

# With language hint and plain text output
text <- create_transcription(
  file            = "lecture.m4a",
  model           = "whisper-1",
  language        = "en",
  response_format = "text"
)
cat(text)
}

Run the code above in your browser using DataLab