Spaces:
Sleeping
Sleeping
File size: 496 Bytes
0f7f63b |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import pathlib
import os
import subprocess
def extract_audio(local_video_path: str, save_dir_path: str = "./downloads/audio") -> str:
if os.name == 'nt':
NotImplementedError("Filename extraction on Windows not yet implemented")
out_file_name = os.path.basename(local_video_path)
audio_path_out = save_dir_path.join("/").join(out_file_name)
subprocess.run(['ffmpeg', '-i', local_video_path, '-f', 'mp3', '-ab', '192000', '-vn', audio_path_out])
return audio_path_out |