Update Space copy for PhaseB FP16 ONNX
Browse files- app.py +3 -3
- app.py.bak-phaseb-copy-20260619175220 +224 -0
app.py
CHANGED
|
@@ -152,8 +152,8 @@ def main() -> gr.Blocks:
|
|
| 152 |
<div id="visualears-root">
|
| 153 |
<div class="topbar">
|
| 154 |
<div>
|
| 155 |
-
<h1>VisualEars
|
| 156 |
-
<p class="subtle">Browser-only WebGPU decode with the
|
| 157 |
</div>
|
| 158 |
</div>
|
| 159 |
|
|
@@ -195,7 +195,7 @@ def main() -> gr.Blocks:
|
|
| 195 |
</div>
|
| 196 |
</div>
|
| 197 |
|
| 198 |
-
<div id="status" class="status">Idle. Load the FP16 model first; the first load downloads about
|
| 199 |
<div id="transcript" class="transcript">Final:
|
| 200 |
...
|
| 201 |
|
|
|
|
| 152 |
<div id="visualears-root">
|
| 153 |
<div class="topbar">
|
| 154 |
<div>
|
| 155 |
+
<h1>VisualEars PhaseB Persian ASR FP16</h1>
|
| 156 |
+
<p class="subtle">Browser-only WebGPU decode with the PhaseB FP16 ONNX export.</p>
|
| 157 |
</div>
|
| 158 |
</div>
|
| 159 |
|
|
|
|
| 195 |
</div>
|
| 196 |
</div>
|
| 197 |
|
| 198 |
+
<div id="status" class="status">Idle. Load the PhaseB FP16 model first; the first load downloads about 232 MB and then uses browser cache.</div>
|
| 199 |
<div id="transcript" class="transcript">Final:
|
| 200 |
...
|
| 201 |
|
app.py.bak-phaseb-copy-20260619175220
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
ROOT = Path(__file__).parent
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def main() -> gr.Blocks:
|
| 11 |
+
tokens = json.loads((ROOT / "tokens.json").read_text(encoding="utf-8"))
|
| 12 |
+
mel_filters = json.loads((ROOT / "mel_filters_slaney_80x257.json").read_text(encoding="utf-8"))
|
| 13 |
+
app_js = (ROOT / "app.js").read_text(encoding="utf-8")
|
| 14 |
+
head = (
|
| 15 |
+
"<script type=\"module\">\n"
|
| 16 |
+
f"window.VISUALEARS_TOKENS = {json.dumps(tokens, ensure_ascii=False)};\n"
|
| 17 |
+
f"window.VISUALEARS_MEL_FILTERS = {json.dumps(mel_filters, separators=(',', ':'))};\n"
|
| 18 |
+
f"{app_js}\n"
|
| 19 |
+
"</script>"
|
| 20 |
+
)
|
| 21 |
+
with gr.Blocks(
|
| 22 |
+
title="VisualEars WebGPU ASR",
|
| 23 |
+
head=head,
|
| 24 |
+
css="""
|
| 25 |
+
.gradio-container { max-width: 1180px !important; }
|
| 26 |
+
#visualears-root {
|
| 27 |
+
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| 28 |
+
color: #111827;
|
| 29 |
+
}
|
| 30 |
+
#visualears-root .topbar {
|
| 31 |
+
display: flex;
|
| 32 |
+
align-items: center;
|
| 33 |
+
justify-content: space-between;
|
| 34 |
+
gap: 16px;
|
| 35 |
+
margin-bottom: 16px;
|
| 36 |
+
}
|
| 37 |
+
#visualears-root h1 {
|
| 38 |
+
font-size: 28px;
|
| 39 |
+
line-height: 1.15;
|
| 40 |
+
margin: 0;
|
| 41 |
+
letter-spacing: 0;
|
| 42 |
+
}
|
| 43 |
+
#visualears-root .subtle {
|
| 44 |
+
color: #4b5563;
|
| 45 |
+
margin: 6px 0 0;
|
| 46 |
+
font-size: 14px;
|
| 47 |
+
}
|
| 48 |
+
#visualears-root .controls {
|
| 49 |
+
display: grid;
|
| 50 |
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
| 51 |
+
gap: 10px;
|
| 52 |
+
align-items: end;
|
| 53 |
+
margin: 14px 0;
|
| 54 |
+
}
|
| 55 |
+
#visualears-root button, #visualears-root select, #visualears-root input {
|
| 56 |
+
width: 100%;
|
| 57 |
+
min-height: 40px;
|
| 58 |
+
border: 1px solid #cbd5e1;
|
| 59 |
+
border-radius: 7px;
|
| 60 |
+
background: white;
|
| 61 |
+
color: #111827;
|
| 62 |
+
font: inherit;
|
| 63 |
+
padding: 8px 10px;
|
| 64 |
+
}
|
| 65 |
+
#visualears-root button.primary {
|
| 66 |
+
background: #111827;
|
| 67 |
+
color: white;
|
| 68 |
+
border-color: #111827;
|
| 69 |
+
}
|
| 70 |
+
#visualears-root button:disabled {
|
| 71 |
+
opacity: 0.45;
|
| 72 |
+
cursor: not-allowed;
|
| 73 |
+
}
|
| 74 |
+
#visualears-root label {
|
| 75 |
+
display: block;
|
| 76 |
+
font-size: 12px;
|
| 77 |
+
color: #475569;
|
| 78 |
+
margin-bottom: 5px;
|
| 79 |
+
}
|
| 80 |
+
#visualears-root .status {
|
| 81 |
+
min-height: 42px;
|
| 82 |
+
overflow-wrap: anywhere;
|
| 83 |
+
border: 1px solid #d1d5db;
|
| 84 |
+
background: #f8fafc;
|
| 85 |
+
border-radius: 7px;
|
| 86 |
+
padding: 10px 12px;
|
| 87 |
+
margin: 10px 0 14px;
|
| 88 |
+
}
|
| 89 |
+
#visualears-root .transcript {
|
| 90 |
+
min-height: 150px;
|
| 91 |
+
direction: rtl;
|
| 92 |
+
text-align: right;
|
| 93 |
+
font-size: 26px;
|
| 94 |
+
line-height: 1.65;
|
| 95 |
+
border: 1px solid #cbd5e1;
|
| 96 |
+
border-radius: 8px;
|
| 97 |
+
padding: 18px;
|
| 98 |
+
background: #ffffff;
|
| 99 |
+
overflow-wrap: anywhere;
|
| 100 |
+
white-space: pre-wrap;
|
| 101 |
+
}
|
| 102 |
+
#visualears-root .stats {
|
| 103 |
+
display: grid;
|
| 104 |
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
| 105 |
+
gap: 10px;
|
| 106 |
+
margin-top: 14px;
|
| 107 |
+
}
|
| 108 |
+
#visualears-root .stat {
|
| 109 |
+
border: 1px solid #d1d5db;
|
| 110 |
+
border-radius: 8px;
|
| 111 |
+
padding: 12px;
|
| 112 |
+
background: #ffffff;
|
| 113 |
+
min-height: 74px;
|
| 114 |
+
}
|
| 115 |
+
#visualears-root .stat b {
|
| 116 |
+
display: block;
|
| 117 |
+
font-size: 12px;
|
| 118 |
+
color: #64748b;
|
| 119 |
+
margin-bottom: 8px;
|
| 120 |
+
font-weight: 600;
|
| 121 |
+
}
|
| 122 |
+
#visualears-root .stat span {
|
| 123 |
+
font-size: 20px;
|
| 124 |
+
color: #111827;
|
| 125 |
+
overflow-wrap: anywhere;
|
| 126 |
+
}
|
| 127 |
+
#visualears-root .meter {
|
| 128 |
+
height: 8px;
|
| 129 |
+
background: #e5e7eb;
|
| 130 |
+
overflow: hidden;
|
| 131 |
+
border-radius: 999px;
|
| 132 |
+
margin-top: 8px;
|
| 133 |
+
}
|
| 134 |
+
#visualears-root .meter > div {
|
| 135 |
+
height: 100%;
|
| 136 |
+
width: 0%;
|
| 137 |
+
background: #10b981;
|
| 138 |
+
transition: width 120ms linear;
|
| 139 |
+
}
|
| 140 |
+
@media (max-width: 820px) {
|
| 141 |
+
#visualears-root .topbar { align-items: flex-start; flex-direction: column; }
|
| 142 |
+
#visualears-root .controls, #visualears-root .stats { grid-template-columns: 1fr 1fr; }
|
| 143 |
+
#visualears-root .transcript { font-size: 22px; }
|
| 144 |
+
}
|
| 145 |
+
@media (max-width: 520px) {
|
| 146 |
+
#visualears-root .controls, #visualears-root .stats { grid-template-columns: 1fr; }
|
| 147 |
+
}
|
| 148 |
+
""",
|
| 149 |
+
) as demo:
|
| 150 |
+
gr.HTML(
|
| 151 |
+
"""
|
| 152 |
+
<div id="visualears-root">
|
| 153 |
+
<div class="topbar">
|
| 154 |
+
<div>
|
| 155 |
+
<h1>VisualEars FA32M Persian ASR FP16</h1>
|
| 156 |
+
<p class="subtle">Browser-only WebGPU decode with the FA32M NeMo-fbank FP16 ONNX export.</p>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
|
| 160 |
+
<div class="controls">
|
| 161 |
+
<button id="load-model" class="primary">Load WebGPU model</button>
|
| 162 |
+
<button id="start-mic" disabled>Start mic</button>
|
| 163 |
+
<button id="stop-mic" disabled>Stop</button>
|
| 164 |
+
<div>
|
| 165 |
+
<label for="decode-every">Decode every</label>
|
| 166 |
+
<select id="decode-every">
|
| 167 |
+
<option value="1.5">1.5 s</option>
|
| 168 |
+
<option value="2.5" selected>2.5 s</option>
|
| 169 |
+
<option value="4">4 s</option>
|
| 170 |
+
</select>
|
| 171 |
+
</div>
|
| 172 |
+
<div>
|
| 173 |
+
<label for="window-seconds">Max utterance</label>
|
| 174 |
+
<select id="window-seconds">
|
| 175 |
+
<option value="8">8 s</option>
|
| 176 |
+
<option value="12" selected>12 s</option>
|
| 177 |
+
<option value="18">18 s</option>
|
| 178 |
+
<option value="20">20 s</option>
|
| 179 |
+
</select>
|
| 180 |
+
</div>
|
| 181 |
+
<div>
|
| 182 |
+
<label for="provider">Provider</label>
|
| 183 |
+
<select id="provider">
|
| 184 |
+
<option value="webgpu" selected>WebGPU</option>
|
| 185 |
+
<option value="wasm">WASM CPU fallback</option>
|
| 186 |
+
</select>
|
| 187 |
+
</div>
|
| 188 |
+
<div>
|
| 189 |
+
<label for="noise-gate">Speech gate</label>
|
| 190 |
+
<input id="noise-gate" type="range" min="0" max="0.04" value="0.006" step="0.001" />
|
| 191 |
+
</div>
|
| 192 |
+
<div>
|
| 193 |
+
<label>Input level</label>
|
| 194 |
+
<div class="meter"><div id="level-bar"></div></div>
|
| 195 |
+
</div>
|
| 196 |
+
</div>
|
| 197 |
+
|
| 198 |
+
<div id="status" class="status">Idle. Load the FP16 model first; the first load downloads about 61 MB and then uses browser cache.</div>
|
| 199 |
+
<div id="transcript" class="transcript">Final:
|
| 200 |
+
...
|
| 201 |
+
|
| 202 |
+
Partial:
|
| 203 |
+
...</div>
|
| 204 |
+
|
| 205 |
+
<div class="stats">
|
| 206 |
+
<div class="stat"><b>Decode Time</b><span id="stat-decode">-</span></div>
|
| 207 |
+
<div class="stat"><b>RTF</b><span id="stat-rtf">-</span></div>
|
| 208 |
+
<div class="stat"><b>Realtime Speed</b><span id="stat-speed">-</span></div>
|
| 209 |
+
<div class="stat"><b>Audio Window</b><span id="stat-audio">-</span></div>
|
| 210 |
+
<div class="stat"><b>Feature Frames</b><span id="stat-frames">-</span></div>
|
| 211 |
+
<div class="stat"><b>Provider</b><span id="stat-provider">-</span></div>
|
| 212 |
+
<div class="stat"><b>Heap Used</b><span id="stat-heap">-</span></div>
|
| 213 |
+
<div class="stat"><b>GPU Adapter</b><span id="stat-gpu">-</span></div>
|
| 214 |
+
<div class="stat"><b>Last Decode</b><span id="stat-last">-</span></div>
|
| 215 |
+
</div>
|
| 216 |
+
</div>
|
| 217 |
+
"""
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
return demo
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
if __name__ == "__main__":
|
| 224 |
+
main().launch()
|