geokanaan commited on
Commit
2c0f3d8
·
1 Parent(s): 39c68a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -5,9 +5,11 @@ import os
5
 
6
  pipe = pipeline(task="automatic-speech-recognition", model="geokanaan/Whisper_Base_Lebanese_Arabizi")
7
  def transcribe(audio):
8
- text = pipe(audio)
9
- return text["text"]
 
10
 
 
11
 
12
  HF_TOKEN = os.getenv('WRITE')
13
  #hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "geokanaan/flagged_Audio_Lebanese")
@@ -15,7 +17,7 @@ HF_TOKEN = os.getenv('WRITE')
15
  iface = gr.Interface(
16
  fn=transcribe,
17
  inputs=[
18
- gr.Audio(sources="microphone",type= "filepath")
19
  ],
20
  outputs="text",
21
  title="arabeasy",
 
5
 
6
  pipe = pipeline(task="automatic-speech-recognition", model="geokanaan/Whisper_Base_Lebanese_Arabizi")
7
  def transcribe(audio):
8
+ sr, y = audio
9
+ y = y.astype(np.float32)
10
+ y /= np.max(np.abs(y))
11
 
12
+ return pipe({"sampling_rate": sr, "raw": y})["text"]
13
 
14
  HF_TOKEN = os.getenv('WRITE')
15
  #hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "geokanaan/flagged_Audio_Lebanese")
 
17
  iface = gr.Interface(
18
  fn=transcribe,
19
  inputs=[
20
+ gr.Audio(sources="microphone")
21
  ],
22
  outputs="text",
23
  title="arabeasy",