Closed j1elo closed 2 years ago
Amazing. Huge thanks!
You're welcome! Actually thank you a lot, for maintaining this server. It wouldn't have occurred to me that aiortc provides a non-standard track.recv()
method to retrieve already uncompressed audio frames! That's so useful to avoid a decoding step between WebRTC (OPUS audio) and the Vosk recognizer.
webrtc: Several fixes for performance and user friendliness
Several small changes that I made to make the demo look better and work more reliably.
Each change is individually self-contained on its own commit.
Changes in this PR:
README
Do not recommend changing internal Chrome flags. This is very unsecure and could open the door to attacks. Instead, web browsers consider "localhost" as a privileged exception to the Secure Context rule, which means that it can be used without SSL to access the mic.
Add instructions for running with HTTPS, in case someone wants to test the demo in their LAN instead of localhost.
WebRTC server
Add support for passing an SSL key file (
VOSK_KEY_FILE
), in addition to the certificate file (VOSK_CERT_FILE
).Fix asyncio event loop reference.
The
get_event_loop()
call was creating a top-level loop which is not what is intended by the code in__run_audio_xfer()
, which runs already as a Task with its own event loop, soget_running_loop()
should be used instead, inside the Task. Also,get_event_loop()
is deprecated.Improved handling of AcceptWaveform() results
Make
process_chunk()
return None if an error is raised by the Python layer, or if an empty PartialResult is returned. This avoids lots of redundant DataChannel messages with empty payload.webrtc/server: Minor optimizations
max_frames_len
never changes, so no need to update it on every loop iteration.Send an empty object to the HTML UI, so the user knows when DataChannel has been connected and the demo is ready.
Demo HTML
webrtc/static: Show a prompt (
>
) on the "partial" divImprove visual feedback to the user, by showing a small prompt indicator on the div where "partial" messagess will appear. This gives the feeling that the partial line does indeed contain intermediate results.
webrtc/static: Improve DataChannel handling code
Catch errors, rename Text result div to "text", and use more robut checks on object members.
webrtc/static: Disable favicon to avoid errors on page loading