Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,11 @@ from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
|
4 |
import gradio as gr
|
5 |
import sox
|
6 |
import subprocess
|
|
|
7 |
|
8 |
|
|
|
|
|
9 |
def read_file_and_process(wav_file):
|
10 |
filename = wav_file.split('.')[0]
|
11 |
filename_16k = filename + "16k.wav"
|
@@ -34,7 +37,8 @@ def parse(wav_file):
|
|
34 |
input_values = read_file_and_process(wav_file)
|
35 |
with torch.no_grad():
|
36 |
logits = model(**input_values).logits
|
37 |
-
|
|
|
38 |
|
39 |
model_id = "jonatasgrosman/wav2vec2-large-xlsr-53-persian"
|
40 |
processor = Wav2Vec2Processor.from_pretrained(model_id)
|
|
|
4 |
import gradio as gr
|
5 |
import sox
|
6 |
import subprocess
|
7 |
+
from google_spell_checker import GoogleSpellChecker
|
8 |
|
9 |
|
10 |
+
spell_checker = GoogleSpellChecker(lang="fa")
|
11 |
+
|
12 |
def read_file_and_process(wav_file):
|
13 |
filename = wav_file.split('.')[0]
|
14 |
filename_16k = filename + "16k.wav"
|
|
|
37 |
input_values = read_file_and_process(wav_file)
|
38 |
with torch.no_grad():
|
39 |
logits = model(**input_values).logits
|
40 |
+
sentence = parse_transcription(logits)
|
41 |
+
return spell_checker.check(sentence)[1]
|
42 |
|
43 |
model_id = "jonatasgrosman/wav2vec2-large-xlsr-53-persian"
|
44 |
processor = Wav2Vec2Processor.from_pretrained(model_id)
|