from pydub import AudioSegment lecture = AudioSegment.frommp3("lecture1.mp3") PyDub…
- User
from pydub import AudioSegment
lecture = AudioSegment.from_mp3("lecture_1.mp3")
PyDub handles time in milliseconds
first_part_lecture = lecture[:30601000]
first_part_lecture.export("lecture_1_part_1.mp3", format="mp3")
second_part_lecture = lecture[30601000:]
second_part_lecture.export("lecture_1_part_2.mp3", format="mp3") How to fix error: { "name": "FileNotFoundError", "message": "[Errno 2] No such file or directory: 'ffprobe'", "stack": "--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) Cell In[19], line 3 1 from pydub import AudioSegment ----> 3 lecture = AudioSegment.from_mp3("lecture_1.mp3") 5 # PyDub handles time in milliseconds 6 first_part_lecture = lecture[:30601000]
File ~/Projects/trading-edu/trading-env/lib/python3.12/site-packages/pydub/audio_segment.py:796, in AudioSegment.from_mp3(cls, file, parameters) 794 @classmethod 795 def from_mp3(cls, file, parameters=None): --> 796 return cls.from_file(file, 'mp3', parameters=parameters)
File ~/Projects/trading-edu/trading-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 ~/Projects/trading-edu/trading-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 /Library/Frameworks/Python.framework/Versions/3.12/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) 1022 if self.text_mode: 1023 self.stderr = io.TextIOWrapper(self.stderr, 1024 encoding=encoding, errors=errors) -> 1026 self._execute_child(args, executable, preexec_fn, close_fds, 1027 pass_fds, cwd, env, 1028 startupinfo, creationflags, shell, 1029 p2cread, p2cwrite, 1030 c2pread, c2pwrite, 1031 errread, errwrite, 1032 restore_signals, 1033 gid, gids, uid, umask, 1034 start_new_session, process_group) 1035 except: 1036 # Cleanup if the child failed starting. 1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
- Assistant