1. 실행
from pydub import AudioSegment
num = 27
path = f'./sample_data_1/원천데이터/쇼핑/업무처리/업무처리/쇼핑_{num}.m4a'
name = extract_filename(path)
audio = AudioSegment.from_file(path, format="m4a")
2. 에러
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[2], line 53
52 name = extract_filename(path)
---> 53 audio = AudioSegment.from_file(path, format="m4a")
54 wavfilepath = f"./data_1/{name}.wav"
55 audio.export(wavfilepath, format="wav")
File ~/data/kyungho/env/lib/python3.12/site-packages/pydub/audio_segment.py:728, in AudioSegment.from_file(cls, file, format, codec, parameters, start_second, duration, **kwargs)
726 info = None
727 else:
--> 728 info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
729 if info:
730 audio_streams = [x for x in info['streams']
731 if x['codec_type'] == 'audio']
File ~/data/kyungho/env/lib/python3.12/site-packages/pydub/utils.py:274, in mediainfo_json(filepath, read_ahead_limit)
271 file.close()
273 command = [prober, '-of', 'json'] + command_args
--> 274 res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
275 output, stderr = res.communicate(input=stdin_data)
276 output = output.decode("utf-8", 'ignore')
File ~/miniconda3/lib/python3.12/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
...
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'
3. 해결방법
sudo apt install ffmpeg
참조: https://stackoverflow.com/questions/57350259/filenotfounderror-errno-2-no-such-file-or-directory-ffprobe-ffprobe