Skip to main content

openAiWhisperApiToCaptions()v4.0.217

将来自 openai 包的 openai.audio.transcriptions.create 的输出转换为 Caption 对象数组。

🌐 Turns the output from openai.audio.transcriptions.create from the openai package into an array of Caption objects.

此软件包对字幕进行处理,以保留单词中的标点符号,而默认情况下这些标点符号不包含在 OpenAI 的响应中。

🌐 This package performs processing on the captions in order to retain the punctuation in the words, which is not by default included in the OpenAI response.

这个函数可以在任何 JavaScript 环境中使用,但你不应该在浏览器中使用 OpenAI API,因为你的 API 密钥会暴露给浏览器。

🌐 This function can be used in any JavaScript environment, but you should not use the OpenAI API in the browser because your API key will be exposed to the browser.

Example usage
import fs from 'fs'; import {OpenAI} from 'openai'; import {openAiWhisperApiToCaptions} from '@remotion/openai-whisper'; const openai = new OpenAI(); const transcription = await openai.audio.transcriptions.create({ file: fs.createReadStream('audio.mp3'), model: 'whisper-1', response_format: 'verbose_json', prompt: 'Hello, welcome to my lecture.', timestamp_granularities: ['word'], }); const {captions} = openAiWhisperApiToCaptions({transcription});

另请参阅

🌐 See also