Skip to main content

jupyterlab-voice-control

Github Actions Status Binder PyPI version

⚠️ This extension is experimental ⚠️

Voice commands for JupyterLab extension relies on experimental Speech Recognition API and is not suitable for use in production environments. You can check the current support on caniuse.com/speech-recognition.

Please be aware that the Speech Recognition method is an implementation detail of the browser, and some browsers, including Google Chrome, may send recordings of your voice to cloud for recognition.

While it is currently just proof of concept, please do get in touch by opening a new issue if you found this extension useful/promising and would like to leave any feedback which would be greatly appreciated.

Usage

To use this extension look for a microphone (microphone icon) icon on the status bar.

Initial icon location in the status bar

Press the disabled microphone icon (disabled microphone icon) to start voice recognition (or use Alt + v shortcut). You will need to agree for the browser to use your microphone:

Microphone access dialog in Chrome

You can use any of the commands available in the command palette, for example try "Download" or "Run selected cells".

Sometimes the speech recognition may be inaccurate, or you may misremember the name of the command. In those cases the voice control assistant will prompt you with suggestions with words "Did you mean..." and one or more suggestions on the status bar:

Suggestion saying "Did you mean New Launcher?"

  • You can accept the first suggestion by saying "yes".
  • To choose the second suggestion say "second suggestion", and so on.
  • Speech synthesis option is available (in the settings) if you prefer it over checking the status bar continuously.
  • The threshold for inclusion of a similar-sounding phrase as a suggestion can be adjusted in the settings.

If there are no errors or suggestions, the recognised speech will be shown on the status bar together with a confidence estimate:

Recognised phrase "close all tabs" with 87% confidence

By default commands recognised with low confidence (<50%) will not be executed (as it is deemed safer in case of any potentially destructive actions), but you can change the threshold in the settings.

Creating custom commands

In the settings editor you can assign custom phrases to commands in the same way as you can configure shortcuts. We refer to the words you need to say in order to execute a command as trigger phrase.

The voice control extension provides additional commands for interaction with the interface such as typing text (vc:insert-text), accepting suggestions (vc:accept-suggestion), stopping recognition (vc:stop-listening), etc.

The trigger phrase can be a regular expression and include named capturing groups. The captured groups will be passed as arguments to the command (/merged with pre-specified arguments if any, with groups overriding pre-specified arguments in case of a collision). For example, to create a command for opening files we could specify:

{
  "phrase": "^open file (?<path>.*)",
  "command": "filebrowser:open-path"
}

^ ensures that only phrases starting with "open file" will be matched.

We provide command vc:open-notebook (by default under open notebook (?<path>.*)) which automatically appends notebook file extension (.ipynb) as it can be problematic for speech recognition software.

Requirements

  • JupyterLab >= 3.4 (may work with older versions of 3.x, but not tested)

Install

To install the extension, execute:

pip install jupyterlab-voice-control

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab-voice-control

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the jupyterlab-voice-control directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the jlpm build command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Development uninstall

pip uninstall jupyterlab-voice-control

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab-voice-control within that folder.

Testing the extension

Frontend tests

This extension is using Jest for JavaScript code testing.

To execute them, execute:

jlpm
jlpm test

Integration tests

This extension uses Playwright for the integration tests (aka user level tests). More precisely, the JupyterLab helper Galata is used to handle testing the extension in JupyterLab.

More information are provided within the ui-tests README.

Packaging the extension

See RELEASE

Metadata

Release files for jupyterlab-voice-control 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-voice-control 0.2.4
File Size Uploaded
jupyterlab-voice-control-0.2.4.tar.gz 516.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-voice-control 0.2.4
File Interpreter ABI Platform
jupyterlab_voice_control-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 1.6 MB

Release files / jupyterlab-voice-control-0.2.4.tar.gz

Download URL jupyterlab-voice-control-0.2.4.tar.gz
Size 516.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cddd79f35d48391dd3837ad2744fe302998b55f6a8645063387597cbfd897304
BLAKE2b-256 checksum
How to use checksums
04b1412fac61daa6bcdeebad65595e1a8d0ab4b4fa69cff3ae160edb42fda909
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / jupyterlab_voice_control-0.2.4-py3-none-any.whl

Download URL jupyterlab_voice_control-0.2.4-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0c04a8d8ea84806145795d18209ac9f0fb29d238963e9e61b03d983889fc437e
BLAKE2b-256 checksum
How to use checksums
9014072cf2a58b9e74445a5200ff861a47a472b4ea6bc5ff786ab28d6fbf7e6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page