Spaces:
Runtime error
Runtime error
a.pourmand
commited on
Commit
·
1b6d8ab
1
Parent(s):
d2fc75a
add file
Browse files
app.py
CHANGED
|
@@ -29,11 +29,18 @@ To duplicate this repo, you have to give permission from three reopsitories and
|
|
| 29 |
"""
|
| 30 |
from pyannote.audio import Pipeline
|
| 31 |
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization",use_auth_token=HF_API)
|
| 32 |
-
def predict(target_language, number_of_speakers,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
if number_of_speakers == 0:
|
| 34 |
-
diarization = pipeline(
|
| 35 |
else:
|
| 36 |
-
diarization = pipeline(
|
| 37 |
|
| 38 |
for turn, value, speaker in diarization.itertracks(yield_label=True):
|
| 39 |
print(f"start={turn.start}s stop={turn.end}s speaker_{speaker}")
|
|
@@ -114,7 +121,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 114 |
submit = gr.Button("Submit")
|
| 115 |
text_output = gr.Textbox(label="Transcribed Text", value="", interactive=False)
|
| 116 |
|
| 117 |
-
submit.click(fn=predict, inputs=[target_language,number_of_speakers,
|
| 118 |
|
| 119 |
gr.Markdown(DUPLICATE)
|
| 120 |
|
|
|
|
| 29 |
"""
|
| 30 |
from pyannote.audio import Pipeline
|
| 31 |
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization",use_auth_token=HF_API)
|
| 32 |
+
def predict(target_language, number_of_speakers, audio_source, input_audio_mic, input_audio_file):
|
| 33 |
+
if audio_source == "microphone":
|
| 34 |
+
input_data = input_audio_mic
|
| 35 |
+
else:
|
| 36 |
+
input_data = input_audio_file
|
| 37 |
+
|
| 38 |
+
print(input_data)
|
| 39 |
+
|
| 40 |
if number_of_speakers == 0:
|
| 41 |
+
diarization = pipeline(input_data)
|
| 42 |
else:
|
| 43 |
+
diarization = pipeline(input_data, num_speakers=number_of_speakers)
|
| 44 |
|
| 45 |
for turn, value, speaker in diarization.itertracks(yield_label=True):
|
| 46 |
print(f"start={turn.start}s stop={turn.end}s speaker_{speaker}")
|
|
|
|
| 121 |
submit = gr.Button("Submit")
|
| 122 |
text_output = gr.Textbox(label="Transcribed Text", value="", interactive=False)
|
| 123 |
|
| 124 |
+
submit.click(fn=predict, inputs=[target_language,number_of_speakers, audio_source,input_audio_mic, input_audio_file], outputs=[text_output],api_name="predict")
|
| 125 |
|
| 126 |
gr.Markdown(DUPLICATE)
|
| 127 |
|