Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ 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).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))
|
| 12 |
speech_timestamps = [{"start": s[0]/1000, "end": s[1]/1000} for s in speech_timestamps]
|
|
@@ -66,7 +66,7 @@ def get_labels(audio_fp, min_speech_duration_ms, min_silence_duration_ms, auto_m
|
|
| 66 |
interface = gr.Interface(
|
| 67 |
get_labels,
|
| 68 |
[
|
| 69 |
-
gr.
|
| 70 |
gr.Number(label="min_speech_duration_ms", value=40, info="default (40)"),
|
| 71 |
gr.Number(label="min_silence_duration_ms", value=40, info="default (40)"),
|
| 72 |
gr.Checkbox(label="Auto merge", value=True),
|
|
|
|
| 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))
|
| 12 |
speech_timestamps = [{"start": s[0]/1000, "end": s[1]/1000} for s in speech_timestamps]
|
|
|
|
| 66 |
interface = gr.Interface(
|
| 67 |
get_labels,
|
| 68 |
[
|
| 69 |
+
gr.File(type="filepath", label="Audio file", file_types=["audio"], file_count="single"),
|
| 70 |
gr.Number(label="min_speech_duration_ms", value=40, info="default (40)"),
|
| 71 |
gr.Number(label="min_silence_duration_ms", value=40, info="default (40)"),
|
| 72 |
gr.Checkbox(label="Auto merge", value=True),
|