high77 commited on
Commit
b964169
·
verified ·
1 Parent(s): ba641e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -98,7 +98,7 @@ repo_id = "ai4Bharat/IndicF5"
98
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
99
  model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).to(device)
100
 
101
- # ---------- PRE-FETCH EXAMPLES (SAFE FOR GRADIO 4) ----------
102
  EXAMPLES = [
103
  {
104
  "audio_name": "ODIA_F (Neutral)",
@@ -120,15 +120,16 @@ EXAMPLES = [
120
  },
121
  ]
122
 
 
123
  for ex in EXAMPLES:
124
  sr, data = load_audio_from_url(ex["audio_url"])
125
- ex["sample_rate"] = sr
126
- ex["audio_data"] = data if data is not None else np.zeros((1,)) # never None
127
 
128
- # build Gradio examples list (skip broken downloads)
129
  examples = []
130
  for ex in EXAMPLES:
131
- if ex["audio_data"] is not None:
132
  examples.append([ex["synth_text"], (ex["sample_rate"], ex["audio_data"]), ex["ref_text"]])
133
 
134
  # ---------- GRADIO UI ----------
 
98
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
99
  model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).to(device)
100
 
101
+ # ---------- PRE-FETCH EXAMPLES (GRADIO 4-SAFE) ----------
102
  EXAMPLES = [
103
  {
104
  "audio_name": "ODIA_F (Neutral)",
 
120
  },
121
  ]
122
 
123
+ # download only valid audio
124
  for ex in EXAMPLES:
125
  sr, data = load_audio_from_url(ex["audio_url"])
126
+ ex["sample_rate"] = sr if sr is not None else 24_000
127
+ ex["audio_data"] = data if data is not None and len(data) > 0 else np.zeros(1_000) # small dummy
128
 
129
+ # build Gradio examples list (never contains None or zero-length audio)
130
  examples = []
131
  for ex in EXAMPLES:
132
+ if ex["audio_data"] is not None and len(ex["audio_data"]) > 0:
133
  examples.append([ex["synth_text"], (ex["sample_rate"], ex["audio_data"]), ex["ref_text"]])
134
 
135
  # ---------- GRADIO UI ----------