From a46d1e1f5199211dcb4f5aa2459499f295f3dd5c Mon Sep 17 00:00:00 2001 From: David Scripka Date: Thu, 9 Nov 2023 20:14:17 -0500 Subject: [PATCH] Updated readmes for new examples [skip ci] --- README.md | 7 ++++++- examples/web/README.md | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f93e2d4..97784f8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ openWakeWord is an open-source wakeword library that can be used to create voice # Updates +**2023/11/09** +- Added example scripts under `examples/web` that demonstrate streaming audio from a web application into openWakeWord. + **2023/10/11** - Significant improvements to the process of [training new models](#training-new-models), including an example Google Colab notebook demonstrating how to train a basic wake word model in <1 hour. @@ -240,9 +243,11 @@ Future release road maps may have non-english support. In particular, [Mycroft.A **Can openWakeWord be run in a browser with javascript?** - While the ONNX runtime [does support javascript](https://onnxruntime.ai/docs/get-started/with-javascript.html), much of the other functionality required for openWakeWord models would need to be ported. This is not currently on the roadmap, but please open an issue/start a discussion if this feature is of particular interest. +- As a potential work-around for some applications, the example scripts in `examples/web` demonstrate how audio can be captured in a browser and streaming via websockets into openWakeWord running in a Python backend server. +- Other potential options could include projects like `pyodide` (see [here](https://github.com/pyodide/pyodide/issues/4220)) for a related issue. **Is there a C++ version of openWakeWord?** -- While the ONNX runtime [also has a C++ API](https://onnxruntime.ai/docs/get-started/with-cpp.html), there isn't an official C++ implementation of the full openWakeWord library. However, [@synesthesiam](https://github.com/synesthesiam) has created a [C++ version](https://github.com/rhasspy/openWakeWord-cpp) of openWakeWord with basic functionality implemented. +- While the ONNX runtime [also has a C++ API](https://onnxruntime.ai/docs/get-started/with-cpp.html), there isn't an official C++ implementation of the full openWakeWord library. However, [@synesthesiam](https://github.com/synesthesiam) has created a [C++ version of openWakeWord](https://github.com/rhasspy/openWakeWord-cpp) with basic functionality implemented. **Why are there three separate models instead of just one?** - Separating the models was an intentional choice to provide flexibility and optimize the efficiency of the end-to-end prediction process. For example, with separate melspectrogram, embedding, and prediction models, each one can operate on different size inputs of audio to optimize overall latency and share computations between models. It certainly is possible to make a combined model with all of the steps integrated, though, if that was a requirement of a particular use case. diff --git a/examples/web/README.md b/examples/web/README.md index 2f9c21b..bd4e970 100644 --- a/examples/web/README.md +++ b/examples/web/README.md @@ -8,8 +8,14 @@ As openWakeWord does not have a native Javascript port, using it within a web br ``` pip install aiohttp +pip install resampy ``` The `streaming_client.html` page shows a simple implementation of audio capture and streamimng from a microphone and streaming in a browser, and the `streaming_server.py` file is the corresponding websocket server that passes the audio into openWakeWord. -To run the example, execute `python streaming_server.py` (add the `--help` argument to see options) and navigate to `localhost:9000` in your browser. \ No newline at end of file +To run the example, execute `python streaming_server.py` (add the `--help` argument to see options) and navigate to `localhost:9000` in your browser. + +Note that this example is illustrative only, and integration of this approach with other web applications may have different requirements. In particular, some key considerations: + +- This example captures PCM audio from the web browser and streams full 16-bit integer representations of ~250 ms audio chunks over the websocket connection. In practice, bandwidth efficient streams of compressed audio may be more suitable for some applications. +- The browser captures audio at the native sampling rate of the capture device, which can require re-sampling prior to passing the audio data to openWakeWord. This example uses the `resampy` library which has a good balance between performance and quality, but other resampling approaches that optimize different aspects may be more suitable for some applications. \ No newline at end of file