Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,30 +9,30 @@ model = whisper.load_model("small")
|
|
9 |
|
10 |
|
11 |
#option 1
|
12 |
-
def transcribe(audio):
|
13 |
-
model = whisper.load_model("base")
|
14 |
-
result = model.transcribe(audio)
|
15 |
-
return result["text"]
|
16 |
-
|
17 |
-
#option 2
|
18 |
# def transcribe(audio):
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
#
|
21 |
-
#
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
|
38 |
def process_text(input_text):
|
@@ -73,7 +73,7 @@ with gr.Blocks() as demo:
|
|
73 |
|
74 |
b1 = gr.Button("Transcribe audio")
|
75 |
b2 = gr.Button("<Placeholder for the prompted action>")
|
76 |
-
#b3 = gr.Button("Email report to your doctor")
|
77 |
|
78 |
|
79 |
text1 = gr.Textbox(lines=5)
|
|
|
9 |
|
10 |
|
11 |
#option 1
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# def transcribe(audio):
|
13 |
+
# model = whisper.load_model("base")
|
14 |
+
# result = model.transcribe(audio)
|
15 |
+
# return result["text"]
|
16 |
+
|
17 |
+
option 2
|
18 |
+
def transcribe(audio):
|
19 |
|
20 |
+
#time.sleep(3)
|
21 |
+
# load audio and pad/trim it to fit 30 seconds
|
22 |
+
audio = whisper.load_audio(audio)
|
23 |
+
audio = whisper.pad_or_trim(audio)
|
24 |
+
|
25 |
+
# make log-Mel spectrogram and move to the same device as the model
|
26 |
+
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
27 |
+
|
28 |
+
# detect the spoken language
|
29 |
+
_, probs = model.detect_language(mel)
|
30 |
+
print(f"Detected language: {max(probs, key=probs.get)}")
|
31 |
+
|
32 |
+
# decode the audio
|
33 |
+
options = whisper.DecodingOptions(fp16 = False)
|
34 |
+
result = whisper.decode(model, mel, options)
|
35 |
+
return result.text
|
36 |
|
37 |
|
38 |
def process_text(input_text):
|
|
|
73 |
|
74 |
b1 = gr.Button("Transcribe audio")
|
75 |
b2 = gr.Button("<Placeholder for the prompted action>")
|
76 |
+
# b3 = gr.Button("Email report to your doctor")
|
77 |
|
78 |
|
79 |
text1 = gr.Textbox(lines=5)
|