create_translation: Translate Audio to English Text (Convenience Function)
Description
Shortcut that creates an OpenAI client from the OPENAI_API_KEY
environment variable and calls client$audio$translations$create().
Always produces English output regardless of source language.
Usage
create_translation(file, model = "whisper-1", ...)
Value
A list with $text containing the English translation (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
AudioTranslationsClient$create(), such as prompt,
response_format, temperature.
if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")
# Translate a Chinese audio file to Englishresult <- create_translation("chinese_speech.mp3")
cat(result$text) # Output is always in English}