Spaces:
Build error
Build error
updt
Browse files
app.py
CHANGED
@@ -1,42 +1,43 @@
|
|
1 |
import os
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
4 |
-
#try:
|
5 |
-
# import tensorflow # required in Colab to avoid protobuf compatibility issues
|
6 |
-
#except ImportError:
|
7 |
-
# pass
|
8 |
-
|
9 |
-
#import torch
|
10 |
-
#import pandas as pd
|
11 |
import whisper
|
12 |
-
#import torchaudio
|
13 |
-
|
14 |
-
#from tqdm.notebook import tqdm
|
15 |
-
|
16 |
|
17 |
-
#DEVICE = "cuda" if torch.cuda.is_available() else "CPU"
|
18 |
model = whisper.load_model("base.en")
|
19 |
|
20 |
-
def fun(audio):
|
21 |
-
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
#
|
30 |
-
|
31 |
-
#
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
gr.Interface(
|
34 |
title = 'Testing Whisper',
|
35 |
fn=fun,
|
36 |
inputs=[
|
37 |
-
gr.inputs.Audio(source="microphone", streaming =
|
|
|
38 |
],
|
39 |
outputs=[
|
40 |
-
"textbox"
|
41 |
],
|
42 |
live=True).launch()
|
|
|
1 |
import os
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import whisper
|
|
|
|
|
|
|
|
|
5 |
|
|
|
6 |
model = whisper.load_model("base.en")
|
7 |
|
8 |
+
def fun(audio, state=''):
|
9 |
+
text = model.transcribe(audio)["text"]
|
10 |
+
state += text + " "
|
11 |
+
return state, state
|
12 |
|
13 |
+
def transcribe(audio, state=""):
|
14 |
+
text = p(audio)["text"]
|
15 |
+
state += text + " "
|
16 |
+
return state, state
|
17 |
+
|
18 |
+
# Set the starting state to an empty string
|
19 |
+
|
20 |
+
#gr.Interface(
|
21 |
+
# fn=transcribe,
|
22 |
+
# inputs=[
|
23 |
+
# gr.Audio(source="microphone", type="filepath", streaming=True),
|
24 |
+
# "state"
|
25 |
+
# ],
|
26 |
+
# outputs=[
|
27 |
+
# "textbox",
|
28 |
+
# "state"
|
29 |
+
# ],
|
30 |
+
# live=True).launch()
|
31 |
+
|
32 |
+
|
33 |
gr.Interface(
|
34 |
title = 'Testing Whisper',
|
35 |
fn=fun,
|
36 |
inputs=[
|
37 |
+
gr.inputs.Audio(source="microphone", streaming = True, type="filepath"),
|
38 |
+
"state"
|
39 |
],
|
40 |
outputs=[
|
41 |
+
"textbox", "state"
|
42 |
],
|
43 |
live=True).launch()
|