if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")
# Generate and save to MP3
audio <- create_speech(
input = "The quick brown fox jumps over the lazy dog.",
model = "tts-1",
voice = "nova"
)
writeBin(audio, "output.mp3")
# High-quality WAV with slower speed
audio <- create_speech(
input = "Welcome to the lecture on macroeconomics.",
model = "tts-1-hd",
voice = "onyx",
response_format = "wav",
speed = 0.9
)
writeBin(audio, "lecture_intro.wav")
}
Run the code above in your browser using DataLab