Spaces:
Running
Running
recover volume meter scale
Browse files- app/main.py +3 -3
- app/static/index.html +1 -1
app/main.py
CHANGED
@@ -76,7 +76,7 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
76 |
raw_audio = data["bytes"]
|
77 |
# print(f"[INFO main] (text+bytes) Received audio chunk: {len(raw_audio)} bytes")
|
78 |
result, rms = stream_audio(raw_audio, stream, recognizer, orig_sr)
|
79 |
-
vol_to_send = min(rms
|
80 |
# print(f"[INFO main] Sending → partial='{result[:30]}…', volume={vol_to_send:.4f}")
|
81 |
await websocket.send_json({"partial": result, "volume": vol_to_send})
|
82 |
continue
|
@@ -88,12 +88,12 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
88 |
# This will also print its own debug info (see asr_worker.py)
|
89 |
result, rms = stream_audio(raw_audio, stream, recognizer, orig_sr)
|
90 |
|
91 |
-
vol_to_send = min(rms
|
92 |
# print(f"[INFO main] Sending → partial='{result[:30]}…', volume={vol_to_send:.4f}")
|
93 |
|
94 |
await websocket.send_json({
|
95 |
"partial": result,
|
96 |
-
"volume": min(rms
|
97 |
})
|
98 |
except Exception as e:
|
99 |
print(f"[ERROR main] Unexpected exception: {e}")
|
|
|
76 |
raw_audio = data["bytes"]
|
77 |
# print(f"[INFO main] (text+bytes) Received audio chunk: {len(raw_audio)} bytes")
|
78 |
result, rms = stream_audio(raw_audio, stream, recognizer, orig_sr)
|
79 |
+
vol_to_send = min(rms, 1.0)
|
80 |
# print(f"[INFO main] Sending → partial='{result[:30]}…', volume={vol_to_send:.4f}")
|
81 |
await websocket.send_json({"partial": result, "volume": vol_to_send})
|
82 |
continue
|
|
|
88 |
# This will also print its own debug info (see asr_worker.py)
|
89 |
result, rms = stream_audio(raw_audio, stream, recognizer, orig_sr)
|
90 |
|
91 |
+
vol_to_send = min(rms, 1.0)
|
92 |
# print(f"[INFO main] Sending → partial='{result[:30]}…', volume={vol_to_send:.4f}")
|
93 |
|
94 |
await websocket.send_json({
|
95 |
"partial": result,
|
96 |
+
"volume": min(rms, 1.0)
|
97 |
})
|
98 |
except Exception as e:
|
99 |
print(f"[ERROR main] Unexpected exception: {e}")
|
app/static/index.html
CHANGED
@@ -271,7 +271,7 @@
|
|
271 |
ws.onmessage = e => {
|
272 |
const msg = JSON.parse(e.data);
|
273 |
if (msg.volume !== undefined) {
|
274 |
-
vol.value = Math.min(msg.volume
|
275 |
}
|
276 |
if (msg.partial) {
|
277 |
// replace content…
|
|
|
271 |
ws.onmessage = e => {
|
272 |
const msg = JSON.parse(e.data);
|
273 |
if (msg.volume !== undefined) {
|
274 |
+
vol.value = Math.min(msg.volume, 1.0);
|
275 |
}
|
276 |
if (msg.partial) {
|
277 |
// replace content…
|