Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ 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]
|
@@ -36,10 +36,12 @@ def parse(wav_file):
|
|
36 |
logits = model(**input_values).logits
|
37 |
return parse_transcription(logits)
|
38 |
|
39 |
-
|
|
|
40 |
processor = Wav2Vec2Processor.from_pretrained(model_id)
|
41 |
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
42 |
|
|
|
43 |
input_ = gr.Audio(source="microphone", type="filepath")
|
44 |
txtbox = gr.Textbox(
|
45 |
label="persian text output:",
|
@@ -53,12 +55,11 @@ txtbox = gr.Textbox(
|
|
53 |
|
54 |
title = "Speech-to-Text (persian)"
|
55 |
description = "Upload a prsian audio, and let AI do the hard work of transcribing."
|
56 |
-
article = "<p style='text-align: center'><a href='https://
|
|
|
57 |
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
demo.launch(share=True)
|
64 |
-
output = outpts
|
|
|
4 |
import gradio as gr
|
5 |
import sox
|
6 |
import subprocess
|
7 |
+
from fuzzywuzzy import fuzz
|
8 |
|
9 |
def read_file_and_process(wav_file):
|
10 |
filename = wav_file.split('.')[0]
|
|
|
36 |
logits = model(**input_values).logits
|
37 |
return parse_transcription(logits)
|
38 |
|
39 |
+
|
40 |
+
model_id = "jonatasgrosman/wav2vec2-large-xlsr-53-persian"
|
41 |
processor = Wav2Vec2Processor.from_pretrained(model_id)
|
42 |
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
43 |
|
44 |
+
|
45 |
input_ = gr.Audio(source="microphone", type="filepath")
|
46 |
txtbox = gr.Textbox(
|
47 |
label="persian text output:",
|
|
|
55 |
|
56 |
title = "Speech-to-Text (persian)"
|
57 |
description = "Upload a prsian audio, and let AI do the hard work of transcribing."
|
58 |
+
article = "<p style='text-align: center'><a href='https://github.com/nimaprgrmr'>Large-Scale Self- and Semi-Supervised Learning for Speech Translation</a></p>"
|
59 |
+
|
60 |
|
61 |
|
62 |
+
demo = gr.Interface(fn=parse, inputs = input_, outputs=txtbox, title=title, description=description, article = article,
|
63 |
+
streaming=True, interactive=True,
|
64 |
+
analytics_enabled=False, show_tips=False, enable_queue=True)
|
65 |
+
demo.launch(share=True)
|
|
|
|