deepsync commited on
Commit
c535b52
·
verified ·
1 Parent(s): db06467

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -5,7 +5,7 @@ from pydub.silence import detect_nonsilent
5
  from pydub import AudioSegment
6
 
7
 
8
- def get_labels(audio_fp, min_speech_duration_ms, min_silence_duration_ms, auto_merge, uppper_merge_threshold, max_segment_length, end_extension, extend_small_segments):
9
  audio = AudioSegment.from_file(audio_fp.name).set_channels(1)
10
  speech_timestamps = detect_nonsilent(audio, min_silence_len=min_silence_duration_ms, silence_thresh=-40)
11
  speech_timestamps = list(filter(lambda x: x[1]-x[0] > min_speech_duration_ms, speech_timestamps))
@@ -57,6 +57,10 @@ def get_labels(audio_fp, min_speech_duration_ms, min_silence_duration_ms, auto_m
57
  if nl[1] + end_extension < new_labels[i+1][0]:
58
  nl[1] = nl[1] + end_extension
59
 
 
 
 
 
60
  translate_labels = list(map(lambda x: f"{x[0]}\t{x[1]}\t{x[2]}", new_labels))
61
 
62
  filename_path = f"{fn}_translate_label.txt"
@@ -76,7 +80,8 @@ interface = gr.Interface(
76
  gr.Textbox(label="Gap max threshold value (seconds)", value=0.350),
77
  gr.Number(label="Approx Max Segment Length", value=7),
78
  gr.Number(label="Extend end by (seconds)", value=0),
79
- gr.Checkbox(label="Extend small segments (minimum 1.02 seconds)", value=False)
 
80
  ],
81
  [
82
  gr.File(label="VAD Labels"),
 
5
  from pydub import AudioSegment
6
 
7
 
8
+ def get_labels(audio_fp, min_speech_duration_ms, min_silence_duration_ms, auto_merge, uppper_merge_threshold, max_segment_length, end_extension, extend_small_segments, show_duration_label):
9
  audio = AudioSegment.from_file(audio_fp.name).set_channels(1)
10
  speech_timestamps = detect_nonsilent(audio, min_silence_len=min_silence_duration_ms, silence_thresh=-40)
11
  speech_timestamps = list(filter(lambda x: x[1]-x[0] > min_speech_duration_ms, speech_timestamps))
 
57
  if nl[1] + end_extension < new_labels[i+1][0]:
58
  nl[1] = nl[1] + end_extension
59
 
60
+ if show_duration_label:
61
+ for nl in new_labels:
62
+ nl[2] = round(nl[1] - nl[0], 3)
63
+
64
  translate_labels = list(map(lambda x: f"{x[0]}\t{x[1]}\t{x[2]}", new_labels))
65
 
66
  filename_path = f"{fn}_translate_label.txt"
 
80
  gr.Textbox(label="Gap max threshold value (seconds)", value=0.350),
81
  gr.Number(label="Approx Max Segment Length", value=7),
82
  gr.Number(label="Extend end by (seconds)", value=0),
83
+ gr.Checkbox(label="Extend small segments (minimum 1.02 seconds)", value=False),
84
+ gr.Checkbox(label="Show only duration in labels", value=False)
85
  ],
86
  [
87
  gr.File(label="VAD Labels"),