geokanaan commited on
Commit
e8ff96d
·
verified ·
1 Parent(s): e95ce5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
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(stream, new_chunk):
14
- sr, y = new_chunk
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
- if stream is not None:
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
- ["state", gr.Audio(sources=["microphone"], streaming=True)],
33
- ["state", "text"],
34
- live=True,
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
  )