MCPcopy Create free account
hub / github.com/MeiGen-AI/MultiTalk / extract_audio_from_video

Function extract_audio_from_video

app.py:316–337  ·  view source on GitHub ↗
(filename, sample_rate)

Source from the content-addressed store, hash-verified

314 return audio_emb
315
316def extract_audio_from_video(filename, sample_rate):
317 raw_audio_path = filename.split('/')[-1].split('.')[0]+'.wav'
318 ffmpeg_command = [
319 "ffmpeg",
320 "-y",
321 "-i",
322 str(filename),
323 "-vn",
324 "-acodec",
325 "pcm_s16le",
326 "-ar",
327 "16000",
328 "-ac",
329 "2",
330 str(raw_audio_path),
331 ]
332 subprocess.run(ffmpeg_command, check=True)
333 human_speech_array, sr = librosa.load(raw_audio_path, sr=sample_rate)
334 human_speech_array = loudness_norm(human_speech_array, sr)
335 os.remove(raw_audio_path)
336
337 return human_speech_array
338
339def audio_prepare_single(audio_path, sample_rate=16000):
340 ext = os.path.splitext(audio_path)[1].lower()

Callers 1

audio_prepare_singleFunction · 0.70

Calls 1

loudness_normFunction · 0.70

Tested by

no test coverage detected