Spaces:
badrex
/
Running on Zero

badrex commited on
Commit
e96836c
ยท
verified ยท
1 Parent(s): 5a8ee19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -5,19 +5,17 @@ import os
5
  from huggingface_hub import login
6
  import spaces
7
 
8
- # Get token from Space secrets
9
  HF_TOKEN = os.environ.get("HF_TOKEN")
10
  if HF_TOKEN:
11
  login(token=HF_TOKEN)
12
 
13
- # Load model from your private repo
14
- MODEL_ID = "badrex/JASR" # Change this to match your repo!
15
  transcriber = pipeline("automatic-speech-recognition", model=MODEL_ID)
16
 
17
  @spaces.GPU
18
  def transcribe(audio):
19
  sr, y = audio
20
- # Convert to mono if stereo
21
  if y.ndim > 1:
22
  y = y.mean(axis=1)
23
  y = y.astype(np.float32)
@@ -25,7 +23,6 @@ def transcribe(audio):
25
  return transcriber({"sampling_rate": sr, "raw": y})["text"]
26
 
27
 
28
- # Manually prepare example file paths without metadata
29
  examples = []
30
  examples_dir = "examples"
31
  if os.path.exists(examples_dir):
@@ -42,7 +39,6 @@ demo = gr.Interface(
42
  fn=transcribe,
43
  inputs=gr.Audio(),
44
  outputs="text",
45
- #theme="gstaff/sketch",
46
  title="JASR ๐Ÿ Dialectal Arabic Speech Recognition",
47
  description="""
48
  <div class="centered-content">
@@ -55,7 +51,8 @@ demo = gr.Interface(
55
  Marhaba ๐Ÿ‘‹๐Ÿผ
56
  <br>
57
  <br>
58
- This is a demo for JASR, pronounced <i>Jasir</i>, an automatic speech recognition system optimized for the regional dialects of <i>Jazirat al-Arab</i>, or the Arabian Peninsula. The model is a fine-tune of the speech foundation model <a href="https://huggingface.co/facebook/w2v-bert-2.0" style="color: #FF5349;">w2v-BERT 2.0</a>, a 580M pre-trained speech encoder.
 
59
  <br>
60
  <p style="font-size: 15px; line-height: 1.8;">
61
  Simply <strong>upload an audio file</strong> ๐Ÿ“ค or <strong>record yourself speaking</strong> ๐ŸŽ™๏ธโบ๏ธ to try out the model!
@@ -64,7 +61,7 @@ demo = gr.Interface(
64
  </div>
65
  """,
66
  examples=examples if examples else None,
67
- cache_examples=False, # Disable caching to avoid issues
68
  flagging_mode=None,
69
  )
70
 
 
5
  from huggingface_hub import login
6
  import spaces
7
 
 
8
  HF_TOKEN = os.environ.get("HF_TOKEN")
9
  if HF_TOKEN:
10
  login(token=HF_TOKEN)
11
 
12
+ MODEL_ID = "badrex/JASR"
 
13
  transcriber = pipeline("automatic-speech-recognition", model=MODEL_ID)
14
 
15
  @spaces.GPU
16
  def transcribe(audio):
17
  sr, y = audio
18
+ # convert to mono if stereo
19
  if y.ndim > 1:
20
  y = y.mean(axis=1)
21
  y = y.astype(np.float32)
 
23
  return transcriber({"sampling_rate": sr, "raw": y})["text"]
24
 
25
 
 
26
  examples = []
27
  examples_dir = "examples"
28
  if os.path.exists(examples_dir):
 
39
  fn=transcribe,
40
  inputs=gr.Audio(),
41
  outputs="text",
 
42
  title="JASR ๐Ÿ Dialectal Arabic Speech Recognition",
43
  description="""
44
  <div class="centered-content">
 
51
  Marhaba ๐Ÿ‘‹๐Ÿผ
52
  <br>
53
  <br>
54
+ This is a demo for JASR, pronounced <i>Jasir</i>, a Transformer-based automatic speech recognition (ASR) system for dialectal Arabic.
55
+ The current running instance is optimized for the regional dialects of <i>Jazirat al-Arab</i>, or the Arabian Peninsula.
56
  <br>
57
  <p style="font-size: 15px; line-height: 1.8;">
58
  Simply <strong>upload an audio file</strong> ๐Ÿ“ค or <strong>record yourself speaking</strong> ๐ŸŽ™๏ธโบ๏ธ to try out the model!
 
61
  </div>
62
  """,
63
  examples=examples if examples else None,
64
+ cache_examples=False,
65
  flagging_mode=None,
66
  )
67