|
|
|
@ -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
|
|
|
|
|