Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def predict(speech_array, sampling_rate):
|
|
27 |
logits = model.to(device)(**inputs).logits
|
28 |
|
29 |
scores = F.softmax(logits, dim=1).detach().cpu().numpy()[0]
|
30 |
-
outputs = [{
|
31 |
return outputs
|
32 |
|
33 |
|
@@ -43,7 +43,7 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
43 |
|
44 |
def transcribe(audio):
|
45 |
sr, audio = audio[0], audio[1]
|
46 |
-
return predict(audio, sr)
|
47 |
|
48 |
|
49 |
def get_asr_interface():
|
@@ -53,7 +53,7 @@ def get_asr_interface():
|
|
53 |
gr.inputs.Audio(source="upload", type="numpy")
|
54 |
],
|
55 |
outputs=[
|
56 |
-
"
|
57 |
])
|
58 |
|
59 |
interfaces = [
|
|
|
27 |
logits = model.to(device)(**inputs).logits
|
28 |
|
29 |
scores = F.softmax(logits, dim=1).detach().cpu().numpy()[0]
|
30 |
+
outputs = [{config.id2label[i]: f"{round(score * 100, 3):.1f}%"} for i, score in enumerate(scores)]
|
31 |
return outputs
|
32 |
|
33 |
|
|
|
43 |
|
44 |
def transcribe(audio):
|
45 |
sr, audio = audio[0], audio[1]
|
46 |
+
return predict(audio, sr)[0]
|
47 |
|
48 |
|
49 |
def get_asr_interface():
|
|
|
53 |
gr.inputs.Audio(source="upload", type="numpy")
|
54 |
],
|
55 |
outputs=[
|
56 |
+
"json"
|
57 |
])
|
58 |
|
59 |
interfaces = [
|