(filename, sample_rate)
| 314 | return audio_emb |
| 315 | |
| 316 | def 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 | |
| 339 | def audio_prepare_single(audio_path, sample_rate=16000): |
| 340 | ext = os.path.splitext(audio_path)[1].lower() |
no test coverage detected