Spaces:
Runtime error
Runtime error
Edgar
commited on
Commit
•
0b45694
1
Parent(s):
1b903b1
Added app.py
Browse files- app.py +38 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import whisper
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
import time
|
5 |
+
|
6 |
+
|
7 |
+
# You can choose your model from - see it on readme file and update the modelname
|
8 |
+
modelname = "large-v2"
|
9 |
+
model = whisper.load_model(modelname)
|
10 |
+
|
11 |
+
def SpeechToText(audio):
|
12 |
+
if audio == None : return ""
|
13 |
+
time.sleep(1)
|
14 |
+
|
15 |
+
audio = whisper.load_audio(audio)
|
16 |
+
audio = whisper.pad_or_trim(audio)
|
17 |
+
|
18 |
+
# Decode audio to Text
|
19 |
+
# options = whisper.DecodingOptions(fp16 = False)
|
20 |
+
result = model.transcribe(audio, language="hy")
|
21 |
+
return result["text"]
|
22 |
+
|
23 |
+
|
24 |
+
gr.Interface(
|
25 |
+
title = 'OpenAI Whisper implementation on Gradio Web UI',
|
26 |
+
fn=SpeechToText,
|
27 |
+
|
28 |
+
inputs=[
|
29 |
+
gr.Audio(source="microphone", type="filepath")
|
30 |
+
],
|
31 |
+
outputs=[
|
32 |
+
"textbox",
|
33 |
+
],
|
34 |
+
live=True
|
35 |
+
).launch(
|
36 |
+
debug=False,
|
37 |
+
share=True
|
38 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
--extra-index-url https://download.pytorch.org/whl/cu116
|
2 |
+
torch
|
3 |
+
git+https://github.com/openai/whisper.git
|