Update app.py
Browse files
app.py
CHANGED
@@ -45,19 +45,20 @@ def recc(a_f):
|
|
45 |
wav = torch.from_numpy(wav).unsqueeze(0)
|
46 |
if torch.cuda.is_available():
|
47 |
wav = wav.cuda()
|
48 |
-
input_values = processor(wav).input_values
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
|
51 |
|
52 |
bl = gr.Blocks()
|
53 |
with bl:
|
54 |
-
text_input = gr.Textbox()
|
55 |
-
text_output = gr.Textbox()
|
56 |
-
text_button = gr.Button("Run")
|
57 |
-
#text_button.click(show_ex, inputs=text_input, outputs=text_output)
|
58 |
-
|
59 |
audio_file = gr.Audio(type="filepath")
|
60 |
-
|
|
|
|
|
61 |
text_button.click(recc, inputs=audio_file, outputs=text_output)
|
62 |
|
63 |
|
|
|
45 |
wav = torch.from_numpy(wav).unsqueeze(0)
|
46 |
if torch.cuda.is_available():
|
47 |
wav = wav.cuda()
|
48 |
+
input_values = processor(wav,sampling_rate=16000).input_values[0]
|
49 |
+
input_values = torch.tensor(input_values, device=device).unsqueeze(0)
|
50 |
+
logits = model(input_values).logits
|
51 |
+
pred_ids = torch.argmax(logits, dim=-1)
|
52 |
+
xcp = processor.decode(pred_ids)
|
53 |
+
return xcp
|
54 |
|
55 |
|
56 |
bl = gr.Blocks()
|
57 |
with bl:
|
|
|
|
|
|
|
|
|
|
|
58 |
audio_file = gr.Audio(type="filepath")
|
59 |
+
text_button = gr.Button("Recognise")
|
60 |
+
text_output = gr.Textbox()
|
61 |
+
|
62 |
text_button.click(recc, inputs=audio_file, outputs=text_output)
|
63 |
|
64 |
|