Skip to main content

@remotion/install-whisper-cppv4.0.115

使用 Whisper.cpp,你可以在本地机器上转录音频。 该软件包提供易于使用的跨平台函数来安装 Whisper.cpp 和一个模型。

🌐 With Whisper.cpp, you can transcribe audio locally on your machine.
This package provides easy to use cross-platform functions to install Whisper.cpp and a model.

npx remotion add @remotion/install-whisper-cpp

示例用法

🌐 Example usage

将 Whisper 1.5.5(在撰写本文时我们发现运行良好并支持令牌级时间戳的最新版本)和 medium.en 模型安装到 whisper.cpp 文件夹。

🌐 Install Whisper 1.5.5 (the latest version at the time of writing that we find works well and supports token-level timestamps) and the medium.en model to the whisper.cpp folder.

install-whisper.cpp
import path from 'path'; import {downloadWhisperModel, installWhisperCpp, transcribe, toCaptions} from '@remotion/install-whisper-cpp'; import fs from 'fs'; const to = path.join(process.cwd(), 'whisper.cpp'); await installWhisperCpp({ to, version: '1.5.5', }); await downloadWhisperModel({ model: 'medium.en', folder: to, }); // Convert the audio to a 16KHz wav file first if needed: // import {execSync} from 'child_process'; // execSync('ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y'); const whisperCppOutput = await transcribe({ model: 'medium.en', whisperPath: to, whisperCppVersion: '1.5.5', inputPath: '/path/to/audio.wav', tokenLevelTimestamps: true, }); // Optional: Apply our recommended postprocessing const {captions} = toCaptions({ whisperCppOutput, }); fs.writeFileSync('captions.json', JSON.stringify(captions, null, 2));

函数

🌐 Functions

许可证

🌐 License

MIT

另请参阅

🌐 See also