sparv-sbx-whisper-import
This Sparv plugin makes it possible to use audio files as input to Sparv. The audio is transcribed to text using transformers and the KB Whisper models.
Prerequisites
Install
Install in a virtual environment:
pip install sparv-sbx-whisper-import
or if you have installed sparv with pipx:
pipx inject sparv sparv-sbx-whisper-import
or if you have installed sparv with uv-pipx:
uvpipx install sparv-sbx-whisper-import --inject sparv
Usage
To use audio files as input to Sparv, first create a corpus and a Sparv configuration file. For more information about creating a corpus, see the Sparv documentation. Possible configuration options are described below.
Once your corpus and configuration file are set up, run Sparv as usual:
sparv run
Supported audio formats
[!NOTE] Only one file type and one importer can be used within a corpus. If you want to process multiple file types, please create separate corpora.
The following audio formats are supported:
| Audio format | Importer (in config) |
|---|---|
| MP3 | sbx_whisper_import:parse_mp3 |
| OGG | sbx_whisper_import:parse_ogg |
| WAV | sbx_whisper_import:parse_wav |
Do you miss some audio format? Please check the tracking issue or open a new issue to request support for additional formats.
Command-line interface
You can use this plugin from the command-line as
# Activate virtual environment
> sbx-whisper-import --help
usage: sbx-whisper-import [-h] [--model-size MODEL_SIZE] [--verbosity VERBOSITY] INPUT
Transcribe audio file with KB-Whisper. Output is in JSON.
positional arguments:
INPUT audio input to trancribe in one of the formats MP3, OGG or WAV
options:
-h, --help show this help message and exit
--model-size MODEL_SIZE
set the size of the model
--verbosity VERBOSITY
set the verbosity of the model
Configuration
To use this plugin, specify the appropriate importer for your audio files in the Sparv configuration file (config.yaml).
The default model size is small and the default verbosity is standard. You can change these settings as described below.
import:
text_annotation: text
# needed to use sbx_whisper_import, use one of the lines below
importer: sbx_whisper_import:parse_mp3
# importer: sbx_whisper_import:parse_ogg
# importer: sbx_whisper_import:parse_wav
sbx_whisper_import:
# One of "tiny", "base", "small", "medium" or "large"
model_size: small
# One of "subtitle", "standard" or "strict" (low verbosity to high verbosity)
# NOTE: model size "medium" does support the verbosity "subtitle"
model_verbosity: standard
# A value between 0.0 and 1.0, defaults to 0.0.
temperature: 0.0
export:
annotations:
- text
- <token>
Annotations
The following annotations are created by the plugin:
textwith the attributesource_filename, which indicates the name of the audio file from which the text was transcribed.utterancewith the attributesstartandend, which indicate the timestamps (in seconds) of the utterance within the audio file.
Sample output:
<?xml version='1.0' encoding='utf-8'?>
<text source_filename="example.mp3">
<utterance end="6.0" start="0.0">
<token>Världsförklaring</token>
<token>.</token>
</utterance>
</text>
Metadata
The following table lists the exact models and revisions used for each combination of model size and model verbosity.
| Model Size | Model Verbosity | Model used | Revision used |
|---|---|---|---|
tiny |
subtitle |
KBLab/kb-whisper-tiny | 238d279d9821c32b905fcaff6ce9dad38ad00ab7 |
tiny |
standard |
KBLab/kb-whisper-tiny | e2bca57c3eee6144b9fefd07749580034cfa9686 |
tiny |
strict |
KBLab/kb-whisper-tiny | ea2a872f41f543aaadea23e185e974d1ab29ba2b |
base |
subtitle |
KBLab/kb-whisper-base | 7a57b541ccf4aebef73ecfdc064ef4b5cab3b02e |
base |
standard |
KBLab/kb-whisper-base | 1ee0facc30bb1f26492bb1360a99d552e25a31c2 |
base |
strict |
KBLab/kb-whisper-base | be19431a3fb78b71ac1525bcafe792220b314c9e |
small |
subtitle |
KBLab/kb-whisper-small | 8d49820338edb72829d1c44fa70a2ba94a4a20fa |
small |
standard |
KBLab/kb-whisper-small | 728c681653e2732ff64618e7f607f509ec87472a |
small |
strict |
KBLab/kb-whisper-small | 066ef166dd25b4b27039517ca77af30c1c10688a |
medium |
subtitle |
NOTE: subtitle not present for kb-whisper-medium | - |
medium |
standard |
KBLab/kb-whisper-medium | 32529a74c6662479625746edce7f16fe743fe011 |
medium |
strict |
KBLab/kb-whisper-medium | 51990d2cd5d0cf120b3eceb812bc5407a171a220 |
large |
subtitle |
KBLab/kb-whisper-large | 50b62f493fa513926007d388f76cce9659bce123 |
large |
standard |
KBLab/kb-whisper-large | 9e03cd21c14d02c57c33ae90b5803b54995ff241 |
large |
strict |
KBLab/kb-whisper-large | ea0a8ac1cda8eab8777bf8d74440eb7606825d8f |
Changelog
This project keeps a changelog.
Minimum supported Python version
This library tries to support as many Python versions as possible. When a Python version is added or dropped, this library's minor version is bumped.
- v0.1.0: Python 3.11
Development
Development prerequisites
For starting to develop on this repository:
- Clone the repo
git clone https://github.com/spraakbanken/sparv-sbx-whisper-import.git - Setup environment:
make dev - Install
pre-commithooks:pre-commit install
Do your work.
Tasks to do:
- Test the code with
make testormake test-w-coverage. - Test the examples with
make test-examples. - Lint the code with
make lint. - Check formatting with
make check-fmt. - Format the code with
make fmt. - Type-check the code with
make type-check.
This repo uses conventional commits.
Release a new version
- Prepare the CHANGELOG:
make prepare-releaseand then editCHANGELOG.md. - Add to git:
git add CHANGELOG.md - Commit with
git commit -m 'chore(release): prepare release'orcog commit chore 'prepare release' release. - Bump version (depends on `bump-my-version)
- Major:
make bumpversion part=major - Minor:
make bumpversion part=minor - Patch:
make bumpversion part=patchormake bumpversion
- Major:
- Push
mainand tags to GitHub:git push main --tagsormake publish- GitHub Actions will build, test and publish the package to PyPi.
- Add metadata for Språkbanken's resource
- Generate metadata:
make generate-metadata - Upload the files from
examples/metadata/export/sbx_metadata/utilityto https://github.com/spraakbanken/metadata/tree/main/yaml/utility.
- Generate metadata:
License
This repository is licensed under the MIT license.
Metadata
Release files for sparv-sbx-whisper-import 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sparv_sbx_whisper_import-0.2.0.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sparv_sbx_whisper_import-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.2 kB
Release files / sparv_sbx_whisper_import-0.2.0.tar.gz
| Download URL | sparv_sbx_whisper_import-0.2.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3af6477fce1d8f6f22a75f62cacf577f36f3d2e67de4d16349cd78d37fbe658e
|
|
BLAKE2b-256 checksum How to use checksums |
5540fe759b30bbdcbe5707cab44b66d40e40aef3b4f168561cc323e9bde3ce77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 21, 2026.
Transparency logRelease files / sparv_sbx_whisper_import-0.2.0-py3-none-any.whl
| Download URL | sparv_sbx_whisper_import-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84abac091a2726174155ea7e2a7b25bb7f59f238c3be3fcfe0219371e87f672f
|
|
BLAKE2b-256 checksum How to use checksums |
e000cf41a74eb36aaea03492a027bd07598fc429794d58cb95c2d2ea0686682b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 21, 2026.
Transparency log