Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,18 +18,18 @@ def load_data(input_file):
|
|
18 |
speech = librosa.resample(speech, sample_rate, 16000)
|
19 |
return speech
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
|
35 |
gr.Interface(asr_transcript,
|
|
|
18 |
speech = librosa.resample(speech, sample_rate, 16000)
|
19 |
return speech
|
20 |
|
21 |
+
def correct_casing(input_sentence):
|
22 |
+
sentences = nltk.sent_tokenize(input_sentence)
|
23 |
+
return (' '.join([s.replace(s[0],s[0].capitalize(),1) for s in sentences]))
|
24 |
|
25 |
+
def asr_transcript(input_file):
|
26 |
+
speech = load_data(input_file)
|
27 |
+
input_values = tokenizer(speech, return_tensors="pt").input_values
|
28 |
+
logits = model(input_values).logits
|
29 |
+
predicted_ids = torch.argmax(logits, dim=-1)
|
30 |
+
transcription = tokenizer.decode(predicted_ids[0])
|
31 |
+
transcription = correct_casing(transcription.lower())
|
32 |
+
return transcription
|
33 |
|
34 |
|
35 |
gr.Interface(asr_transcript,
|