Spaces:
Build error
Build error
Commit
·
feba9aa
1
Parent(s):
25f01f2
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,20 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
def run_diarization(path1):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
df = pd.DataFrame(columns=['start_time', 'end_time', 'speaker'])
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
return df
|
| 19 |
|
| 20 |
inputs = [
|
|
|
|
| 1 |
+
from nemo.collections.asr.models import NeuralDiarizer
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 6 |
|
| 7 |
+
model = NeuralDiarizer.from_pretrained("diar_msdd_telephonic").to(device)
|
| 8 |
|
| 9 |
def run_diarization(path1):
|
| 10 |
+
annotation = model(path1)
|
| 11 |
+
rttm=annotation.to_rttm()
|
| 12 |
df = pd.DataFrame(columns=['start_time', 'end_time', 'speaker'])
|
| 13 |
+
for idx,line in enumerate(rttm.splitlines()):
|
| 14 |
+
split = line.split()
|
| 15 |
+
start_time, duration, speaker = split[3], split[4], split[7]
|
| 16 |
+
end_time = float(start_time) + float(duration)
|
| 17 |
+
df.loc[idx] = start_time, end_time, speaker
|
| 18 |
return df
|
| 19 |
|
| 20 |
inputs = [
|