A cli tool for cutting a long audio into segments by silence.
Project description
voicecut
A cli utility for splitting a long audio file into shorter chunks based on moments of silence. It is useful for preprocessing audio before performing speech-to-text on it.
Installation
pip install voicecut
Usage
Command Line Interface
Split audio files from the command line:
voicecut audio.mp3 [OPTIONS]
Options:
--segment-length FLOAT: Target segment length in seconds (default: 600)--segment-delta FLOAT: Allowed deviation from segment length in seconds (default: 30)--silence-thresh-delta INT: Silence threshold delta in dB (default: -16)--min-silence-len FLOAT: Minimum silence length in seconds (default: 0.5)--output-dir PATH: Output directory for split segments (default: current directory)
Example:
voicecut audio.mp3 --segment-length 600 --output-dir ./segments
Python API
Split an audio file in roughly 10 minute segments with splits in moments of silence.
from voicecut import split_audio_on_silence
from pydub import AudioSegment
audio = AudioSegment.from_file("example_audio.mp3")
splitted = split_audio_on_silence(audio)
for i, segment in enumerate(splitted):
segment.export(f"segment_{i}.wav")
Development
It is recomended to use uv toolset for development.
Testing
There are unittests available in the tests/ directory.
uv run pytest
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file voicecut-0.1.0.tar.gz.
File metadata
- Download URL: voicecut-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29cb28b45764d6560b448078946b60284875a5e625a4f7172a6cd3000af6b56c
|
|
| MD5 |
65c55826399fb119920264255938d3dc
|
|
| BLAKE2b-256 |
6a4251b6717d9c8ba715bfa49d667e1cb020325e2a0a7525057366de5beac119
|
File details
Details for the file voicecut-0.1.0-py3-none-any.whl.
File metadata
- Download URL: voicecut-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37c949e5e2f5e65b99d3af0fb8d31244e066d1151ce6d41851eb83d9d8256290
|
|
| MD5 |
a416de99b071eb68998bad49edd4c1ea
|
|
| BLAKE2b-256 |
8894bf7b9243ac4cfcbf0650bf03b8f3505274b55d993ba9d4522bdf33da8ab3
|