Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ transcriber = pipeline(task="automatic-speech-recognition", model="geokanaan/Whi
|
|
10 |
HF_TOKEN = os.getenv('WRITE')
|
11 |
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "flagged_Audio_Lebanese")
|
12 |
|
13 |
-
def transcribe(
|
14 |
-
sr, y =
|
15 |
|
16 |
# Convert to mono if stereo
|
17 |
if y.ndim > 1:
|
@@ -20,19 +20,14 @@ def transcribe(stream, new_chunk):
|
|
20 |
y = y.astype(np.float32)
|
21 |
y /= np.max(np.abs(y))
|
22 |
|
23 |
-
|
24 |
-
stream = np.concatenate([stream, y])
|
25 |
-
else:
|
26 |
-
stream = y
|
27 |
-
return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"]
|
28 |
|
29 |
|
30 |
demo = gr.Interface(
|
31 |
transcribe,
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
title="UNDER MAINTENANCE",
|
36 |
description="Realtime demo for Lebanese Arabizi speech recognition",
|
37 |
allow_flagging='manual', # Enable manual flagging
|
38 |
)
|
|
|
10 |
HF_TOKEN = os.getenv('WRITE')
|
11 |
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "flagged_Audio_Lebanese")
|
12 |
|
13 |
+
def transcribe(audio):
|
14 |
+
sr, y = audio
|
15 |
|
16 |
# Convert to mono if stereo
|
17 |
if y.ndim > 1:
|
|
|
20 |
y = y.astype(np.float32)
|
21 |
y /= np.max(np.abs(y))
|
22 |
|
23 |
+
return transcriber({"sampling_rate": sr, "raw": y})["text"]
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
demo = gr.Interface(
|
27 |
transcribe,
|
28 |
+
gr.Audio(sources=["microphone"],
|
29 |
+
"text",
|
30 |
+
title="Arabeasy",
|
|
|
31 |
description="Realtime demo for Lebanese Arabizi speech recognition",
|
32 |
allow_flagging='manual', # Enable manual flagging
|
33 |
)
|