Soenneker.Libraries.Whisper.CTranslate:将 Windows whisper-ctranslate2 可执行文件打包为 .NET 内容资产
soenneker/soenneker.libraries.whisper.ctranslate
Soenneker.Libraries.Whisper.CTranslate 将 Windows 版 whisper-ctranslate2 可执行文件打包为 .NET 内容资产,通过 `dotnet add package Soenneker.Libraries.Whisper.CTranslate` 安装后,exe 会被复制到应用输出目录下的 Resources 文件夹。
The Windows whisper-ctranslate2 executable packaged as a .NET content asset.
Install
dotnet add package Soenneker.Libraries.Whisper.CTranslate
The executable is copied beneath the application output directory:
string whisper = Path.Combine( AppContext.BaseDirectory, "Resources", "whisper_ctranslate2.exe"); var startInfo = new ProcessStartInfo(whisper) { UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true }; startInfo.ArgumentList.Add(audioPath); startInfo.ArgumentList.Add("--model"); startInfo.ArgumentList.Add("medium"); startInfo.ArgumentList.Add("--output_format"); startInfo.ArgumentList.Add("srt"); startInfo.ArgumentList.Add("--output_dir"); startInfo.ArgumentList.Add(outputDirectory);
Start the process, drain both redirected streams, wait for completion, and reject a non-zero exit code. Pass paths and other variable values through ArgumentList rather than concatenating a command string.
Named models may be downloaded on first use, so the process needs network access and writable model-cache storage unless the model is already available locally. Model size, CPU/GPU selection, and audio duration materially affect runtime and memory use.
This package supplies the executable; it does not manage models, start processes, parse transcripts, or enforce time and output-size limits.
来源:GitHub · github.com