Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,16 +2,24 @@ import os
|
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
title = "Transcribe speech
|
6 |
|
7 |
-
|
8 |
-
|
9 |
|
10 |
def transcribeFile(audio_path : str) -> str:
|
11 |
-
transcription =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
return transcription["text"]
|
13 |
|
14 |
|
|
|
15 |
app1 = gr.Interface(
|
16 |
fn=transcribeFile,
|
17 |
inputs=gr.inputs.Audio(label="Upload audio file", type="filepath"),
|
@@ -21,8 +29,9 @@ app1 = gr.Interface(
|
|
21 |
|
22 |
|
23 |
app2 = gr.Interface(
|
24 |
-
fn=
|
25 |
-
inputs=gr.
|
|
|
26 |
outputs="text",
|
27 |
title=title
|
28 |
)
|
|
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
title = "Transcribe speech several languages"
|
6 |
|
7 |
+
pipelineGE = pipeline(task="automatic-speech-recognition", model="jonatasgrosman/wav2vec2-large-xlsr-53-german")
|
8 |
+
pipelineEN = pipeline(task="automatic-speech-recognition", model="openai/whisper-large")
|
9 |
|
10 |
def transcribeFile(audio_path : str) -> str:
|
11 |
+
transcription = pipelineGE(audio_path)
|
12 |
+
return transcription["text"]
|
13 |
+
|
14 |
+
def transcribeFileMulti(inputlang, audio_path : str) -> str:
|
15 |
+
if inputlang == "English":
|
16 |
+
transcription = pipelineEN(audio_path)
|
17 |
+
elif inputlang == "German":
|
18 |
+
transcription = pipelineGE(audio_path)
|
19 |
return transcription["text"]
|
20 |
|
21 |
|
22 |
+
|
23 |
app1 = gr.Interface(
|
24 |
fn=transcribeFile,
|
25 |
inputs=gr.inputs.Audio(label="Upload audio file", type="filepath"),
|
|
|
29 |
|
30 |
|
31 |
app2 = gr.Interface(
|
32 |
+
fn=transcribeFileMulti,
|
33 |
+
inputs=[gr.Radio(["English", "German"], label="Source Language", info="Select the language of the speech you want to transcribe"),
|
34 |
+
gr.Audio(source="microphone", type="filepath")],
|
35 |
outputs="text",
|
36 |
title=title
|
37 |
)
|