spacy-whisper


Namespacy-whisper JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/theirstory/spacy-whisper
SummaryIntegrate Whisper transcriptions with spaCy for advanced NLP tasks
upload_time2024-04-01 12:45:40
maintainerNone
docs_urlNone
authorTheir Story
requires_pythonNone
licenseMIT
keywords nlp spacy whisper transcription
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # spaCy Whisper

![spacy Whisper logo](https://github.com/theirstory/spacy-whisper/raw/main/images/spacy_whisper.jpeg)

spaCy Whisper is a Python package designed to integrate Whisper transcriptions with the natural language processing (NLP) capabilities of spaCy. It allows users to process and analyze Whisper transcribed text with the powerful tools offered by spaCy, including tokenization, entity recognition, part-of-speech tagging, and more.

## Features

- **Word Level Processing:** Assigns custom attributes such as start and end times, and probabilities to tokens based on Whisper output.
- **Segment Level Processing:** Processes text at a segment level where each word in a segment shares the same start and end time.
- **Custom Token Extensions:** Adds custom extensions like start_time, end_time, and probability to spaCy's Token objects.
- **Custom Span Extensions:** Adds start_time and end_time extensions to Span objects (such as entities and sentences).
- **Custom Document Extensions:** Adds a timestamp_doc extension to Doc objects, representing the document with timestamps.

## Installation

spaCy Whisper can be installed via pip:

```bash
pip install spacy-whisper
```

## Usage

```python
from spacy_whisper import SpacyWhisper
import json

# Load a Whisper Output:
with open("whisper_output.json", "r", encoding="utf-8") as f:
    whisper_output = json.load(f)

# Initialize SpacyWhisper
sw = SpacyWhisper(lang="en", model="en_core_web_sm", segments_key="segments", word_level=True)

doc = sw.create_doc(whisper_output)

# Access custom attributes
for token in doc:
    print(token.text, token._.start_time, token._.end_time, token._.probability)
```

### Expected Output

```markdown
[00:00:00.000] One of the most useful things you can learn as an intermediate Python student is comprehension.
[00:00:04.720] List comprehension looks something like this.
[00:00:07.000] Imagine we had a list of names, Tom, Cat, and Bob.
```

## Identify Entity Timing

```python
for ent in doc.ents:
    if ent.label_ == "PERSON":
        print(ent, ent.label_, ent._.start_time, ent._.end_time)
```

### Expected Output

```markdown
Tom PERSON 8.4 8.66
Bob PERSON 9.24 9.54
Tom PERSON 24.64 24.94
Bob PERSON 24.94 25.2
N. PERSON 50.94 51.82
```

## Find when Sentences Start and End

```python
for sent in doc.sents:
    print(sent.text, sent._.start_time, sent._.end_time)
```

### Expected Output

```markdown
One of the most useful things you can learn as an intermediate Python student is comprehension. 0.0 4.04
List comprehension looks something like this. 4.72 6.68
Imagine we had a list of names, Tom, Cat, and Bob. 7.0 9.54
...
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/theirstory/spacy-whisper",
    "name": "spacy-whisper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "NLP, spaCy, Whisper, transcription",
    "author": "Their Story",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/54/51/951e29094b54621b92023add954ffcccb5355b2258b261cd56371a466d71/spacy-whisper-0.0.1.tar.gz",
    "platform": null,
    "description": "# spaCy Whisper\n\n![spacy Whisper logo](https://github.com/theirstory/spacy-whisper/raw/main/images/spacy_whisper.jpeg)\n\nspaCy Whisper is a Python package designed to integrate Whisper transcriptions with the natural language processing (NLP) capabilities of spaCy. It allows users to process and analyze Whisper transcribed text with the powerful tools offered by spaCy, including tokenization, entity recognition, part-of-speech tagging, and more.\n\n## Features\n\n- **Word Level Processing:** Assigns custom attributes such as start and end times, and probabilities to tokens based on Whisper output.\n- **Segment Level Processing:** Processes text at a segment level where each word in a segment shares the same start and end time.\n- **Custom Token Extensions:** Adds custom extensions like start_time, end_time, and probability to spaCy's Token objects.\n- **Custom Span Extensions:** Adds start_time and end_time extensions to Span objects (such as entities and sentences).\n- **Custom Document Extensions:** Adds a timestamp_doc extension to Doc objects, representing the document with timestamps.\n\n## Installation\n\nspaCy Whisper can be installed via pip:\n\n```bash\npip install spacy-whisper\n```\n\n## Usage\n\n```python\nfrom spacy_whisper import SpacyWhisper\nimport json\n\n# Load a Whisper Output:\nwith open(\"whisper_output.json\", \"r\", encoding=\"utf-8\") as f:\n    whisper_output = json.load(f)\n\n# Initialize SpacyWhisper\nsw = SpacyWhisper(lang=\"en\", model=\"en_core_web_sm\", segments_key=\"segments\", word_level=True)\n\ndoc = sw.create_doc(whisper_output)\n\n# Access custom attributes\nfor token in doc:\n    print(token.text, token._.start_time, token._.end_time, token._.probability)\n```\n\n### Expected Output\n\n```markdown\n[00:00:00.000] One of the most useful things you can learn as an intermediate Python student is comprehension.\n[00:00:04.720] List comprehension looks something like this.\n[00:00:07.000] Imagine we had a list of names, Tom, Cat, and Bob.\n```\n\n## Identify Entity Timing\n\n```python\nfor ent in doc.ents:\n    if ent.label_ == \"PERSON\":\n        print(ent, ent.label_, ent._.start_time, ent._.end_time)\n```\n\n### Expected Output\n\n```markdown\nTom PERSON 8.4 8.66\nBob PERSON 9.24 9.54\nTom PERSON 24.64 24.94\nBob PERSON 24.94 25.2\nN. PERSON 50.94 51.82\n```\n\n## Find when Sentences Start and End\n\n```python\nfor sent in doc.sents:\n    print(sent.text, sent._.start_time, sent._.end_time)\n```\n\n### Expected Output\n\n```markdown\nOne of the most useful things you can learn as an intermediate Python student is comprehension. 0.0 4.04\nList comprehension looks something like this. 4.72 6.68\nImagine we had a list of names, Tom, Cat, and Bob. 7.0 9.54\n...\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Integrate Whisper transcriptions with spaCy for advanced NLP tasks",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/theirstory/spacy-whisper"
    },
    "split_keywords": [
        "nlp",
        " spacy",
        " whisper",
        " transcription"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "215990abf314eaad828aa6ba9813f24bdd541f5e88740c0e1c84b8e83c765e23",
                "md5": "3ab135205ef217f53e0a0fb20d120422",
                "sha256": "38660cfe0629c3f24ea0abd5f39be5dc7502fa929bd4669788db97c8a01243d2"
            },
            "downloads": -1,
            "filename": "spacy_whisper-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ab135205ef217f53e0a0fb20d120422",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5348,
            "upload_time": "2024-04-01T12:45:38",
            "upload_time_iso_8601": "2024-04-01T12:45:38.039695Z",
            "url": "https://files.pythonhosted.org/packages/21/59/90abf314eaad828aa6ba9813f24bdd541f5e88740c0e1c84b8e83c765e23/spacy_whisper-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5451951e29094b54621b92023add954ffcccb5355b2258b261cd56371a466d71",
                "md5": "6c04f63535b2e2447d827603c2450301",
                "sha256": "709d12a05363bb8f94bf858b19960a407c9e9989e4766a9c660667e877a35cd5"
            },
            "downloads": -1,
            "filename": "spacy-whisper-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6c04f63535b2e2447d827603c2450301",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4882,
            "upload_time": "2024-04-01T12:45:40",
            "upload_time_iso_8601": "2024-04-01T12:45:40.056777Z",
            "url": "https://files.pythonhosted.org/packages/54/51/951e29094b54621b92023add954ffcccb5355b2258b261cd56371a466d71/spacy-whisper-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-01 12:45:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "theirstory",
    "github_project": "spacy-whisper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "spacy-whisper"
}
        
Elapsed time: 3.22442s