Skip to main content

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")

Release files for stlrcore 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stlrcore 1.0.1
File Size Uploaded
stlrcore-1.0.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stlrcore 1.0.1
File Interpreter ABI Platform
stlrcore-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / stlrcore-1.0.1.tar.gz

Download URL stlrcore-1.0.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dd8511fa5dcda6269a4c9b3e0edff6203b91693284355ea0840618a6089a742d
BLAKE2b-256 checksum
How to use checksums
d06277e8f6d1def500d4b271a4631430756909af0eeff51ba80e62d4d4fa6aae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / stlrcore-1.0.1-py3-none-any.whl

Download URL stlrcore-1.0.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d00aea74523dbe889ccd8776f68feb6736fbd136c2eff4a46b95ca864e374bd0
BLAKE2b-256 checksum
How to use checksums
088735fd8ad81fb148040f270d3133468241fc359d42f79a86988e8661010431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page