Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,9 @@ processor_is = Wav2Vec2Processor.from_pretrained(MODEL_IS)
|
|
| 16 |
model_fo = Wav2Vec2ForCTC.from_pretrained(MODEL_FO).to(device)
|
| 17 |
processor_fo = Wav2Vec2Processor.from_pretrained(MODEL_FO)
|
| 18 |
|
| 19 |
-
|
| 20 |
pipe_is = pipeline(model=MODEL_IS)
|
|
|
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
def readwav(a_f):
|
|
@@ -42,11 +43,13 @@ def recc(audio_file,model,processor):
|
|
| 42 |
|
| 43 |
def recis(audio_file):
|
| 44 |
single_output = recc(audio_file,model_is,processor_is)
|
| 45 |
-
chunk_output = pipe_is(audio_file, chunk_length_s=
|
| 46 |
return (single_output, chunk_output)
|
| 47 |
|
| 48 |
def recfo(audio_file):
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
bl = gr.Blocks()
|
|
@@ -71,15 +74,17 @@ with bl:
|
|
| 71 |
audio_file = gr.Audio(type="filepath")
|
| 72 |
with gr.Column():
|
| 73 |
whole_output = gr.Textbox(label="whole-file recognition")
|
| 74 |
-
chunk_output = gr.Textbox("recognition with chunking")
|
| 75 |
text_button = gr.Button("Recognise Icelandic")
|
| 76 |
text_button.click(recis, inputs=audio_file, outputs=[whole_output,chunk_output])
|
| 77 |
with gr.TabItem("Faroese"):
|
| 78 |
with gr.Row():
|
| 79 |
audio_file = gr.Audio(type="filepath")
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
text_button = gr.Button("Recognise Faroese")
|
| 82 |
-
text_button.click(recfo, inputs=audio_file, outputs=
|
| 83 |
|
| 84 |
bl.launch()
|
| 85 |
|
|
|
|
| 16 |
model_fo = Wav2Vec2ForCTC.from_pretrained(MODEL_FO).to(device)
|
| 17 |
processor_fo = Wav2Vec2Processor.from_pretrained(MODEL_FO)
|
| 18 |
|
|
|
|
| 19 |
pipe_is = pipeline(model=MODEL_IS)
|
| 20 |
+
pipe_fo = pipeline(model=MODEL_FO)
|
| 21 |
+
|
| 22 |
|
| 23 |
|
| 24 |
def readwav(a_f):
|
|
|
|
| 43 |
|
| 44 |
def recis(audio_file):
|
| 45 |
single_output = recc(audio_file,model_is,processor_is)
|
| 46 |
+
chunk_output = pipe_is(audio_file, chunk_length_s=4)['text']
|
| 47 |
return (single_output, chunk_output)
|
| 48 |
|
| 49 |
def recfo(audio_file):
|
| 50 |
+
single_output = recc(audio_file,model_fo,processor_fo)
|
| 51 |
+
chunk_output = pipe_fo(audio_file, chunk_length_s=4)['text']
|
| 52 |
+
return (single_output, chunk_output)
|
| 53 |
|
| 54 |
|
| 55 |
bl = gr.Blocks()
|
|
|
|
| 74 |
audio_file = gr.Audio(type="filepath")
|
| 75 |
with gr.Column():
|
| 76 |
whole_output = gr.Textbox(label="whole-file recognition")
|
| 77 |
+
chunk_output = gr.Textbox(label="recognition with chunking")
|
| 78 |
text_button = gr.Button("Recognise Icelandic")
|
| 79 |
text_button.click(recis, inputs=audio_file, outputs=[whole_output,chunk_output])
|
| 80 |
with gr.TabItem("Faroese"):
|
| 81 |
with gr.Row():
|
| 82 |
audio_file = gr.Audio(type="filepath")
|
| 83 |
+
with gr.Column():
|
| 84 |
+
whole_output = gr.Textbox(label="whole-file recognition")
|
| 85 |
+
chunk_output = gr.Textbox(label="recognition with chunking")
|
| 86 |
text_button = gr.Button("Recognise Faroese")
|
| 87 |
+
text_button.click(recfo, inputs=audio_file, outputs=[whole_output,chunk_output])
|
| 88 |
|
| 89 |
bl.launch()
|
| 90 |
|