This script splits an audio file into segments based on a provided cut list. Each segment is named according to the titles specified in the cut list.
- Supports various audio file formats: MP3, WAV, OGG, FLAC, AAC, AIFF, M4A, MP4, WMA, ALAC.
- Sanitizes titles to ensure they are safe for use as file names.
- Provides progress information during the splitting process.
-c,--cutlist: Path to the cut list file.-i,--input: Path to the input audio file.-o,--output: Path to the output folder where the segments will be saved.-f,--format: Format of the input audio file (e.g., mp3, wav, ogg, flac, aac, aiff, m4a, mp4, wma, alac).
python split_audio.py -c cutlist.txt -i input.mp3 -o output_folder -f mp3The cut list file should contain lines in the following format:
<time_mark> <title>
<time_mark>: Time in the formatmm:ss(minutes:seconds).<title>: The name of the segment.
0:00 The_Beginning_of_an_Epic_Adventure
1:30 The_Rise_of_the_Hero's_Journey
3:45 The_Climax_of_the_Story!
In this example:
- The first segment is named
The_Beginning_of_an_Epic_Adventureand starts at 0:00. - The second segment is named
The_Rise_of_the_Hero's_Journeyand starts at 1:30. - The third segment is named
The_Climax_of_the_Story!and starts at 3:45.
- The script sanitizes the titles to ensure they are safe for use as file names.
- Unsafe characters (e.g., /, , :, *, ?, ", <, >, |, ') are replaced with underscores (_).
- Python 3.x
pydublibrary
pip install pydub- Ensure Python is installed and added to your system's PATH.
- Install the required dependencies using the command above.
- Create a cut list file in the specified format.
- Run the script with the appropriate command line arguments.
0:00 The_Beginning_of_an_Epic_Adventure
1:30 The_Rise_of_the_Hero's_Journey
3:45 The_Climax_of_the_Story!
python split_audio.py -c cutlist.txt -i input.mp3 -o output_folder -f mp3This will split the input.mp3 file into segments based on the cut list and save them in the output_folder.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
Thanks to the pydub library for providing the audio processing capabilities.