Skip to content

franckferman/audio_splitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Contributors Forks Stargazers License

๐ŸŽถ audio_splitter

A simple yet powerful tool to split audio files using FFmpeg.
CLI-based audio segmentation made easy.

๐Ÿ“œ Table of Contents

Click to collapse/expand
  1. ๐Ÿ“– About
  2. ๐Ÿ› ๏ธ Installation
  3. ๐ŸŽฎ Usage
  4. ๐Ÿค Contributing
  5. ๐ŸŒ  Star Evolution
  6. ๐Ÿ“œ License
  7. ๐Ÿ“ž Contact

๐Ÿ“– About

audio_splitter is a lightweight CLI tool built to split audio files (and automatically extract audio from video files) into smaller, fixed-duration segments using FFmpeg and the Python library ffmpeg-python.

I initially developed audio_splitter to complement my other project, Whisper_Transcriber, enhancing the workflow for transcribing audio files via OpenAI's Whisper API. Two main motivations drove the creation of this utility:

  • Whisper's API Duration Limit: Whisper API strictly limits the maximum audio duration per transcription request, necessitating prior audio segmentation.
  • Clearer Cost Monitoring & Control: Splitting audio into shorter segments allows for precise monitoring of transcription costs per request, enabling better budget management and visibility into Whisper API credit usage.

audio_splitter seamlessly handles multiple audio formats (MP3, WAV, M4A, FLAC, etc.) and extracts audio from popular video formats (MP4, AVI, MKV, MOV), converting them automatically into MP3 segments. It thus provides a practical solution for audio management and transcription tasks.

The primary goal of audio_splitter is to streamline and simplify audio preprocessing, offering a straightforward and effective solution to quickly segment lengthy audio and video recordingsโ€”especially when used in conjunction with tools like Whisper_Transcriber.

โš™๏ธ Features of audio_splitter

  • โœ… Quickly splits audio and video files into customizable-duration segments.
  • โœ… Supports major audio formats (MP3, WAV, M4A, FLAC, and others).
  • โœ… Automatically extracts and converts audio tracks from videos (MP4, AVI, MKV, MOV).
  • โœ… Fast and accurate segmentation powered by FFmpeg and the Python package ffmpeg-python.
  • โœ… Built-in utility for cleaning temporary files (e.g., .pyc, cache, logs).
  • โœ… Intuitive and user-friendly CLI, with optional detailed logging and debug mode.

(๐Ÿ”ผ Back to top)

๐Ÿš€ Installation

Before getting started, make sure you meet the following prerequisites.

Prerequisites

  1. Python 3: Ensure Python 3 is installed on your system.

โš ๏ธ Note: audio_splitter has been tested on Python 3.11.10 under Linux. While it might work on other versions or operating systems, compatibility is officially guaranteed only for this specific setup.

  1. Dependencies: Install the required Python dependencies using pip:
pip install -r requirements.txt

ffmpeg-python requires FFmpeg to be installed on your system. Please ensure that FFmpeg is installed and accessible via your system's PATH.

Installation Methods

  1. Clone the repository via Git:
git clone https://github.com/franckferman/audio_splitter.git

2. Direct Download from GitHub

  1. Go to GitHub repo.
  2. Click <> Code โ†’ Download ZIP.
  3. Extract the archive to your desired location.

(๐Ÿ”ผ Back to top)

๐ŸŽฎ Usage

Below you'll find common commands and usage examples for audio_splitter.

๐Ÿšฆ Quick Start

To quickly view all available commands and options:

python3 src/audio_splitter.py --help

๐Ÿ“– Available Commands

  • split: Splits audio files into segments of customizable duration.
  • clean: Cleans temporary and unwanted files from the project.

๐ŸŽง Splitting Audio Files

Use the split command to split audio files into smaller segments.

Basic Splitting Example

Split an audio file into segments of 10 minutes (600 seconds) each:

python3 src/audio_splitter.py split ./audio/example.mp3 ./output/ --duration 600
Options Explained
Argument Description Example
input_file Path to the input audio/video file ./my_audio.mp3
output_folder Directory where split segments will be saved ./output
-d, --duration Duration in seconds of each segment (default: 600) -d 300 (5-minute segments)
--debug Enable verbose debug logging --debug

๐Ÿง™โ€โ™‚๏ธ Advanced Example

Split a video file (e.g., MP4) by extracting audio automatically and creating 5-minute segments with debug enabled:

python3 src/audio_splitter.py split ./videos/lecture.mp4 ./segments/ --duration 300 --debug

๐Ÿงน Cleaning Temporary Files

Use the clean command to remove temporary files from your project.

Basic Cleanup Example

To clean temporary files (like .pyc, pycache) from your current directory:

python3 src/audio_splitter.py clean

(๐Ÿ”ผ Back to top)

๐Ÿค Contributing

We truly appreciate and welcome community involvement. Your contributions, feedback, and suggestions play a crucial role in improving the project for everyone. If you're interested in contributing or have ideas for enhancements, please feel free to open an issue or submit a pull request on our GitHub repository. Every contribution, no matter how big or small, is highly valued and greatly appreciated!

(๐Ÿ”ผ Back to top)

๐ŸŒ  Star Evolution

Explore the star history of this project and see how it has evolved over time:

Star History Chart

Your support is greatly appreciated. We're grateful for every star! Your backing fuels our passion. โœจ

(๐Ÿ”ผ Back to top)

๐Ÿ“š License

This project is licensed under the GNU Affero General Public License, Version 3.0. For more details, please refer to the LICENSE file in the repository: Read the license on GitHub

(๐Ÿ”ผ Back to top)

๐Ÿ“ž Contact

ProtonMail LinkedIn Twitter

(๐Ÿ”ผ Back to top)