Spaces:
Running
Running
improve ui look
Browse files- app/static/index.html +167 -156
app/static/index.html
CHANGED
@@ -4,61 +4,110 @@
|
|
4 |
<meta charset="UTF-8" />
|
5 |
<title>🎤 Real-Time ASR Demo</title>
|
6 |
<style>
|
7 |
-
/*
|
8 |
-
#transcript {
|
9 |
-
white-space: pre-wrap;
|
10 |
-
overflow-y: auto;
|
11 |
-
}
|
12 |
-
|
13 |
-
/* Finalized utterances in green, with a bit of right-margin */
|
14 |
-
#transcript .final {
|
15 |
-
color: green;
|
16 |
-
display: inline;
|
17 |
-
margin-right: 0.5em;
|
18 |
-
}
|
19 |
-
|
20 |
-
/* Interim utterance in red */
|
21 |
-
#transcript .interim {
|
22 |
-
color: red;
|
23 |
-
display: inline;
|
24 |
-
}
|
25 |
body {
|
26 |
font-family: "Segoe UI", sans-serif;
|
27 |
background-color: #f5f6fa;
|
28 |
-
display: flex;
|
29 |
-
flex-direction: column;
|
30 |
-
align-items: center;
|
31 |
-
justify-content: center;
|
32 |
-
min-height: 100vh;
|
33 |
margin: 0;
|
34 |
padding: 2rem;
|
35 |
color: #2f3640;
|
|
|
|
|
|
|
36 |
}
|
37 |
-
|
38 |
h1 {
|
39 |
-
margin-bottom: 1rem;
|
40 |
font-size: 2rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
#hotwordStatus {
|
|
|
45 |
font-size: 0.9rem;
|
46 |
color: #e1b12c;
|
47 |
font-weight: bold;
|
|
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
#vol {
|
51 |
-
width:
|
|
|
52 |
height: 20px;
|
53 |
-
margin-
|
54 |
appearance: none;
|
55 |
}
|
56 |
-
|
57 |
#vol::-webkit-progress-bar {
|
58 |
background-color: #dcdde1;
|
59 |
border-radius: 8px;
|
60 |
}
|
61 |
-
|
62 |
#vol::-webkit-progress-value {
|
63 |
background-color: #44bd32;
|
64 |
border-radius: 8px;
|
@@ -70,90 +119,40 @@
|
|
70 |
transition: width 0.2s;
|
71 |
}
|
72 |
|
73 |
-
|
74 |
-
width: 90%;
|
75 |
-
max-width: 800px;
|
76 |
-
text-align: left;
|
77 |
-
margin-top: 2rem;
|
78 |
-
background: white;
|
79 |
-
padding: 1rem 1.5rem;
|
80 |
-
border-radius: 10px;
|
81 |
-
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
82 |
-
display: flex;
|
83 |
-
flex-direction: column;
|
84 |
-
}
|
85 |
.transcript-container {
|
86 |
-
flex: 1; /* take remaining vertical space */
|
87 |
-
max-height: 300px; /* adjust as you like */
|
88 |
margin-top: 0.5rem;
|
89 |
padding: 0.5rem;
|
90 |
background: #fff;
|
91 |
border: 1px solid #dcdde1;
|
92 |
border-radius: 8px;
|
93 |
-
|
94 |
-
|
|
|
95 |
font-size: 1.1rem;
|
96 |
color: #353b48;
|
97 |
}
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
.controls {
|
105 |
-
display: flex;
|
106 |
-
gap: 1rem;
|
107 |
-
margin-bottom: 1rem;
|
108 |
-
align-items: center;
|
109 |
-
}
|
110 |
-
.controls label {
|
111 |
-
font-weight: bold;
|
112 |
-
color: #2f3640;
|
113 |
-
}
|
114 |
-
.controls select,
|
115 |
-
.controls input[type="range"] {
|
116 |
-
width: 150px;
|
117 |
-
}
|
118 |
-
.controls textarea {
|
119 |
-
padding: 0.3rem;
|
120 |
-
border-radius: 5px;
|
121 |
-
border: 1px solid #dcdde1;
|
122 |
-
background: white;
|
123 |
-
font-size: 1rem;
|
124 |
-
}
|
125 |
-
.controls textarea {
|
126 |
-
flex: 1;
|
127 |
-
resize: vertical;
|
128 |
-
min-height: 4rem;
|
129 |
-
}
|
130 |
-
|
131 |
-
.model-info {
|
132 |
-
margin-bottom: 1rem;
|
133 |
-
font-size: 0.9rem;
|
134 |
-
color: #353b48;
|
135 |
-
}
|
136 |
-
.model-info span {
|
137 |
-
font-weight: bold;
|
138 |
-
}
|
139 |
-
|
140 |
-
.mic-info {
|
141 |
-
margin-bottom: 1rem;
|
142 |
-
font-size: 0.9rem;
|
143 |
-
color: #353b48;
|
144 |
}
|
145 |
-
.
|
146 |
-
|
|
|
147 |
}
|
148 |
</style>
|
149 |
</head>
|
150 |
<body>
|
151 |
-
<h1>🎤 Speak into
|
152 |
-
|
153 |
-
<
|
154 |
-
<
|
155 |
-
<
|
156 |
-
<
|
|
|
|
|
|
|
157 |
<option value="pfluo/k2fsa-zipformer-chinese-english-mixed">k2fsa-chinese-english-mixed</option>
|
158 |
<option value="k2-fsa/sherpa-onnx-streaming-zipformer-korean-2024-06-16">sherpa-onnx-zipformer-korean</option>
|
159 |
<option value="k2-fsa/sherpa-onnx-streaming-zipformer-multi-zh-hans-2023-12-12">zipformer-multi-zh-hans</option>
|
@@ -166,61 +165,73 @@
|
|
166 |
<option value="csukuangfj/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23">zipformer-zh-14M</option>
|
167 |
<option value="csukuangfj/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17">zipformer-en-20M</option>
|
168 |
<option value="csukuangfj/sherpa-onnx-streaming-zipformer-ar_en_id_ja_ru_th_vi_zh-2025-02-10">zipformer-ar_en_id_ja_ru_th_vi_zh</option>
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
<
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
<
|
204 |
-
<
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
<script>
|
226 |
const MODEL_METADATA = {
|
|
|
4 |
<meta charset="UTF-8" />
|
5 |
<title>🎤 Real-Time ASR Demo</title>
|
6 |
<style>
|
7 |
+
/* Page layout */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
body {
|
9 |
font-family: "Segoe UI", sans-serif;
|
10 |
background-color: #f5f6fa;
|
|
|
|
|
|
|
|
|
|
|
11 |
margin: 0;
|
12 |
padding: 2rem;
|
13 |
color: #2f3640;
|
14 |
+
display: flex;
|
15 |
+
flex-direction: column;
|
16 |
+
align-items: center;
|
17 |
}
|
|
|
18 |
h1 {
|
|
|
19 |
font-size: 2rem;
|
20 |
+
margin-bottom: 1rem;
|
21 |
+
}
|
22 |
+
section {
|
23 |
+
width: 100%;
|
24 |
+
max-width: 900px;
|
25 |
+
margin-bottom: 1.5rem;
|
26 |
+
background: white;
|
27 |
+
border-radius: 8px;
|
28 |
+
padding: 1rem;
|
29 |
+
box-shadow: 0 0 8px rgba(0,0,0,0.1);
|
30 |
+
}
|
31 |
+
section h2 {
|
32 |
+
margin-top: 0;
|
33 |
+
font-size: 1.2rem;
|
34 |
+
border-bottom: 1px solid #dcdde1;
|
35 |
+
padding-bottom: 0.5rem;
|
36 |
+
color: #2f3640;
|
37 |
+
}
|
38 |
+
|
39 |
+
/* Grid for controls */
|
40 |
+
.controls-grid {
|
41 |
+
display: grid;
|
42 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
43 |
+
gap: 1rem;
|
44 |
+
margin-top: 1rem;
|
45 |
+
}
|
46 |
+
.control-item {
|
47 |
+
display: flex;
|
48 |
+
flex-direction: column;
|
49 |
+
}
|
50 |
+
.control-item > label {
|
51 |
+
font-weight: 600;
|
52 |
+
margin-bottom: 0.3rem;
|
53 |
+
}
|
54 |
+
.control-item > select,
|
55 |
+
.control-item > input,
|
56 |
+
.control-item > textarea {
|
57 |
+
padding: 0.5rem;
|
58 |
+
border: 1px solid #dcdde1;
|
59 |
+
border-radius: 5px;
|
60 |
+
font-size: 1rem;
|
61 |
+
background: white;
|
62 |
}
|
63 |
+
.control-item > textarea {
|
64 |
+
resize: vertical;
|
65 |
+
min-height: 4rem;
|
66 |
+
}
|
67 |
+
.control-item > button {
|
68 |
+
margin-top: 0.5rem;
|
69 |
+
padding: 0.5rem;
|
70 |
+
border: none;
|
71 |
+
border-radius: 5px;
|
72 |
+
background-color: #44bd32;
|
73 |
+
color: white;
|
74 |
+
font-size: 1rem;
|
75 |
+
cursor: pointer;
|
76 |
+
transition: background-color 0.2s;
|
77 |
+
}
|
78 |
+
.control-item > button:hover {
|
79 |
+
background-color: #4cd137;
|
80 |
+
}
|
81 |
+
|
82 |
+
/* Status text */
|
83 |
#hotwordStatus {
|
84 |
+
margin-top: 0.5rem;
|
85 |
font-size: 0.9rem;
|
86 |
color: #e1b12c;
|
87 |
font-weight: bold;
|
88 |
+
text-align: center;
|
89 |
}
|
90 |
|
91 |
+
/* Mic info and volume */
|
92 |
+
.mic-info {
|
93 |
+
font-size: 0.9rem;
|
94 |
+
color: #353b48;
|
95 |
+
margin-top: 1rem;
|
96 |
+
}
|
97 |
+
.mic-info .label {
|
98 |
+
font-weight: bold;
|
99 |
+
}
|
100 |
#vol {
|
101 |
+
width: 100%;
|
102 |
+
max-width: 500px;
|
103 |
height: 20px;
|
104 |
+
margin-top: 0.5rem;
|
105 |
appearance: none;
|
106 |
}
|
|
|
107 |
#vol::-webkit-progress-bar {
|
108 |
background-color: #dcdde1;
|
109 |
border-radius: 8px;
|
110 |
}
|
|
|
111 |
#vol::-webkit-progress-value {
|
112 |
background-color: #44bd32;
|
113 |
border-radius: 8px;
|
|
|
119 |
transition: width 0.2s;
|
120 |
}
|
121 |
|
122 |
+
/* Transcript */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
.transcript-container {
|
|
|
|
|
124 |
margin-top: 0.5rem;
|
125 |
padding: 0.5rem;
|
126 |
background: #fff;
|
127 |
border: 1px solid #dcdde1;
|
128 |
border-radius: 8px;
|
129 |
+
max-height: 300px;
|
130 |
+
overflow-y: auto;
|
131 |
+
white-space: pre-wrap;
|
132 |
font-size: 1.1rem;
|
133 |
color: #353b48;
|
134 |
}
|
135 |
+
.transcript-container .final {
|
136 |
+
color: green;
|
137 |
+
display: inline;
|
138 |
+
margin-right: 0.5em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
+
.transcript-container .interim {
|
141 |
+
color: red;
|
142 |
+
display: inline;
|
143 |
}
|
144 |
</style>
|
145 |
</head>
|
146 |
<body>
|
147 |
+
<h1>🎤 Speak into Your Microphone</h1>
|
148 |
+
|
149 |
+
<section class="section--settings">
|
150 |
+
<h2>Recognition Settings</h2>
|
151 |
+
<div class="controls-grid">
|
152 |
+
<div class="control-item">
|
153 |
+
<label for="modelSelect">Model</label>
|
154 |
+
<select id="modelSelect">
|
155 |
+
<option value="csukuangfj/k2fsa-zipformer-bilingual-zh-en-t">k2fsa-small-bilingual-zh-en</option>
|
156 |
<option value="pfluo/k2fsa-zipformer-chinese-english-mixed">k2fsa-chinese-english-mixed</option>
|
157 |
<option value="k2-fsa/sherpa-onnx-streaming-zipformer-korean-2024-06-16">sherpa-onnx-zipformer-korean</option>
|
158 |
<option value="k2-fsa/sherpa-onnx-streaming-zipformer-multi-zh-hans-2023-12-12">zipformer-multi-zh-hans</option>
|
|
|
165 |
<option value="csukuangfj/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23">zipformer-zh-14M</option>
|
166 |
<option value="csukuangfj/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17">zipformer-en-20M</option>
|
167 |
<option value="csukuangfj/sherpa-onnx-streaming-zipformer-ar_en_id_ja_ru_th_vi_zh-2025-02-10">zipformer-ar_en_id_ja_ru_th_vi_zh</option>
|
168 |
+
</select>
|
169 |
+
</div>
|
170 |
+
<div class="control-item">
|
171 |
+
<label for="precisionSelect">Precision</label>
|
172 |
+
<select id="precisionSelect">
|
173 |
+
<option value="fp32">FP32</option>
|
174 |
+
<option value="int8">INT8</option>
|
175 |
+
</select>
|
176 |
+
</div>
|
177 |
+
</div>
|
178 |
+
<div class="model-info">
|
179 |
+
Languages: <span id="modelLangs"></span> | Size: <span id="modelSize"></span> MB
|
180 |
+
</div>
|
181 |
+
</section>
|
182 |
+
|
183 |
+
<section class="section--hotwords">
|
184 |
+
<h2>Hotword Settings</h2>
|
185 |
+
<div class="controls-grid">
|
186 |
+
<div class="control-item">
|
187 |
+
<label for="hotwordsList">Hotwords</label>
|
188 |
+
<textarea id="hotwordsList" placeholder="One per line"></textarea>
|
189 |
+
</div>
|
190 |
+
<div class="control-item">
|
191 |
+
<label for="boostScore">Boost Score: <span id="boostValue">2.0</span></label>
|
192 |
+
<input type="range" id="boostScore" min="0" max="10" step="0.1" value="2.0" />
|
193 |
+
</div>
|
194 |
+
<div class="control-item">
|
195 |
+
<button id="applyHotwords">Apply Hotwords</button>
|
196 |
+
</div>
|
197 |
+
</div>
|
198 |
+
<div id="hotwordStatus">Hotword Bias: Off</div>
|
199 |
+
</section>
|
200 |
+
|
201 |
+
<section class="section--endpoint">
|
202 |
+
<h2>Endpoint Detection</h2>
|
203 |
+
<div class="controls-grid">
|
204 |
+
<div class="control-item">
|
205 |
+
<label for="epRule1">Rule 1 (silence ≥ s)</label>
|
206 |
+
<input type="number" id="epRule1" step="0.1" value="2.4" />
|
207 |
+
</div>
|
208 |
+
<div class="control-item">
|
209 |
+
<label for="epRule2">Rule 2 (silence ≥ s)</label>
|
210 |
+
<input type="number" id="epRule2" step="0.1" value="1.2" />
|
211 |
+
</div>
|
212 |
+
<div class="control-item">
|
213 |
+
<label for="epRule3">Rule 3 (min utt ms)</label>
|
214 |
+
<input type="number" id="epRule3" step="50" value="300" />
|
215 |
+
</div>
|
216 |
+
<div class="control-item">
|
217 |
+
<button id="applyEndpointConfig">Apply Endpoint Config</button>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
</section>
|
221 |
+
|
222 |
+
<section class="section--mic">
|
223 |
+
<h2>Microphone</h2>
|
224 |
+
<div class="mic-info">
|
225 |
+
<span class="label">Device:</span> <span id="micName">Detecting…</span><br>
|
226 |
+
<span class="label">Sample Rate:</span> <span id="sampleRate">-</span> Hz
|
227 |
+
</div>
|
228 |
+
<progress id="vol" max="1" value="0"></progress>
|
229 |
+
</section>
|
230 |
+
|
231 |
+
<section class="section--transcript">
|
232 |
+
<h2>Transcript</h2>
|
233 |
+
<div id="transcript" class="transcript-container">…</div>
|
234 |
+
</section>
|
235 |
|
236 |
<script>
|
237 |
const MODEL_METADATA = {
|