Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import whisper
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model = whisper.load_model("large")
|
5 |
+
|
6 |
+
def transcribe(audio):
|
7 |
+
|
8 |
+
#time.sleep(3)
|
9 |
+
# load audio and pad/trim it to fit 30 seconds
|
10 |
+
audio = whisper.load_audio(audio)
|
11 |
+
audio = whisper.pad_or_trim(audio)
|
12 |
+
|
13 |
+
# make log-Mel spectrogram and move to the same device as the model
|
14 |
+
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
15 |
+
|
16 |
+
# detect the spoken language
|
17 |
+
_, probs = model.detect_language(mel)
|
18 |
+
|
19 |
+
# decode the audio
|
20 |
+
options = whisper.DecodingOptions(fp16 = False,language="de")
|
21 |
+
result = whisper.decode(model, mel, options)
|
22 |
+
return result.text
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
gr.Interface(
|
27 |
+
title = 'Automatische Spracherkennung',
|
28 |
+
fn=transcribe,
|
29 |
+
inputs=[
|
30 |
+
gr.inputs.Audio(source="microphone", type="filepath")
|
31 |
+
],
|
32 |
+
outputs=[
|
33 |
+
"textbox"
|
34 |
+
],
|
35 |
+
live=True).launch()
|
36 |
+
|