speechwidgets


Namespeechwidgets JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/nicolvisser/speechwidgets
SummaryA library with Jupyter widgets for speech processing
upload_time2023-03-29 15:13:09
maintainer
docs_urlNone
authornicolvisser
requires_python>=3.6
licenseBSD
keywords jupyter widgets ipython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            
# speechwidgets

Jupyter widgets for speech processing

- **`SpectrogramPlayer`**
  - Based on the React component, [react-audio-spectrogram-player](https://github.com/nicolvisser/react-audio-spectrogram-player). See the [demo](https://react-audio-spectrogram-player.netlify.app).
  
![preview](./preview.png)

## Installation

You can install using `pip`:

```bash
pip install speechwidgets
```

If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable
the nbextension:
```bash
jupyter nbextension enable --py [--sys-prefix|--user|--system] speechwidgets
```

## Usage

```py
from speechwidgets import SpectrogramPlayer
```
### Basic usage:
```py
SpectrogramPlayer(
    wav_file_path='./19-198-0001.wav',
    width=800,
    spec_height=200,
    navigator=True,
    nav_height=60,
)
```
### Advanced usage:
```py
SpectrogramPlayer(
    wav_file_path='./19-198-0001.wav',
    width=800,
    spec_height=200,
    navigator=False,
    settings=False,
    colormap="greys",

    # for dark mode notebooks:
    dark=False, # set to True
    transparent=False, # optionally set to True
    
    # mel spec parameters:
    n_fft=2048,
    win_length=400,
    hop_length=160,
    f_min=50, 
    n_mels=80,
    power=1.0,
    
    # amplitude to db parameter:
    top_db=80 
)
```
### Annotations:
```py
word_intervals = [['0.54', '0.84', 'this'],
        ['0.84', '1.1', 'little'],
        ['1.1', '1.4', 'work']]
```
```py
s = SpectrogramPlayer(
    wav_file_path='./19-198-0001.wav',
    width=800,
    spec_height=200
)
```
```py
s.annotate(data=word_intervals, title="Word Intervals", height=20, stroke_width=0.5)
```
You can call the `annotate` method  multiple times with different data. `title`, `height` and `stroke_width` are optional arguments.

See `examples/` folder on github for full code examples.

## Development Installation

Create a dev environment:
```bash
conda create -n speechwidgets-dev -c conda-forge nodejs python=3.10 jupyterlab
conda activate speechwidgets-dev
```

Install the python dependencies. This will also build the TS package.
```bash
pip install -e ".[test, examples]"
```

When developing your extensions, you need to manually enable your extensions with the
notebook / lab frontend. For lab, this is done by the command:

```
jupyter labextension develop --overwrite .
npm install
npm run build
```

For classic notebook, you need to run:

```
jupyter nbextension install --sys-prefix --symlink --overwrite --py speechwidgets
jupyter nbextension enable --sys-prefix --py speechwidgets
```

Note that the `--symlink` flag doesn't work on Windows, so you will here have to run
the `install` command every time that you rebuild your extension. For certain installations
you might also need another flag instead of `--sys-prefix`, but we won't cover the meaning
of those flags here.

### How to see your changes
#### Typescript:
If you use JupyterLab to develop then 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 widget.

```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
npm run watch
# Run JupyterLab in another terminal
jupyter lab
```

After a change wait for the build to finish and then refresh your browser and the changes should take effect.

#### Python:
If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nicolvisser/speechwidgets",
    "name": "speechwidgets",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "Jupyter,Widgets,IPython",
    "author": "nicolvisser",
    "author_email": "nicolvisser@yahoo.com",
    "download_url": "https://files.pythonhosted.org/packages/28/c4/73b4e66a2ffd3ff36bbfd73ff978a463a6ea54f2717fd1e909043fb6bb5f/speechwidgets-1.0.1.tar.gz",
    "platform": "Linux",
    "description": "\n# speechwidgets\n\nJupyter widgets for speech processing\n\n- **`SpectrogramPlayer`**\n  - Based on the React component, [react-audio-spectrogram-player](https://github.com/nicolvisser/react-audio-spectrogram-player). See the [demo](https://react-audio-spectrogram-player.netlify.app).\n  \n![preview](./preview.png)\n\n## Installation\n\nYou can install using `pip`:\n\n```bash\npip install speechwidgets\n```\n\nIf you are using Jupyter Notebook 5.2 or earlier, you may also need to enable\nthe nbextension:\n```bash\njupyter nbextension enable --py [--sys-prefix|--user|--system] speechwidgets\n```\n\n## Usage\n\n```py\nfrom speechwidgets import SpectrogramPlayer\n```\n### Basic usage:\n```py\nSpectrogramPlayer(\n    wav_file_path='./19-198-0001.wav',\n    width=800,\n    spec_height=200,\n    navigator=True,\n    nav_height=60,\n)\n```\n### Advanced usage:\n```py\nSpectrogramPlayer(\n    wav_file_path='./19-198-0001.wav',\n    width=800,\n    spec_height=200,\n    navigator=False,\n    settings=False,\n    colormap=\"greys\",\n\n    # for dark mode notebooks:\n    dark=False, # set to True\n    transparent=False, # optionally set to True\n    \n    # mel spec parameters:\n    n_fft=2048,\n    win_length=400,\n    hop_length=160,\n    f_min=50, \n    n_mels=80,\n    power=1.0,\n    \n    # amplitude to db parameter:\n    top_db=80 \n)\n```\n### Annotations:\n```py\nword_intervals = [['0.54', '0.84', 'this'],\n        ['0.84', '1.1', 'little'],\n        ['1.1', '1.4', 'work']]\n```\n```py\ns = SpectrogramPlayer(\n    wav_file_path='./19-198-0001.wav',\n    width=800,\n    spec_height=200\n)\n```\n```py\ns.annotate(data=word_intervals, title=\"Word Intervals\", height=20, stroke_width=0.5)\n```\nYou can call the `annotate` method  multiple times with different data. `title`, `height` and `stroke_width` are optional arguments.\n\nSee `examples/` folder on github for full code examples.\n\n## Development Installation\n\nCreate a dev environment:\n```bash\nconda create -n speechwidgets-dev -c conda-forge nodejs python=3.10 jupyterlab\nconda activate speechwidgets-dev\n```\n\nInstall the python dependencies. This will also build the TS package.\n```bash\npip install -e \".[test, examples]\"\n```\n\nWhen developing your extensions, you need to manually enable your extensions with the\nnotebook / lab frontend. For lab, this is done by the command:\n\n```\njupyter labextension develop --overwrite .\nnpm install\nnpm run build\n```\n\nFor classic notebook, you need to run:\n\n```\njupyter nbextension install --sys-prefix --symlink --overwrite --py speechwidgets\njupyter nbextension enable --sys-prefix --py speechwidgets\n```\n\nNote that the `--symlink` flag doesn't work on Windows, so you will here have to run\nthe `install` command every time that you rebuild your extension. For certain installations\nyou might also need another flag instead of `--sys-prefix`, but we won't cover the meaning\nof those flags here.\n\n### How to see your changes\n#### Typescript:\nIf you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different\nterminals to watch for changes in the extension's source and automatically rebuild the widget.\n\n```bash\n# Watch the source directory in one terminal, automatically rebuilding when needed\nnpm run watch\n# Run JupyterLab in another terminal\njupyter lab\n```\n\nAfter a change wait for the build to finish and then refresh your browser and the changes should take effect.\n\n#### Python:\nIf you make a change to the python code then you will need to restart the notebook kernel to have it take effect.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A library with Jupyter widgets for speech processing",
    "version": "1.0.1",
    "split_keywords": [
        "jupyter",
        "widgets",
        "ipython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3c8da39cd0112dd247f1399a7a7c1f444f90f0765b8568503c8f8bfbedd2be2",
                "md5": "9dcbeef4308c1a51c521d1c029ada80c",
                "sha256": "2b4816c34239b91f9a530d81e1fe68e7c72b9cbae2a55ab329b086f17cc16803"
            },
            "downloads": -1,
            "filename": "speechwidgets-1.0.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9dcbeef4308c1a51c521d1c029ada80c",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 514099,
            "upload_time": "2023-03-29T15:13:05",
            "upload_time_iso_8601": "2023-03-29T15:13:05.896303Z",
            "url": "https://files.pythonhosted.org/packages/e3/c8/da39cd0112dd247f1399a7a7c1f444f90f0765b8568503c8f8bfbedd2be2/speechwidgets-1.0.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28c473b4e66a2ffd3ff36bbfd73ff978a463a6ea54f2717fd1e909043fb6bb5f",
                "md5": "74e9912dc058c05466ba07468b9214dd",
                "sha256": "d970c05692991a82f2a9cf0215ebd071a618631d0b663fbcb3bb1e2b73bbdd6f"
            },
            "downloads": -1,
            "filename": "speechwidgets-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "74e9912dc058c05466ba07468b9214dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 758939,
            "upload_time": "2023-03-29T15:13:09",
            "upload_time_iso_8601": "2023-03-29T15:13:09.221398Z",
            "url": "https://files.pythonhosted.org/packages/28/c4/73b4e66a2ffd3ff36bbfd73ff978a463a6ea54f2717fd1e909043fb6bb5f/speechwidgets-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-29 15:13:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "nicolvisser",
    "github_project": "speechwidgets",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "speechwidgets"
}
        
Elapsed time: 0.11764s