spaCy Whisper
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:
pip install spacy-whisper
Usage
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
[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
for ent in doc.ents:
if ent.label_ == "PERSON":
print(ent, ent.label_, ent._.start_time, ent._.end_time)
Expected Output
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
for sent in doc.sents:
print(sent.text, sent._.start_time, sent._.end_time)
Expected Output
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
...
Metadata
Release files for spacy-whisper 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spacy-whisper-0.0.1.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spacy_whisper-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / spacy-whisper-0.0.1.tar.gz
| Download URL | spacy-whisper-0.0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
709d12a05363bb8f94bf858b19960a407c9e9989e4766a9c660667e877a35cd5
|
|
BLAKE2b-256 checksum How to use checksums |
5451951e29094b54621b92023add954ffcccb5355b2258b261cd56371a466d71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / spacy_whisper-0.0.1-py3-none-any.whl
| Download URL | spacy_whisper-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38660cfe0629c3f24ea0abd5f39be5dc7502fa929bd4669788db97c8a01243d2
|
|
BLAKE2b-256 checksum How to use checksums |
215990abf314eaad828aa6ba9813f24bdd541f5e88740c0e1c84b8e83c765e23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|