Spaces:
Runtime error
Runtime error
Commit
·
bdec318
1
Parent(s):
b58af27
full adjust
Browse files- .gitignore +1 -0
- app.py +12 -23
- diarization.py +5 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__
|
app.py
CHANGED
@@ -4,31 +4,20 @@ import ffmpeg
|
|
4 |
import gradio as gr
|
5 |
import os
|
6 |
|
7 |
-
# Get video & convert it
|
8 |
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
def video_to_audio(input_video_path, output_audio_path):
|
11 |
-
(
|
12 |
-
ffmpeg.input(input_video_path)
|
13 |
-
.output(output_audio_path, format='wav')
|
14 |
-
.run()
|
15 |
-
)
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
out_file = ffmpeg.input(inputs_interface).audio.output(
|
22 |
-
"input.wav", format="wav").run()
|
23 |
-
|
24 |
-
|
25 |
-
def prepareInput():
|
26 |
-
return startDiarization(out_file)
|
27 |
-
|
28 |
-
|
29 |
-
gr.Interface(
|
30 |
-
prepareInput,
|
31 |
-
inputs=inputs_interface,
|
32 |
outputs="text",
|
33 |
title="Get Diarization"
|
34 |
-
)
|
|
|
|
|
|
|
|
4 |
import gradio as gr
|
5 |
import os
|
6 |
|
|
|
7 |
|
8 |
+
def prepareInput(input_file):
|
9 |
+
output_file = "input.wav"
|
10 |
+
ffmpeg.input(input_file).audio.output(
|
11 |
+
output_file, format="wav").run()
|
12 |
+
return startDiarization(output_file)
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
video_interface = gr.Interface(
|
16 |
+
fn=prepareInput,
|
17 |
+
inputs=gr.Video(type="file"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
outputs="text",
|
19 |
title="Get Diarization"
|
20 |
+
)
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
video_interface.launch()
|
diarization.py
CHANGED
@@ -12,6 +12,7 @@ pipeline.to(device)
|
|
12 |
|
13 |
|
14 |
def startDiarization(input_file):
|
|
|
15 |
diarization = pipeline(input_file)
|
16 |
|
17 |
sample_groups = []
|
@@ -26,8 +27,12 @@ def startDiarization(input_file):
|
|
26 |
suffix += 1
|
27 |
file_name = f"{speaker}-{suffix}"
|
28 |
speaker_groups[file_name] = [turn.start, turn.end]
|
|
|
|
|
|
|
29 |
saveGroupsJson(sample_groups, speaker_groups)
|
30 |
audioSegmentation(input_file, speaker_groups)
|
|
|
31 |
return str(speaker_groups)
|
32 |
|
33 |
|
|
|
12 |
|
13 |
|
14 |
def startDiarization(input_file):
|
15 |
+
print("Starting diarization")
|
16 |
diarization = pipeline(input_file)
|
17 |
|
18 |
sample_groups = []
|
|
|
27 |
suffix += 1
|
28 |
file_name = f"{speaker}-{suffix}"
|
29 |
speaker_groups[file_name] = [turn.start, turn.end]
|
30 |
+
print(f"speaker_groups {file_name}: {speaker_groups[file_name]}")
|
31 |
+
print(f"start={turn.start:.3f}s stop={turn.end:.3f}s speaker_{speaker}")
|
32 |
+
|
33 |
saveGroupsJson(sample_groups, speaker_groups)
|
34 |
audioSegmentation(input_file, speaker_groups)
|
35 |
+
print(str(speaker_groups))
|
36 |
return str(speaker_groups)
|
37 |
|
38 |
|