Update app.py
Browse files
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 (
|
| 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"]
|
| 127 |
|
| 128 |
-
# build Gradio examples list (
|
| 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 ----------
|