MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / extractAudio

Function extractAudio

packages/cli/src/whisper/transcribe.ts:144–158  ·  view source on GitHub ↗

* Extract audio from a video file as 16kHz mono WAV (whisper requirement).

(videoPath: string)

Source from the content-addressed store, hash-verified

142 * Extract audio from a video file as 16kHz mono WAV (whisper requirement).
143 */
144function extractAudio(videoPath: string): string {
145 const ffmpegPath = findFFmpeg();
146 if (!ffmpegPath) {
147 throw new Error(
148 `ffmpeg is required to extract audio from video. Install: ${getFFmpegInstallHint()}`,
149 );
150 }
151 const wavPath = tempWavPath();
152 execFileSync(
153 ffmpegPath,
154 ["-i", videoPath, "-vn", "-ar", "16000", "-ac", "1", "-f", "wav", "-y", wavPath],
155 { stdio: "ignore", timeout: 120_000 },
156 );
157 return wavPath;
158}
159
160/**
161 * Check if a WAV file is already 16kHz mono via ffprobe.

Callers 1

transcribeFunction · 0.85

Calls 3

findFFmpegFunction · 0.85
getFFmpegInstallHintFunction · 0.85
tempWavPathFunction · 0.85

Tested by

no test coverage detected