From f0e13acc36dcbcd98ef65b782644f94bb4e0acd9 Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Sat, 3 Feb 2024 19:38:08 -0500 Subject: [PATCH] Debugging --- .gitignore | 3 +++ pyproject.toml | 6 ++++++ requirements.in | 1 + requirements.txt | 2 ++ split_it/cli.py | 7 +++++-- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e8afa11..d5343ce 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ target/ # Pycharm .idea + +# +output/ diff --git a/pyproject.toml b/pyproject.toml index 2a0c26e..08bf08d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,9 @@ classifiers = [ ] dynamic = ["readme", "dependencies"] +[tool.setuptools] +packages = ["split_it"] + [tool.setuptools.dynamic] readme = {file = ["README.md"], content-type = "text/markdown"} dependencies = {file = ["requirements.txt"]} @@ -20,6 +23,9 @@ dependencies = {file = ["requirements.txt"]} requires = ["setuptools"] build-backend = "setuptools.build_meta" +[project.scripts] +split-it = "split_it.cli:main" + [tool.isort] profile = "black" line_length = 120 diff --git a/requirements.in b/requirements.in index 0b46f1b..ad65dce 100644 --- a/requirements.in +++ b/requirements.in @@ -1,2 +1,3 @@ pydub +simpleaudio tqdm diff --git a/requirements.txt b/requirements.txt index dca89b9..93b756b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,7 @@ # pydub==0.25.1 # via -r requirements.in +simpleaudio==1.0.4 + # via -r requirements.in tqdm==4.66.1 # via -r requirements.in diff --git a/split_it/cli.py b/split_it/cli.py index 40d7eef..709372a 100644 --- a/split_it/cli.py +++ b/split_it/cli.py @@ -12,6 +12,7 @@ def save_chunk(chunk, start_time, output_dir, output_format): def merge_short_chunks(chunks, min_chunk_length_ms): + merged_chunks = [] current_chunk = chunks[0] @@ -40,7 +41,9 @@ def split_audio( # Split the audio file based on silence min_silence_len = silence_min_len silence_thresh = silence_threshold - chunks = split_on_silence(audio, min_silence_len=min_silence_len, silence_thresh=silence_thresh) + chunks = split_on_silence( + audio, min_silence_len=min_silence_len, silence_thresh=silence_thresh, keep_silence=200 + ) # Merge adjacent chunks shorter than the specified length chunks = merge_short_chunks(chunks, chunk_length_ms) @@ -112,7 +115,7 @@ def main(): "--silence_threshold", type=int, default=-40, help="Threshold in dB for silence based splitting." ) parser.add_argument( - "--silence_min_len", type=int, default=400, help="Minimum length of silence in milliseconds for splitting." + "--silence_min_len", type=int, default=1000, help="Minimum length of silence in milliseconds for splitting." ) # Parse the arguments