Spaces:
Build error
Build error
duration check
Browse files
app.py
CHANGED
|
@@ -25,15 +25,18 @@ embedding_model = PretrainedSpeakerEmbedding(
|
|
| 25 |
|
| 26 |
def transcribe(audio, num_speakers):
|
| 27 |
path = convert_to_wav(audio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
result = model.transcribe(path)
|
| 29 |
segments = result["segments"]
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
num_speakers = len(segments)
|
| 33 |
if len(segments) == 1:
|
| 34 |
segments[0]['speaker'] = 'SPEAKER 1'
|
| 35 |
else:
|
| 36 |
-
duration = get_duration(path)
|
| 37 |
embeddings = make_embeddings(path, segments, duration)
|
| 38 |
add_speaker_labels(segments, embeddings, num_speakers)
|
| 39 |
output = get_output(segments)
|
|
@@ -94,5 +97,5 @@ gr.Interface(
|
|
| 94 |
],
|
| 95 |
outputs=[
|
| 96 |
gr.outputs.Textbox(label='Transcript')
|
| 97 |
-
]
|
| 98 |
-
|
|
|
|
| 25 |
|
| 26 |
def transcribe(audio, num_speakers):
|
| 27 |
path = convert_to_wav(audio)
|
| 28 |
+
|
| 29 |
+
duration = get_duration(path)
|
| 30 |
+
if duration > 4 * 60 * 60:
|
| 31 |
+
return "Audio duration too long"
|
| 32 |
+
|
| 33 |
result = model.transcribe(path)
|
| 34 |
segments = result["segments"]
|
| 35 |
+
|
| 36 |
+
num_speakers = min(max(round(num_speakers), 1), len(segments))
|
|
|
|
| 37 |
if len(segments) == 1:
|
| 38 |
segments[0]['speaker'] = 'SPEAKER 1'
|
| 39 |
else:
|
|
|
|
| 40 |
embeddings = make_embeddings(path, segments, duration)
|
| 41 |
add_speaker_labels(segments, embeddings, num_speakers)
|
| 42 |
output = get_output(segments)
|
|
|
|
| 97 |
],
|
| 98 |
outputs=[
|
| 99 |
gr.outputs.Textbox(label='Transcript')
|
| 100 |
+
]
|
| 101 |
+
).launch()
|