Upgrade
Browse files
app.py
CHANGED
@@ -1,23 +1,21 @@
|
|
1 |
-
import os
|
2 |
-
os.system("pip install git+https://github.com/openai/whisper.git")
|
3 |
import gradio as gr
|
4 |
-
import whisper
|
5 |
|
6 |
-
|
7 |
|
8 |
def inference(audio):
|
9 |
-
audio = whisper.load_audio(audio)
|
10 |
-
audio = whisper.pad_or_trim(audio)
|
11 |
|
12 |
-
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
13 |
|
14 |
-
_, probs = model.detect_language(mel)
|
15 |
|
16 |
-
options = whisper.DecodingOptions(fp16 = False)
|
17 |
-
result = whisper.decode(model, mel, options)
|
18 |
|
19 |
-
print(result.text)
|
20 |
-
return result.text
|
|
|
21 |
|
22 |
article = """
|
23 |
## εθ
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
whisper = gr.load("models/openai/whisper-small")
|
4 |
|
5 |
def inference(audio):
|
6 |
+
# audio = whisper.load_audio(audio)
|
7 |
+
# audio = whisper.pad_or_trim(audio)
|
8 |
|
9 |
+
# mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
10 |
|
11 |
+
# _, probs = model.detect_language(mel)
|
12 |
|
13 |
+
# options = whisper.DecodingOptions(fp16 = False)
|
14 |
+
# result = whisper.decode(model, mel, options)
|
15 |
|
16 |
+
# print(result.text)
|
17 |
+
# return result.text
|
18 |
+
return whisper(audio).replace("AutomaticSpeechRecognitionOutput(text=' ", "").replace("', chunks=None)", "")
|
19 |
|
20 |
article = """
|
21 |
## εθ
|