Spaces:
Sleeping
Sleeping
sotirios-slv
commited on
Commit
•
ce1af45
1
Parent(s):
b802d71
Tidied up the app
Browse files
app.py
CHANGED
@@ -17,19 +17,12 @@ description = """
|
|
17 |
|
18 |
diction_text = "How now brown cow"
|
19 |
|
20 |
-
test_text = f"""
|
21 |
-
<div>
|
22 |
-
<p>{diction_text}</p>
|
23 |
-
</div>
|
24 |
-
"""
|
25 |
-
|
26 |
-
# diction = gr.HTML(test_text)
|
27 |
|
28 |
diction_script = gr.Textbox(diction_text, interactive=False)
|
29 |
|
30 |
|
31 |
device = "cpu"
|
32 |
-
|
33 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
34 |
|
35 |
model_id = "openai/whisper-large-v3"
|
@@ -56,23 +49,19 @@ pipe = pipeline(
|
|
56 |
)
|
57 |
|
58 |
|
59 |
-
def diff_texts(audio_input: str):
|
60 |
-
|
61 |
d = Differ()
|
62 |
|
63 |
return [
|
64 |
(token[2:], token[0] if token[0] != "" else None)
|
65 |
-
for token in d.compare(
|
66 |
]
|
67 |
|
68 |
|
69 |
-
def transcribe_audio(
|
70 |
-
print("Diction", diction)
|
71 |
result = pipe(audio)
|
72 |
-
|
73 |
-
diff_text = diff_texts(result["text"])
|
74 |
-
|
75 |
-
print("diff", diff_text)
|
76 |
|
77 |
return diff_text
|
78 |
|
@@ -105,16 +94,6 @@ demo = gr.Interface(
|
|
105 |
theme="abidlabs/Lime",
|
106 |
)
|
107 |
|
108 |
-
# with gr.Blocks() as demo:
|
109 |
-
# gr.HTML(description)
|
110 |
-
# gr.HTML(test_text)
|
111 |
-
|
112 |
-
# with gr.Row():
|
113 |
-
# inp = input_audio
|
114 |
-
# out = highlighted_results
|
115 |
-
# btn = gr.Button("Run")
|
116 |
-
# btn.click(fn=transcribe_audio, inputs=[diction_script, inp], outputs=out)
|
117 |
-
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
demo.launch()
|
|
|
17 |
|
18 |
diction_text = "How now brown cow"
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
diction_script = gr.Textbox(diction_text, interactive=False)
|
22 |
|
23 |
|
24 |
device = "cpu"
|
25 |
+
|
26 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
27 |
|
28 |
model_id = "openai/whisper-large-v3"
|
|
|
49 |
)
|
50 |
|
51 |
|
52 |
+
def diff_texts(diction_text: str, audio_input: str):
|
53 |
+
|
54 |
d = Differ()
|
55 |
|
56 |
return [
|
57 |
(token[2:], token[0] if token[0] != "" else None)
|
58 |
+
for token in d.compare(diction_text, audio_input)
|
59 |
]
|
60 |
|
61 |
|
62 |
+
def transcribe_audio(diction_text, audio):
|
|
|
63 |
result = pipe(audio)
|
64 |
+
diff_text = diff_texts(diction_text, result["text"])
|
|
|
|
|
|
|
65 |
|
66 |
return diff_text
|
67 |
|
|
|
94 |
theme="abidlabs/Lime",
|
95 |
)
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
if __name__ == "__main__":
|
99 |
demo.launch()
|