Create and process audio transcriptions with word timings
Project description
stlr-core
Overview
stlrcore is a toolkit designed as a wrapper to whisper-timestamped and stable-whisper which aims to provide a more convenient interface between them. It serves as the foundation for stlrapps (a suite of tools for automatic subtitle generation, etc.)
Installation
Usage
from pathlib import Path
from typing import Iterator
from stlrcore import Transcription
from stlrcore.transcribe import WordTiming, Segment
# create a transcription from an audio file
transcription = Transcription.from_audio("path/to/audio.ext")
# Transcription objects are iterable, and they iterate over WordTimings
word_timings: Iterator[WordTiming] = iter(transcription)
# For just the actual words themselves:
words: list[str] = transcription.words
text: str = str(transcription)
# You can also create Segments, which are consecutive words without pauses.
segments: Iterator[Segment] = transcription.get_segments(tolerance=0.0)
# Find the timing for a particular substring of words
segment: Segment = transcription.get_fragment(fragment="...")
# Transcriptions can be exported as json, Audacity cue, or Audition cue
transcription.export(filestem="transcription", mode="json") # -> transcription.json
transcription.export(filestem="transcription", mode="audacity") # -> transcription.txt
transcription.export(filestem="transcription", mode="audition") # -> transcription.csv
# Similarly, Transcriptions can be created from these exported files:
transcription = Transcription.from_json(Path("transcription.json"))
transcription = Transcription.from_audacity_cue(Path("transcription.txt"))
transcription = Transcription.from_audition_cue(Path("transcription.csv"))
# A convenience wrapper around these is also provided:
# `mode` should be one of "audio", "json", "audacity", "audition"
transcription = Transcription.load(Path(...), mode=...)
# Because Transcriptions are constructed out of words, not as segments, direct export
# to SRT is not supported. While it may be preferable to manually (or otherwise) determine
# the proper segment split points, the following can be used:
Transcription.write_srt(segments=transcription.get_segments(), dest="transcription.srt")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stlrcore-1.0.1.tar.gz.
File metadata
- Download URL: stlrcore-1.0.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd8511fa5dcda6269a4c9b3e0edff6203b91693284355ea0840618a6089a742d
|
|
| MD5 |
2fe4e76669917e0d8afe122eba0a2cbd
|
|
| BLAKE2b-256 |
d06277e8f6d1def500d4b271a4631430756909af0eeff51ba80e62d4d4fa6aae
|
File details
Details for the file stlrcore-1.0.1-py3-none-any.whl.
File metadata
- Download URL: stlrcore-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d00aea74523dbe889ccd8776f68feb6736fbd136c2eff4a46b95ca864e374bd0
|
|
| MD5 |
2cd370fc6435aee713db38f534a1b702
|
|
| BLAKE2b-256 |
088735fd8ad81fb148040f270d3133468241fc359d42f79a86988e8661010431
|