From 99b6fdb87d983ebe84b4db6e16c0780c38cf0ba0 Mon Sep 17 00:00:00 2001 From: Shai Shmuel Date: Mon, 30 Nov 2026 13:54:09 +0200 Subject: [PATCH 1/6] feat(server): add an out-of-lexicon G2P fallback for Kokoro-82M misaki's English G2P leaves words outside its lexicon silent unless it is given a fallback. Add one built on cisco-ai/mini-bart-g2p (Apache-2.0), a small sequence-to-sequence letter-to-sound model, with greedy decoding and its ARPAbet output mapped onto misaki's American and British phoneme alphabets. Tokens are handled three ways. A token with a digit or symbol (5:30, km/h, an e-mail address or URL) is split with misaki's sub-tokenizer, a few symbols are said as words, a URL scheme is dropped in any case, every digit after a decimal point is said, and the pieces are read by misaki again. A short word without vowels (mg, www) is spelled with misaki's lexicon. Anything else goes to the model, one chunk per run of letters after accents are folded and CamelCase is split. A token that is only symbols is silent unless it is one of the listed symbols. Output is bounded: a run of letters is read in pieces of at most 48, a token yields at most 8 pieces and 400 phoneme characters, each piece at most its length plus 6 phonemes, and no unit of up to four phonemes is repeated more than twice in a row, which stops decoding loops on words such as Llanfairpwllgwyngyll. misaki asks for one token at a time. Before a text is phonemized, prefetch() runs misaki once in a collecting mode and reads every chunk it would ask for in one batched model call; results go to a bounded cache that the real pass reads, and the spaCy parse is reused by the real pass. Re-entry depth and the collecting mode are per thread. Tests stub misaki and the model, and run the decoding path against a tiny random-weight BART checkpoint built in the test. --- .../adapters/kokoro/g2p_fallback.py | 310 +++++++++++++++++ .../tests/adapters/test_kokoro_g2p.py | 325 ++++++++++++++++++ 2 files changed, 635 insertions(+) create mode 100644 packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py create mode 100644 packages/sie_server/tests/adapters/test_kokoro_g2p.py diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py b/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py new file mode 100644 index 000000000..cfbfea006 --- /dev/null +++ b/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py @@ -0,0 +1,310 @@ +"""Out-of-lexicon fallback for misaki's English G2P, used by the Kokoro-82M adapter. + +misaki calls the fallback with one token whose text its lexicon could not read and +expects ``(phonemes, rating)`` back, or ``(None, None)`` to leave the token silent. +``Fallback`` sorts tokens three ways: + +* A token with a digit or symbol (``5:30``, ``km/h``, ``support@example.com``) is + split with misaki's own sub-tokenizer, a few symbols are said as words, and the + pieces are read by misaki again: numbers take misaki's number path and letter + pieces come back here. +* A short word without vowels (``mg``, ``km``, ``www``) is spelled letter by + letter with misaki's lexicon. +* Any other token is read by ``LetterToSound``: the ``cisco-ai/mini-bart-g2p`` + sequence-to-sequence model (Apache-2.0), whose ARPAbet output is mapped onto + misaki's phoneme alphabet. + +misaki asks for one token at a time, and one model call per token costs tens of +milliseconds. ``Fallback.prefetch`` therefore runs misaki over the text once in a +collecting mode, reads every letter chunk it would ask for in one batched model +call, and keeps the results in a bounded cache that the real pass reads. The +spaCy parse of each text is kept for the real pass, so the collecting pass costs +misaki's own work only. + +This relies on misaki 0.9.4 internals: ``en.subtokenize``, ``Lexicon.get_NNP``, +the G2P's ``nlp`` attribute and calling the G2P again from inside its fallback. +""" + +# ruff: noqa: RUF001 +# Phoneme symbols (IPA letters and stress marks) are intentional. + +from __future__ import annotations + +import re +import threading +import unicodedata +from collections import OrderedDict +from collections.abc import Callable, Iterable, Sequence +from pathlib import Path +from typing import Any + +import torch + +# Rating misaki stores for fallback words (its lexicon uses 3 to 5). +_RATING = 1 + +_CONSONANTS = { + "B": "b", "CH": "ʧ", "D": "d", "DH": "ð", "F": "f", "G": "ɡ", "HH": "h", "JH": "ʤ", + "K": "k", "L": "l", "M": "m", "N": "n", "NG": "ŋ", "P": "p", "R": "ɹ", "S": "s", + "SH": "ʃ", "T": "t", "TH": "θ", "V": "v", "W": "w", "Y": "j", "Z": "z", "ZH": "ʒ", +} # fmt: skip +# Vowels as (unstressed, stressed) in misaki's American and British alphabets. +_US_VOWELS = { + "AA": ("ɑ", "ɑ"), "AE": ("æ", "æ"), "AH": ("ə", "ʌ"), "AO": ("ɔ", "ɔ"), "AW": ("W", "W"), + "AY": ("I", "I"), "EH": ("ɛ", "ɛ"), "ER": ("əɹ", "ɜɹ"), "EY": ("A", "A"), "IH": ("ɪ", "ɪ"), + "IY": ("i", "i"), "OW": ("O", "O"), "OY": ("Y", "Y"), "UH": ("ʊ", "ʊ"), "UW": ("u", "u"), +} # fmt: skip +_GB_VOWELS = { + **_US_VOWELS, + "AA": ("ɑː", "ɑː"), "AE": ("a", "a"), "AO": ("ɔː", "ɔː"), "ER": ("ə", "ɜː"), + "IY": ("i", "iː"), "OW": ("Q", "Q"), "UW": ("u", "uː"), +} # fmt: skip +_STRESS_MARKS = {"1": "ˈ", "2": "ˌ"} + +# Letters the model has no input symbol for, and that Unicode does not decompose. +_FOLD = str.maketrans( + {"ł": "l", "Ł": "L", "ø": "o", "Ø": "O", "đ": "d", "Đ": "D", "æ": "ae", "Æ": "Ae", "œ": "oe", "Œ": "Oe", "ß": "ss"} +) +_CAMEL_CASE = re.compile(r"(?<=[a-z])(?=[A-Z])") +_NOT_LETTER = re.compile(r"[^A-Za-z']+") +# The model has 128 input positions; real words are far shorter. A longer run of +# letters is read in pieces, and a token yields a bounded number of pieces. +MAX_CHUNK_LETTERS = 48 +MAX_CHUNKS_PER_TOKEN = 8 +# Output cap per chunk: its letters plus this many phonemes stops decoding loops early. +_EXTRA_PHONEMES = 6 +# A unit of up to this many phonemes may appear at most twice in a row. +_MAX_LOOP_UNIT = 4 +_MAX_REPEATS = 2 +# Longest phoneme string one token may produce (one Kokoro forward pass reads 510). +MAX_TOKEN_PHONEMES = 400 +_BATCH_SIZE = 256 +_CACHE_SIZE = 4096 +# spaCy parses kept between the collecting pass and the real pass. +_PARSE_CACHE_SIZE = 64 + +# Symbols said as words inside a token. misaki has words for % & + @ too, but +# spaCy sometimes tags a lone one as punctuation, and misaki then drops it. +_SAY = { + ".": "dot", "/": "slash", "°": "degrees", "=": "equals", "−": "minus", "_": "underscore", + "@": "at", "+": "plus", "&": "and", "%": "percent", +} # fmt: skip +_VOWEL = re.compile(r"[aeiouyAEIOUY]") +_PLAIN_WORD = re.compile(r"[^\W\d_]+(?:['’-][^\W\d_]+)*") +_URL_SCHEME = re.compile(r"^[a-z][a-z0-9+.-]*://", re.IGNORECASE) +_DEGREES = re.compile(r"°([CF])\b") +_DEGREE_UNITS = {"C": "Celsius", "F": "Fahrenheit"} +_DOTTED_LETTERS = re.compile(r"[^\W\d_]\.[^\W\d_]") +_DECIMAL = re.compile(r"(\d+)\.(\d+)") + + +def arpabet_to_misaki(arpabet: Iterable[str], *, british: bool) -> str: + """Map ARPAbet with stress digits to misaki phonemes, stress marks before the vowel.""" + vowels = _GB_VOWELS if british else _US_VOWELS + out: list[str] = [] + for phoneme in arpabet: + base, stress = (phoneme[:-1], phoneme[-1]) if phoneme[-1:].isdigit() else (phoneme, "") + if base in vowels: + unstressed, stressed = vowels[base] + out.append(_STRESS_MARKS.get(stress, "") + (stressed if stress in _STRESS_MARKS else unstressed)) + elif base in _CONSONANTS: + out.append(_CONSONANTS[base]) + return "".join(out) + + +def letter_chunks(text: str) -> list[str]: + """Runs of letters the model reads for one token: accents dropped, CamelCase split, length bounded.""" + text = "".join(c for c in unicodedata.normalize("NFD", text.translate(_FOLD)) if unicodedata.category(c) != "Mn") + chunks: list[str] = [] + for part in _NOT_LETTER.split(_CAMEL_CASE.sub(" ", text)): + part = part.strip("'") + chunks += [part[i : i + MAX_CHUNK_LETTERS] for i in range(0, len(part), MAX_CHUNK_LETTERS)] + return chunks[:MAX_CHUNKS_PER_TOKEN] + + +def limit_repeats(phonemes: Sequence[str]) -> list[str]: + """Drop a third back-to-back copy of any unit of up to four phonemes (stress ignored).""" + out: list[str] = [] + for phoneme in phonemes: + out.append(phoneme) + for n in range(1, _MAX_LOOP_UNIT + 1): + span = n * (_MAX_REPEATS + 1) + tail = [p.rstrip("012") for p in out[-span:]] + if len(tail) == span and all(tail[k] == tail[k % n] for k in range(span)): + del out[-n:] + break + return out + + +def _bounded(phonemes: str) -> str: + if len(phonemes) <= MAX_TOKEN_PHONEMES: + return phonemes + return phonemes[:MAX_TOKEN_PHONEMES].rsplit(" ", 1)[0] + + +class _RecentParses: + """Wraps a spaCy pipeline and returns the same parse for a text seen recently.""" + + def __init__(self, nlp: Callable[[str], Any]) -> None: + self._nlp = nlp + self._docs: OrderedDict[str, Any] = OrderedDict() + self._lock = threading.Lock() + + def __call__(self, text: str) -> Any: + with self._lock: + doc = self._docs.get(text) + if doc is not None: + self._docs.move_to_end(text) + return doc + doc = self._nlp(text) + with self._lock: + self._docs[text] = doc + while len(self._docs) > _PARSE_CACHE_SIZE: + self._docs.popitem(last=False) + return doc + + +class LetterToSound: + """Greedy ARPAbet decoding of ``cisco-ai/mini-bart-g2p`` from a local snapshot, with a bounded cache. + + The model runs on CPU: its cost is per-step overhead, which a GPU does not + reduce, and it does not depend on the CPU thread count. + """ + + def __init__(self, directory: str | Path) -> None: + from transformers import AutoModelForSeq2SeqLM, AutoTokenizer + + self._tokenizer = AutoTokenizer.from_pretrained(str(directory)) + self._model = AutoModelForSeq2SeqLM.from_pretrained(str(directory)).eval() + self._cache: OrderedDict[str, tuple[str, ...]] = OrderedDict() + self._lock = threading.Lock() + + def arpabet(self, chunks: Sequence[str]) -> list[tuple[str, ...]]: + """ARPAbet for each chunk: cached ones from the cache, the rest in batched model calls.""" + # The tokenizer lowercases its input, so the cache does too. + keys = [chunk.lower() for chunk in chunks] + found: dict[str, tuple[str, ...]] = {} + with self._lock: + for key in keys: + if key in self._cache: + self._cache.move_to_end(key) + found[key] = self._cache[key] + missing = [key for key in dict.fromkeys(keys) if key not in found] + if missing: + predicted = dict(zip(missing, self._predict(missing), strict=True)) + found.update(predicted) + with self._lock: + self._cache.update(predicted) + while len(self._cache) > _CACHE_SIZE: + self._cache.popitem(last=False) + return [found[key] for key in keys] + + @torch.inference_mode() + def _predict(self, chunks: list[str]) -> list[tuple[str, ...]]: + out: list[tuple[str, ...]] = [] + for start in range(0, len(chunks), _BATCH_SIZE): + batch = chunks[start : start + _BATCH_SIZE] + inputs = self._tokenizer(batch, return_tensors="pt", padding=True) + # The decoder start id and a leading , then the longest chunk's letters plus the extra phonemes. + max_length = max(map(len, batch)) + _EXTRA_PHONEMES + 2 + ids = self._model.generate( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + num_beams=1, + do_sample=False, + max_length=max_length, + ) + for chunk, decoded in zip(batch, self._tokenizer.batch_decode(ids, skip_special_tokens=True), strict=True): + out.append(tuple(limit_repeats(decoded.split()[: len(chunk) + _EXTRA_PHONEMES]))) + return out + + +class Fallback: + """misaki fallback for one ``en.G2P``: symbol and spelling handling around ``LetterToSound``. + + ``g2p`` is the misaki G2P that calls this fallback; tokens with digits or + symbols are read by calling it again. ``subtokenize`` is misaki's + ``en.subtokenize``. + """ + + def __init__( + self, g2p: Any, letter_to_sound: LetterToSound, *, british: bool, subtokenize: Callable[[str], list[str]] + ) -> None: + self.g2p = g2p + self.letter_to_sound = letter_to_sound + self.british = british + self._subtokenize = subtokenize + if hasattr(g2p, "nlp"): + g2p.nlp = _RecentParses(g2p.nlp) + # Re-entry depth and the collecting pass belong to the calling thread. + self._state = threading.local() + + def prefetch(self, texts: Iterable[str]) -> None: + """Read every letter chunk misaki would ask for in ``texts`` in one batched model call.""" + collected: list[str] = [] + self._state.collected = collected + try: + for text in texts: + self.g2p(text) + finally: + self._state.collected = None + if collected: + self.letter_to_sound.arpabet(collected) + + def __call__(self, token: Any) -> tuple[str | None, int | None]: + depth = getattr(self._state, "depth", 0) + text = token.text + core = text.rstrip(".") # a trailing dot ends a sentence or an abbreviation + if core.isalpha(): + # As a word of its own, Title case (Ms, Hz) and a doubled last letter + # (shh, hmm) go to the model; inside a split token (www) they are spelled. + if ( + len(core) <= 5 + and core.isascii() + and not _VOWEL.search(core) + and (depth or not (core.istitle() or core[-1] == core[-2:-1])) + ): + return self.g2p.lexicon.get_NNP(core) + return self._letters(text) + if depth or _PLAIN_WORD.fullmatch(text): + return self._letters(text) + if not any(c.isalnum() for c in text) and text not in _SAY: + return None, None # "--", "...", "’": only a single listed symbol is said + return self._split(text, depth) + + def _letters(self, text: str) -> tuple[str | None, int | None]: + chunks = letter_chunks(text) + collected = getattr(self._state, "collected", None) + if collected is not None: + collected += chunks + return None, None + if not chunks: + return None, None + spelled = (arpabet_to_misaki(a, british=self.british) for a in self.letter_to_sound.arpabet(chunks)) + phonemes = _bounded(" ".join(p for p in spelled if p)) + return (phonemes, _RATING) if phonemes else (None, None) + + def _split(self, text: str, depth: int) -> tuple[str | None, int | None]: + text = _URL_SCHEME.sub("", text) + text = _DEGREES.sub(lambda m: "°" + _DEGREE_UNITS[m.group(1)], text) + address = "@" in text or _DOTTED_LETTERS.search(text) is not None + parts: list[str] = [] + for part in self._subtokenize(text): + if part in _SAY: + parts.append(_SAY[part]) + elif part == ":" or (part in "-–" and parts): + continue # 5:30 is "five thirty"; ops-team is "ops team" + elif address and part.isalpha() and len(part) <= 2: + parts.append(part.upper()) # short labels (co.uk, .io) are spelled + elif decimal := _DECIMAL.fullmatch(part): + # Every digit after the point is said, trailing zeros included. + parts += [decimal.group(1), "point", *decimal.group(2)] + else: + parts.append(part) + self._state.depth = depth + 1 + try: + phonemes, _ = self.g2p(" ".join(parts)) + finally: + self._state.depth = depth + phonemes = _bounded(phonemes.strip(" .,;:!?")) + return (phonemes, _RATING) if phonemes else (None, None) diff --git a/packages/sie_server/tests/adapters/test_kokoro_g2p.py b/packages/sie_server/tests/adapters/test_kokoro_g2p.py new file mode 100644 index 000000000..24e963778 --- /dev/null +++ b/packages/sie_server/tests/adapters/test_kokoro_g2p.py @@ -0,0 +1,325 @@ +# ruff: noqa: RUF001 +# Phoneme symbols (IPA letters and stress marks) are intentional. +"""Out-of-lexicon fallback of the Kokoro-82M adapter, without misaki or the published weights. + +misaki is stubbed by ``_FakeG2P`` (digits are read as number words, every other word goes to the +fallback) and the letter-to-sound model by ``_FakeLetterToSound`` or a tiny random BART saved locally. +""" + +from __future__ import annotations + +import re +import threading +from pathlib import Path +from types import SimpleNamespace +from typing import Any + +import pytest +import torch +from sie_server.adapters.kokoro import g2p_fallback +from sie_server.adapters.kokoro.g2p_fallback import ( + MAX_CHUNK_LETTERS, + MAX_CHUNKS_PER_TOKEN, + MAX_TOKEN_PHONEMES, + Fallback, + LetterToSound, + arpabet_to_misaki, + letter_chunks, + limit_repeats, +) + +# ARPAbet the fake letter-to-sound model returns, per lowercase chunk. +_ARPABET = { + "zorvexa": ("Z", "AO0", "R", "V", "EH1", "K", "S", "AH0"), + "cat": ("K", "AE1", "T"), + "example": ("IH0", "G", "Z", "AE1", "M", "P", "AH0", "L"), + "com": ("K", "AA1", "M"), + "ops": ("AA1", "P", "S"), + "quark": ("K", "W", "AO1", "R", "K"), + "hmm": ("HH", "M"), +} +_NUMBERS = {"0": "zˈɪɹO", "1": "wˈʌn", "2": "tˈu", "7": "sˈɛvən", "10": "tˈɛn", "5": "fˈIv", "30": "θˈɜɹTi"} +_WORDS = {"dot": "dˈɑt", "slash": "slˈæʃ", "at": "æt", "point": "pˈYnt", "equals": "ˈikwəlz"} + + +class _FakeLetterToSound: + def __init__(self) -> None: + self.calls: list[list[str]] = [] + + def arpabet(self, chunks: list[str]) -> list[tuple[str, ...]]: + self.calls.append(list(chunks)) + return [_ARPABET.get(chunk.lower(), ("AH0",)) for chunk in chunks] + + +class _FakeG2P: + """Stands in for ``misaki.en.G2P``: knows a few words and numbers, asks the fallback for the rest.""" + + def __init__(self) -> None: + self.fallback: Any = None + self.inputs: list[str] = [] + self.lexicon = SimpleNamespace(get_NNP=lambda word: ("-".join(word.upper()), 3)) + + def __call__(self, text: str) -> tuple[str, list[Any]]: + self.inputs.append(text) + out = [] + for word in text.split(): + if word in _NUMBERS or word in _WORDS: + out.append(_NUMBERS.get(word) or _WORDS[word]) + continue + if word.isalpha() and word.isupper() and len(word) <= 2: + out.append(self.lexicon.get_NNP(word)[0]) # misaki spells short capitals itself + continue + phonemes, _ = self.fallback(SimpleNamespace(text=word)) + out.append(phonemes or "") + return " ".join(p for p in out if p), [] + + +def _subtokenize(text: str) -> list[str]: + return re.findall(r"\d+(?:\.\d+)?|[^\W\d_]+|[^\w\s]|_", text) + + +def _fallback(*, british: bool = False) -> tuple[Fallback, _FakeG2P, _FakeLetterToSound]: + g2p, lts = _FakeG2P(), _FakeLetterToSound() + fallback = Fallback(g2p, lts, british=british, subtokenize=_subtokenize) # ty: ignore[invalid-argument-type] + g2p.fallback = fallback + return fallback, g2p, lts + + +def _say(fallback: Fallback, text: str) -> tuple[str | None, int | None]: + return fallback(SimpleNamespace(text=text)) + + +# --------------------------------------------------------------------- pure helpers + + +def test_arpabet_maps_onto_the_american_and_british_alphabets() -> None: + hello = ["HH", "AH0", "L", "OW1"] + assert arpabet_to_misaki(hello, british=False) == "həlˈO" + assert arpabet_to_misaki(hello, british=True) == "həlˈQ" + assert arpabet_to_misaki(["B", "ER1", "D"], british=False) == "bˈɜɹd" + assert arpabet_to_misaki(["B", "ER1", "D"], british=True) == "bˈɜːd" + assert arpabet_to_misaki(["", "a", ""], british=False) == "" + + +def test_letter_chunks_fold_letters_and_split_words() -> None: + assert letter_chunks("Ibáñez-Szczepański") == ["Ibanez", "Szczepanski"] + assert letter_chunks("Tromsø") == ["Tromso"] + assert letter_chunks("Straße") == ["Strasse"] + assert letter_chunks("QuarkLine") == ["Quark", "Line"] + assert letter_chunks("O'Neill's") == ["O'Neill's"] + assert letter_chunks("--") == [] + assert letter_chunks("") == [] + + +def test_letter_chunks_bound_run_length_and_count() -> None: + # Defect: a run of 127 or more letters overflows the model's 128 input positions. + chunks = letter_chunks("a" * 130) + assert [len(chunk) for chunk in chunks] == [48, 48, 34] + assert all(len(chunk) <= MAX_CHUNK_LETTERS for chunk in letter_chunks("x" * 5_000)) + # Defect: the number of chunks per token, and so its phonemes, was unbounded. + assert len(letter_chunks("-".join(["word"] * 100))) == MAX_CHUNKS_PER_TOKEN + assert len(letter_chunks("x" * 5_000)) == MAX_CHUNKS_PER_TOKEN + + +def test_limit_repeats_stops_decoding_loops_and_keeps_doubles() -> None: + # "Llanfairpwllgwyngyll" decodes to ...G W IH NG repeated until the length cap. + loop = ["L", "AE2", "N", "F", "EH1", "R", "P", "AH0", "L", *["G", "W", "IH2", "NG"] * 3, "G", "W", "IH0", "NG"] + assert limit_repeats(loop) == ["L", "AE2", "N", "F", "EH1", "R", "P", "AH0", "L", *["G", "W", "IH2", "NG"] * 2] + bonbon = ["B", "AA1", "N", "B", "AA2", "N"] + assert limit_repeats(bonbon) == bonbon + assert limit_repeats(["Z"] * 6) == ["Z", "Z"] + mississippi = ["M", "IH2", "S", "IH0", "S", "IH1", "P", "IY0"] + assert limit_repeats(mississippi) == mississippi + + +# --------------------------------------------------------------------- the hook, with stubbed models + + +def test_plain_out_of_lexicon_words_go_to_the_model() -> None: + american, _, lts = _fallback() + assert _say(american, "Zorvexa") == ("zɔɹvˈɛksə", 1) + assert _say(american, "cat.") == ("kˈæt", 1) + assert lts.calls == [["Zorvexa"], ["cat"]] + british, _, _ = _fallback(british=True) + assert _say(british, "cat") == ("kˈat", 1) + # A hyphenated word is one token with one chunk per part. + assert _say(american, "Zorvexa-cat") == ("zɔɹvˈɛksə kˈæt", 1) + + +def test_short_words_without_vowels_are_spelled() -> None: + fallback, _, lts = _fallback() + assert _say(fallback, "mg") == ("M-G", 3) + assert _say(fallback, "km.") == ("K-M", 3) + # As words of their own, Title case and a doubled last letter go to the model. + assert _say(fallback, "Hmm") == ("hm", 1) + assert _say(fallback, "Ms")[1] == 1 + assert lts.calls == [["Hmm"], ["Ms"]] + + +def test_tokens_with_symbols_are_split_and_read_again() -> None: + fallback, g2p, _ = _fallback() + assert _say(fallback, "5:30") == ("fˈIv θˈɜɹTi", 1) + assert _say(fallback, "ops@quark.io") == ("ˈɑps æt kwˈɔɹk dˈɑt I-O", 1) + assert g2p.inputs == ["5 30", "ops at quark dot IO"] + + +def test_decimals_keep_trailing_zeros() -> None: + # Defect: "1:10.270" was read "one ten point two seven". + fallback, g2p, _ = _fallback() + phonemes, _ = _say(fallback, "1:10.270") + assert g2p.inputs == ["1 10 point 2 7 0"] + assert phonemes == "wˈʌn tˈɛn pˈYnt tˈu sˈɛvən zˈɪɹO" + + +@pytest.mark.parametrize( + "url", ["https://example.com", "HTTPS://Example.COM", "Https://example.com", "git+ssh://example.com"] +) +def test_url_scheme_is_not_read_in_any_case(url: str) -> None: + # Defect: the scheme was stripped only when lowercase. + fallback, g2p, _ = _fallback() + phonemes, rating = _say(fallback, url) + assert g2p.inputs[0].lower() == "example dot com" + assert (phonemes, rating) == ("ɪɡzˈæmpəl dˈɑt kˈɑm", 1) + + +@pytest.mark.parametrize("text", ["--", "’", "...", "", "—", "@@"]) +def test_empty_and_symbol_only_tokens_stay_silent(text: str) -> None: + fallback, g2p, lts = _fallback() + assert _say(fallback, text) == (None, None) + assert lts.calls == [] + assert g2p.inputs == [] + + +def test_a_single_listed_symbol_is_said() -> None: + fallback, _, _ = _fallback() + assert _say(fallback, "=") == ("ˈikwəlz", 1) + + +def test_one_token_produces_a_bounded_phoneme_string() -> None: + fallback, _, _ = _fallback() + phonemes, _ = _say(fallback, ".".join(["cat"] * 2_000)) + assert phonemes is not None + assert 0 < len(phonemes) <= MAX_TOKEN_PHONEMES + assert not phonemes.endswith(" ") + + +def test_prefetch_reads_every_chunk_in_one_call_then_serves_from_it() -> None: + fallback, g2p, lts = _fallback() + fallback.prefetch(["Zorvexa visited ops@quark.io", "cat"]) + assert lts.calls == [["Zorvexa", "visited", "ops", "quark", "cat"]] + # The real pass asks again token by token (the real model answers from its cache). + g2p("Zorvexa visited ops@quark.io") + assert lts.calls[1:] == [["Zorvexa"], ["visited"], ["ops"], ["quark"]] + assert getattr(fallback._state, "collected", None) is None + + +def test_the_real_pass_reuses_the_collecting_pass_parse() -> None: + g2p, lts = _FakeG2P(), _FakeLetterToSound() + parsed: list[str] = [] + g2p.nlp = lambda text: parsed.append(text) or text # ty: ignore[unresolved-attribute] + fallback = Fallback(g2p, lts, british=False, subtokenize=_subtokenize) # ty: ignore[invalid-argument-type] + for _ in range(3): + assert g2p.nlp("Zorvexa spoke.") == "Zorvexa spoke." # ty: ignore[unresolved-attribute] + assert parsed == ["Zorvexa spoke."] + assert fallback.g2p is g2p + + +def test_reentry_depth_is_per_thread() -> None: + # Defect: the re-entry counter was shared, so another thread inside a split + # token made this thread's "5:30" skip the split and lose its digits. + fallback, g2p, _ = _fallback() + inside, release = threading.Event(), threading.Event() + original = g2p.__call__ + + def slow_g2p(text: str) -> tuple[str, list[Any]]: + if text == "ops at quark dot IO": + inside.set() + assert release.wait(5) + return original(text) + + fallback.g2p = slow_g2p + results: dict[str, Any] = {} + worker = threading.Thread(target=lambda: results.setdefault("a", _say(fallback, "ops@quark.io"))) + worker.start() + assert inside.wait(5) + results["b"] = _say(fallback, "5:30") + release.set() + worker.join(5) + assert results["b"] == ("fˈIv θˈɜɹTi", 1) + assert results["a"] == ("ˈɑps æt kwˈɔɹk dˈɑt I-O", 1) + + +# --------------------------------------------------------------------- LetterToSound with a tiny local BART + +_VOCAB = ["", "", "", "", "", *"abcdefghijklmnopqrstuvwxyz'", "K", "AE1", "T", "AH0"] + + +@pytest.fixture(scope="module") +def tiny_bart(tmp_path_factory: pytest.TempPathFactory) -> Path: + """A mini-bart-g2p-shaped checkpoint: WordLevel character tokenizer, 128 positions, random weights.""" + from tokenizers import Tokenizer, models, normalizers, pre_tokenizers, processors + from transformers import BartConfig, BartForConditionalGeneration, PreTrainedTokenizerFast + + directory = tmp_path_factory.mktemp("tiny_bart") + special = {"bos_token": "", "eos_token": "", "pad_token": "", "unk_token": ""} + tokenizer = Tokenizer(models.WordLevel({t: i for i, t in enumerate(_VOCAB)}, special["unk_token"])) + tokenizer.normalizer = normalizers.Lowercase() # ty: ignore[invalid-assignment] + tokenizer.pre_tokenizer = pre_tokenizers.Split("", behavior="removed") # ty: ignore[invalid-assignment] + tokenizer.post_processor = processors.RobertaProcessing(("", 2), ("", 0)) # ty: ignore[invalid-assignment] + PreTrainedTokenizerFast(tokenizer_object=tokenizer, **special).save_pretrained(directory) + config = BartConfig( + vocab_size=len(_VOCAB), d_model=16, encoder_layers=1, decoder_layers=1, encoder_attention_heads=2, + decoder_attention_heads=2, encoder_ffn_dim=32, decoder_ffn_dim=32, max_position_embeddings=128, + pad_token_id=1, bos_token_id=0, eos_token_id=2, decoder_start_token_id=2, forced_eos_token_id=2, + ) # fmt: skip + torch.manual_seed(0) + model = BartForConditionalGeneration(config) + # Always predict "K": decoding runs to the length cap, like a loop. + with torch.no_grad(): + model.final_logits_bias[0, _VOCAB.index("K")] = 100.0 + model.save_pretrained(directory) + return directory + + +def _count_generate(lts: LetterToSound) -> list[dict[str, Any]]: + calls: list[dict[str, Any]] = [] + generate = lts._model.generate + + def counted(**kwargs: Any) -> Any: + calls.append({"rows": kwargs["input_ids"].shape[0], "max_length": kwargs["max_length"]}) + return generate(**kwargs) + + lts._model.generate = counted # ty: ignore[invalid-assignment] + return calls + + +def test_letter_to_sound_batches_caps_and_caches(tiny_bart: Path) -> None: + lts = LetterToSound(tiny_bart) + calls = _count_generate(lts) + + out = lts.arpabet(["cat", "Zorvexa", "CAT"]) + + # One model call for the two distinct chunks (the cache key is lowercase). + assert calls == [{"rows": 2, "max_length": len("zorvexa") + 8}] + # A run of "K" is capped at the chunk's letters plus six, then cut to two copies. + assert out == [("K", "K"), ("K", "K"), ("K", "K")] + assert lts.arpabet(["zorvexa"]) == [("K", "K")] + assert len(calls) == 1 + + +def test_letter_to_sound_reads_a_130_letter_run(tiny_bart: Path) -> None: + # Defect: 130 letters in one run raised IndexError inside the model. + lts = LetterToSound(tiny_bart) + with pytest.raises(IndexError): + lts.arpabet(["a" * 130]) + assert len(lts.arpabet(letter_chunks("a" * 130))) == 3 + + +def test_letter_to_sound_cache_is_bounded(tiny_bart: Path, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(g2p_fallback, "_CACHE_SIZE", 3) + lts = LetterToSound(tiny_bart) + calls = _count_generate(lts) + assert len(lts.arpabet(["a", "b", "c", "d", "e"])) == 5 + assert len(lts._cache) == 3 + assert lts.arpabet(["e"]) == [("K", "K")] + assert len(calls) == 1 From 5f9c68ea6c16ca1db68a1a644a00371afc5d3c54 Mon Sep 17 00:00:00 2001 From: Shai Shmuel Date: Mon, 30 Nov 2026 13:54:09 +0200 Subject: [PATCH 2/6] feat(server): run Kokoro-82M from adapter-local model code The kokoro package requires misaki[en], which brings in the espeak-ng based phonemizer packages, and its pipeline module imports misaki.espeak unconditionally. Carry the parts of kokoro 0.9.4 (Apache-2.0) the adapter uses instead: the KModel acoustic model with its StyleTTS 2 derived modules (MIT), and an English-only pipeline with kokoro's 510-phoneme chunking. Config, weights and voices are read from the pinned snapshot only. misaki's English G2P is built with the out-of-lexicon fallback, whose letter-to-sound model is a second pinned checkpoint: the loadtime options g2p_model and g2p_revision (cisco-ai/mini-bart-g2p at 0fbbf8c590f9db920939a2bc4befbaac26eebc4c) are resolved in load() through the same checkpoint resolution as the Kokoro snapshot, so nothing is downloaded after load() and an offline server reads both from its cache. The letter-to-sound model runs on CPU and is shared by the American and British pipelines. On CPU, the adapter-local model and pipeline produce the same phonemes and bit-identical audio as kokoro 0.9.4 for the same G2P and random seed. Tests stub the model, pipeline and letter-to-sound model, check that both checkpoints are resolved at their pinned revisions, and load the adapter with a small random-weight checkpoint while misaki.espeak, phonemizer and espeakng_loader cannot be imported. --- .../models/hexgrad__Kokoro-82M.yaml | 5 +- .../src/sie_server/adapters/kokoro/NOTICE | 39 ++ .../src/sie_server/adapters/kokoro/adapter.py | 59 ++- .../sie_server/adapters/kokoro/istftnet.py | 387 ++++++++++++++++++ .../src/sie_server/adapters/kokoro/model.py | 111 +++++ .../src/sie_server/adapters/kokoro/modules.py | 205 ++++++++++ .../sie_server/adapters/kokoro/pipeline.py | 116 ++++++ .../sie_server/tests/adapters/test_kokoro.py | 209 ++++++++-- 8 files changed, 1086 insertions(+), 45 deletions(-) create mode 100644 packages/sie_server/src/sie_server/adapters/kokoro/NOTICE create mode 100644 packages/sie_server/src/sie_server/adapters/kokoro/istftnet.py create mode 100644 packages/sie_server/src/sie_server/adapters/kokoro/model.py create mode 100644 packages/sie_server/src/sie_server/adapters/kokoro/modules.py create mode 100644 packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py diff --git a/packages/sie_server/models/hexgrad__Kokoro-82M.yaml b/packages/sie_server/models/hexgrad__Kokoro-82M.yaml index c7ad9ecf7..066b9e9df 100644 --- a/packages/sie_server/models/hexgrad__Kokoro-82M.yaml +++ b/packages/sie_server/models/hexgrad__Kokoro-82M.yaml @@ -19,5 +19,8 @@ profiles: compute_precision: float32 adapter_path: sie_server.adapters.kokoro.adapter:KokoroAdapter adapter_options: - loadtime: {} + loadtime: + # Letter-to-sound model for words outside misaki's lexicon. + g2p_model: cisco-ai/mini-bart-g2p + g2p_revision: 0fbbf8c590f9db920939a2bc4befbaac26eebc4c runtime: {} diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/NOTICE b/packages/sie_server/src/sie_server/adapters/kokoro/NOTICE new file mode 100644 index 000000000..052178061 --- /dev/null +++ b/packages/sie_server/src/sie_server/adapters/kokoro/NOTICE @@ -0,0 +1,39 @@ +The Kokoro-82M model code in this directory (istftnet.py, modules.py, model.py, +pipeline.py) is adapted from kokoro 0.9.4 by hexgrad (Apache-2.0): +https://github.com/hexgrad/kokoro +https://pypi.org/project/kokoro/0.9.4/ + +Parts of that code (istftnet.py, modules.py) are in turn adapted from StyleTTS 2 +(MIT): https://github.com/yl4579/StyleTTS2 + +Changes from the originals are described at the top of each file. + +g2p_fallback.py runs the cisco-ai/mini-bart-g2p model (Apache-2.0), which the +adapter loads from the Hugging Face Hub at a pinned revision; its weights are +not part of this repository: +https://huggingface.co/cisco-ai/mini-bart-g2p + +The Apache-2.0 license text is in the LICENSE file at the root of this +repository. The StyleTTS 2 license follows. + +MIT License + +Copyright (c) 2023 Aaron (Yinghao) Li + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/adapter.py b/packages/sie_server/src/sie_server/adapters/kokoro/adapter.py index 40c73a6e8..8563ebe82 100644 --- a/packages/sie_server/src/sie_server/adapters/kokoro/adapter.py +++ b/packages/sie_server/src/sie_server/adapters/kokoro/adapter.py @@ -1,10 +1,13 @@ """Kokoro-82M text-to-speech adapter implemented on the native extract primitive. ``hexgrad/Kokoro-82M`` turns text into 24 kHz mono speech. Each text item is -one utterance: the ``kokoro`` pipeline converts it to phonemes with ``misaki`` -(spaCy tagging plus a lexicon, with espeak-ng for out-of-lexicon words), splits -the phonemes into chunks of at most 510, and synthesizes each chunk with -``KModel``. The adapter joins the chunks' audio and returns, per item:: +one utterance: ``misaki`` converts it to phonemes (spaCy tagging plus a +lexicon), the pipeline splits the phonemes into chunks of at most 510, and +``KModel`` synthesizes each chunk. Words outside the lexicon are read by +``g2p_fallback``: symbols and short consonant-only words are handled there, the +rest by the ``cisco-ai/mini-bart-g2p`` letter-to-sound model (Apache-2.0). The +model and pipeline code is adapted from the ``kokoro`` package (see ``NOTICE``). +The adapter joins the chunks' audio and returns, per item:: {"audio": , "format": "wav", "sample_rate": 24000, "duration_ms": ..., "voice": ...} @@ -27,8 +30,11 @@ ``INPUT_TOO_LONG``; the rest of the batch is synthesized. The defaults keep one item under four minutes of audio, about 15 MB once base64-encoded. -Weights, config and voices come from one pinned snapshot; the adapter never -downloads anything after ``load()``. +Kokoro's weights, config and voices come from one pinned snapshot, and the +letter-to-sound model from a second one (loadtime options ``g2p_model`` and +``g2p_revision``). Both are resolved in ``load()`` under the server's cache +policy; the adapter never downloads anything after ``load()``. The +letter-to-sound model runs on CPU. """ from __future__ import annotations @@ -47,6 +53,9 @@ from sie_server.adapters._checkpoint import resolve_checkpoint from sie_server.adapters._spec import AdapterSpec from sie_server.adapters._types import ERR_NOT_LOADED +from sie_server.adapters.kokoro.g2p_fallback import LetterToSound +from sie_server.adapters.kokoro.model import KModel +from sie_server.adapters.kokoro.pipeline import EnglishPipeline from sie_server.core.inference_output import EncodeOutput, ExtractItemError, ExtractOutput from sie_server.types.inputs import InvalidInputError from sie_server.types.responses import ErrorCode @@ -66,8 +75,18 @@ _CHECKPOINT_FILES = ("config.json", "kokoro-v1_0.pth", "voices/*.pt") _WEIGHTS_FILE = "kokoro-v1_0.pth" -_REPO_ID = "hexgrad/Kokoro-82M" -# Kokoro language codes this adapter serves, with the aliases ``kokoro`` accepts. +DEFAULT_G2P_MODEL = "cisco-ai/mini-bart-g2p" +DEFAULT_G2P_REVISION = "0fbbf8c590f9db920939a2bc4befbaac26eebc4c" +_G2P_FILES = ( + "config.json", + "generation_config.json", + "model.safetensors", + "special_tokens_map.json", + "tokenizer.json", + "tokenizer_config.json", + "vocab.json", +) +# Kokoro language codes this adapter serves, with their aliases. _LANGS = {"a": "a", "b": "b", "en-us": "a", "en-gb": "b"} _RUNTIME_OPTIONS = frozenset({"voice", "speed", "lang"}) # ``KModel.forward`` wraps every chunk's phoneme ids in one start and one end id. @@ -92,6 +111,8 @@ def __init__( revision: str | None = None, max_chars_per_item: int = DEFAULT_MAX_CHARS_PER_ITEM, max_audio_ms: int = DEFAULT_MAX_AUDIO_MS, + g2p_model: str = DEFAULT_G2P_MODEL, + g2p_revision: str | None = DEFAULT_G2P_REVISION, **kwargs: Any, ) -> None: del kwargs @@ -105,17 +126,18 @@ def __init__( self._revision = revision self._max_chars_per_item = max_chars_per_item self._max_audio_ms = max_audio_ms + self._g2p_model = g2p_model + self._g2p_revision = g2p_revision self._model: Any = None self._pipelines: dict[str, Any] | None = None self._voices: dict[str, Path] | None = None self._device: str | None = None def load(self, device: str) -> None: - from kokoro import KModel, KPipeline # ty: ignore[unresolved-import] - directory = resolve_checkpoint( self._model_name_or_path, revision=self._revision, allow_patterns=_CHECKPOINT_FILES ) + g2p_directory = resolve_checkpoint(self._g2p_model, revision=self._g2p_revision, allow_patterns=_G2P_FILES) voices = {path.stem: path for path in sorted((directory / "voices").glob("*.pt"))} if DEFAULT_VOICE not in voices: msg = f"Kokoro checkpoint {directory} has no voices/{DEFAULT_VOICE}.pt" @@ -123,17 +145,18 @@ def load(self, device: str) -> None: logger.info( "Loading Kokoro model %s on device=%s with %d voices", self._model_name_or_path, device, len(voices) ) - model = KModel( - repo_id=_REPO_ID, - config=str(directory / "config.json"), - model=str(directory / _WEIGHTS_FILE), - ) + model = KModel(config=directory / "config.json", model=directory / _WEIGHTS_FILE) self._model = model.to(device).eval() self._device = device self._voices = voices - # One G2P pipeline per language, sharing the model. Building one loads - # spaCy, so both are built here rather than on a first request. - self._pipelines = {code: KPipeline(lang_code=code, repo_id=_REPO_ID, model=self._model) for code in ("a", "b")} + # One G2P pipeline per language, sharing the model and the letter-to-sound + # model. Building one loads spaCy, so both are built here rather than on a + # first request. + letter_to_sound = LetterToSound(g2p_directory) + self._pipelines = { + code: EnglishPipeline(self._model, british=code == "b", letter_to_sound=letter_to_sound) + for code in ("a", "b") + } def encode( self, diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/istftnet.py b/packages/sie_server/src/sie_server/adapters/kokoro/istftnet.py new file mode 100644 index 000000000..a6fc64dcc --- /dev/null +++ b/packages/sie_server/src/sie_server/adapters/kokoro/istftnet.py @@ -0,0 +1,387 @@ +"""iSTFTNet decoder of Kokoro-82M. + +Adapted from ``kokoro/istftnet.py`` of kokoro 0.9.4 (https://github.com/hexgrad/kokoro, +Apache-2.0), itself adapted from StyleTTS 2 (https://github.com/yl4579/StyleTTS2, MIT). +See ``NOTICE`` in this directory. Changes: inference only, type annotations, the +complex-free STFT and pulse-train code paths removed, and weight initialisation +dropped because every parameter is loaded from the checkpoint. + +Module and attribute names match the checkpoint's state dict and must not change. +""" + +from __future__ import annotations + +import math + +import torch +import torch.nn.functional as F +from torch import nn +from torch.nn.utils import weight_norm + + +def get_padding(kernel_size: int, dilation: int = 1) -> int: + return (kernel_size * dilation - dilation) // 2 + + +class AdaIN1d(nn.Module): + def __init__(self, style_dim: int, num_features: int) -> None: + super().__init__() + # The checkpoint was trained with affine=False but stores the affine + # parameters; upstream keeps affine=True so they load. + self.norm = nn.InstanceNorm1d(num_features, affine=True) + self.fc = nn.Linear(style_dim, num_features * 2) + + def forward(self, x: torch.Tensor, s: torch.Tensor) -> torch.Tensor: + h = self.fc(s) + h = h.view(h.size(0), h.size(1), 1) + gamma, beta = torch.chunk(h, chunks=2, dim=1) + return (1 + gamma) * self.norm(x) + beta + + +class AdaINResBlock1(nn.Module): + def __init__( + self, channels: int, kernel_size: int = 3, dilation: tuple[int, ...] = (1, 3, 5), style_dim: int = 64 + ) -> None: + super().__init__() + self.convs1 = nn.ModuleList( + [ + weight_norm( + nn.Conv1d(channels, channels, kernel_size, 1, dilation=d, padding=get_padding(kernel_size, d)) + ) + for d in dilation[:3] + ] + ) + self.convs2 = nn.ModuleList( + [ + weight_norm( + nn.Conv1d(channels, channels, kernel_size, 1, dilation=1, padding=get_padding(kernel_size, 1)) + ) + for _ in range(3) + ] + ) + self.adain1 = nn.ModuleList([AdaIN1d(style_dim, channels) for _ in range(3)]) + self.adain2 = nn.ModuleList([AdaIN1d(style_dim, channels) for _ in range(3)]) + self.alpha1 = nn.ParameterList([nn.Parameter(torch.ones(1, channels, 1)) for _ in range(3)]) + self.alpha2 = nn.ParameterList([nn.Parameter(torch.ones(1, channels, 1)) for _ in range(3)]) + + def forward(self, x: torch.Tensor, s: torch.Tensor) -> torch.Tensor: + for c1, c2, n1, n2, a1, a2 in zip( + self.convs1, self.convs2, self.adain1, self.adain2, self.alpha1, self.alpha2, strict=True + ): + xt = n1(x, s) + xt = xt + (1 / a1) * (torch.sin(a1 * xt) ** 2) # Snake1D + xt = c1(xt) + xt = n2(xt, s) + xt = xt + (1 / a2) * (torch.sin(a2 * xt) ** 2) # Snake1D + xt = c2(xt) + x = xt + x + return x + + +class TorchSTFT(nn.Module): + def __init__(self, filter_length: int = 800, hop_length: int = 200, win_length: int = 800) -> None: + super().__init__() + self.filter_length = filter_length + self.hop_length = hop_length + self.win_length = win_length + self.window = torch.hann_window(win_length, periodic=True, dtype=torch.float32) + + def transform(self, input_data: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: + forward_transform = torch.stft( + input_data, + self.filter_length, + self.hop_length, + self.win_length, + window=self.window.to(input_data.device), + return_complex=True, + ) + return torch.abs(forward_transform), torch.angle(forward_transform) + + def inverse(self, magnitude: torch.Tensor, phase: torch.Tensor) -> torch.Tensor: + inverse_transform = torch.istft( + magnitude * torch.exp(phase * 1j), + self.filter_length, + self.hop_length, + self.win_length, + window=self.window.to(magnitude.device), + ) + return inverse_transform.unsqueeze(-2) + + +class SineGen(nn.Module): + """Sine-wave source with harmonics for the neural source-filter vocoder.""" + + def __init__( + self, + samp_rate: int, + upsample_scale: int, + harmonic_num: int = 0, + sine_amp: float = 0.1, + noise_std: float = 0.003, + voiced_threshold: float = 0, + ) -> None: + super().__init__() + self.sine_amp = sine_amp + self.noise_std = noise_std + self.harmonic_num = harmonic_num + self.dim = self.harmonic_num + 1 + self.sampling_rate = samp_rate + self.voiced_threshold = voiced_threshold + self.upsample_scale = upsample_scale + + def _f02uv(self, f0: torch.Tensor) -> torch.Tensor: + return (f0 > self.voiced_threshold).type(torch.float32) + + def _f02sine(self, f0_values: torch.Tensor) -> torch.Tensor: + rad_values = (f0_values / self.sampling_rate) % 1 + # Random initial phase for the overtones, none for the fundamental. + rand_ini = torch.rand(f0_values.shape[0], f0_values.shape[2], device=f0_values.device) + rand_ini[:, 0] = 0 + rad_values[:, 0, :] = rad_values[:, 0, :] + rand_ini + rad_values = F.interpolate( + rad_values.transpose(1, 2), scale_factor=1 / self.upsample_scale, mode="linear" + ).transpose(1, 2) + phase = torch.cumsum(rad_values, dim=1) * 2 * torch.pi + phase = F.interpolate( + phase.transpose(1, 2) * self.upsample_scale, scale_factor=self.upsample_scale, mode="linear" + ).transpose(1, 2) + return torch.sin(phase) + + def forward(self, f0: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]: + harmonics = torch.FloatTensor([[list(range(1, self.harmonic_num + 2))]]).to(f0.device) + fn = torch.multiply(f0, harmonics) + sine_waves = self._f02sine(fn) * self.sine_amp + uv = self._f02uv(f0) + noise_amp = uv * self.noise_std + (1 - uv) * self.sine_amp / 3 + noise = noise_amp * torch.randn_like(sine_waves) + sine_waves = sine_waves * uv + noise + return sine_waves, uv, noise + + +class SourceModuleHnNSF(nn.Module): + def __init__( + self, + sampling_rate: int, + upsample_scale: int, + harmonic_num: int = 0, + sine_amp: float = 0.1, + add_noise_std: float = 0.003, + voiced_threshod: float = 0, + ) -> None: + super().__init__() + self.sine_amp = sine_amp + self.noise_std = add_noise_std + self.l_sin_gen = SineGen(sampling_rate, upsample_scale, harmonic_num, sine_amp, add_noise_std, voiced_threshod) + self.l_linear = nn.Linear(harmonic_num + 1, 1) + self.l_tanh = nn.Tanh() + + def forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]: + with torch.no_grad(): + sine_wavs, uv, _ = self.l_sin_gen(x) + sine_merge = self.l_tanh(self.l_linear(sine_wavs)) + noise = torch.randn_like(uv) * self.sine_amp / 3 + return sine_merge, noise, uv + + +class Generator(nn.Module): + def __init__( + self, + style_dim: int, + resblock_kernel_sizes: list[int], + upsample_rates: list[int], + upsample_initial_channel: int, + resblock_dilation_sizes: list[list[int]], + upsample_kernel_sizes: list[int], + gen_istft_n_fft: int, + gen_istft_hop_size: int, + ) -> None: + super().__init__() + self.num_kernels = len(resblock_kernel_sizes) + self.num_upsamples = len(upsample_rates) + self.m_source = SourceModuleHnNSF( + sampling_rate=24000, + upsample_scale=math.prod(upsample_rates) * gen_istft_hop_size, + harmonic_num=8, + voiced_threshod=10, + ) + self.f0_upsamp = nn.Upsample(scale_factor=math.prod(upsample_rates) * gen_istft_hop_size) + self.noise_convs = nn.ModuleList() + self.noise_res = nn.ModuleList() + self.ups = nn.ModuleList() + for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes, strict=True)): + self.ups.append( + weight_norm( + nn.ConvTranspose1d( + upsample_initial_channel // (2**i), + upsample_initial_channel // (2 ** (i + 1)), + k, + u, + padding=(k - u) // 2, + ) + ) + ) + self.resblocks = nn.ModuleList() + ch = upsample_initial_channel + for i in range(len(self.ups)): + ch = upsample_initial_channel // (2 ** (i + 1)) + for k, d in zip(resblock_kernel_sizes, resblock_dilation_sizes, strict=True): + self.resblocks.append(AdaINResBlock1(ch, k, tuple(d), style_dim)) + if i + 1 < len(upsample_rates): + stride_f0 = math.prod(upsample_rates[i + 1 :]) + self.noise_convs.append( + nn.Conv1d( + gen_istft_n_fft + 2, + ch, + kernel_size=stride_f0 * 2, + stride=stride_f0, + padding=(stride_f0 + 1) // 2, + ) + ) + self.noise_res.append(AdaINResBlock1(ch, 7, (1, 3, 5), style_dim)) + else: + self.noise_convs.append(nn.Conv1d(gen_istft_n_fft + 2, ch, kernel_size=1)) + self.noise_res.append(AdaINResBlock1(ch, 11, (1, 3, 5), style_dim)) + self.post_n_fft = gen_istft_n_fft + self.conv_post = weight_norm(nn.Conv1d(ch, self.post_n_fft + 2, 7, 1, padding=3)) + self.reflection_pad = nn.ReflectionPad1d((1, 0)) + self.stft = TorchSTFT(filter_length=gen_istft_n_fft, hop_length=gen_istft_hop_size, win_length=gen_istft_n_fft) + + def forward(self, x: torch.Tensor, s: torch.Tensor, f0: torch.Tensor) -> torch.Tensor: + with torch.no_grad(): + f0 = self.f0_upsamp(f0[:, None]).transpose(1, 2) + har_source, _, _ = self.m_source(f0) + har_source = har_source.transpose(1, 2).squeeze(1) + har_spec, har_phase = self.stft.transform(har_source) + har = torch.cat([har_spec, har_phase], dim=1) + for i in range(self.num_upsamples): + x = F.leaky_relu(x, negative_slope=0.1) + x_source = self.noise_convs[i](har) + x_source = self.noise_res[i](x_source, s) + x = self.ups[i](x) + if i == self.num_upsamples - 1: + x = self.reflection_pad(x) + x = x + x_source + xs = self.resblocks[i * self.num_kernels](x, s) + for j in range(1, self.num_kernels): + xs += self.resblocks[i * self.num_kernels + j](x, s) + x = xs / self.num_kernels + x = F.leaky_relu(x) + x = self.conv_post(x) + spec = torch.exp(x[:, : self.post_n_fft // 2 + 1, :]) + phase = torch.sin(x[:, self.post_n_fft // 2 + 1 :, :]) + return self.stft.inverse(spec, phase) + + +class UpSample1d(nn.Module): + def __init__(self, layer_type: str | bool) -> None: + super().__init__() + self.layer_type = layer_type + + def forward(self, x: torch.Tensor) -> torch.Tensor: + if self.layer_type == "none": + return x + return F.interpolate(x, scale_factor=2, mode="nearest") + + +class AdainResBlk1d(nn.Module): + def __init__( + self, + dim_in: int, + dim_out: int, + style_dim: int = 64, + actv: nn.Module | None = None, + upsample: str | bool = "none", + dropout_p: float = 0.0, + ) -> None: + super().__init__() + self.actv = actv if actv is not None else nn.LeakyReLU(0.2) + self.upsample_type = upsample + self.upsample = UpSample1d(upsample) + self.learned_sc = dim_in != dim_out + self.conv1 = weight_norm(nn.Conv1d(dim_in, dim_out, 3, 1, 1)) + self.conv2 = weight_norm(nn.Conv1d(dim_out, dim_out, 3, 1, 1)) + self.norm1 = AdaIN1d(style_dim, dim_in) + self.norm2 = AdaIN1d(style_dim, dim_out) + if self.learned_sc: + self.conv1x1 = weight_norm(nn.Conv1d(dim_in, dim_out, 1, 1, 0, bias=False)) + self.dropout = nn.Dropout(dropout_p) + if upsample == "none": + self.pool: nn.Module = nn.Identity() + else: + self.pool = weight_norm( + nn.ConvTranspose1d(dim_in, dim_in, kernel_size=3, stride=2, groups=dim_in, padding=1, output_padding=1) + ) + + def _shortcut(self, x: torch.Tensor) -> torch.Tensor: + x = self.upsample(x) + if self.learned_sc: + x = self.conv1x1(x) + return x + + def _residual(self, x: torch.Tensor, s: torch.Tensor) -> torch.Tensor: + x = self.norm1(x, s) + x = self.actv(x) + x = self.pool(x) + x = self.conv1(self.dropout(x)) + x = self.norm2(x, s) + x = self.actv(x) + return self.conv2(self.dropout(x)) + + def forward(self, x: torch.Tensor, s: torch.Tensor) -> torch.Tensor: + out = self._residual(x, s) + return (out + self._shortcut(x)) * torch.rsqrt(torch.tensor(2)) + + +class Decoder(nn.Module): + def __init__( + self, + dim_in: int, + style_dim: int, + dim_out: int, + resblock_kernel_sizes: list[int], + upsample_rates: list[int], + upsample_initial_channel: int, + resblock_dilation_sizes: list[list[int]], + upsample_kernel_sizes: list[int], + gen_istft_n_fft: int, + gen_istft_hop_size: int, + ) -> None: + super().__init__() + del dim_out + self.encode = AdainResBlk1d(dim_in + 2, 1024, style_dim) + self.decode = nn.ModuleList( + [ + AdainResBlk1d(1024 + 2 + 64, 1024, style_dim), + AdainResBlk1d(1024 + 2 + 64, 1024, style_dim), + AdainResBlk1d(1024 + 2 + 64, 1024, style_dim), + AdainResBlk1d(1024 + 2 + 64, 512, style_dim, upsample=True), + ] + ) + self.F0_conv = weight_norm(nn.Conv1d(1, 1, kernel_size=3, stride=2, groups=1, padding=1)) + self.N_conv = weight_norm(nn.Conv1d(1, 1, kernel_size=3, stride=2, groups=1, padding=1)) + self.asr_res = nn.Sequential(weight_norm(nn.Conv1d(512, 64, kernel_size=1))) + self.generator = Generator( + style_dim, + resblock_kernel_sizes, + upsample_rates, + upsample_initial_channel, + resblock_dilation_sizes, + upsample_kernel_sizes, + gen_istft_n_fft, + gen_istft_hop_size, + ) + + def forward(self, asr: torch.Tensor, f0_curve: torch.Tensor, n: torch.Tensor, s: torch.Tensor) -> torch.Tensor: + f0 = self.F0_conv(f0_curve.unsqueeze(1)) + n = self.N_conv(n.unsqueeze(1)) + x = torch.cat([asr, f0, n], dim=1) + x = self.encode(x, s) + asr_res = self.asr_res(asr) + res = True + for block in self.decode: + if res: + x = torch.cat([x, asr_res, f0, n], dim=1) + x = block(x, s) + if block.upsample_type != "none": + res = False + return self.generator(x, s, f0_curve) diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/model.py b/packages/sie_server/src/sie_server/adapters/kokoro/model.py new file mode 100644 index 000000000..8faa7df84 --- /dev/null +++ b/packages/sie_server/src/sie_server/adapters/kokoro/model.py @@ -0,0 +1,111 @@ +"""Kokoro-82M acoustic model: phonemes and a voice embedding in, 24 kHz audio out. + +Adapted from ``kokoro/model.py`` of kokoro 0.9.4 (https://github.com/hexgrad/kokoro, +Apache-2.0). See ``NOTICE`` in this directory. Changes: config and weights are read +from local paths only (no Hub download), inference only, type annotations, and the +ONNX wrapper removed. +""" + +from __future__ import annotations + +import json +from pathlib import Path +from typing import Any + +import torch +from torch import nn +from transformers import AlbertConfig + +from sie_server.adapters.kokoro.istftnet import Decoder +from sie_server.adapters.kokoro.modules import CustomAlbert, ProsodyPredictor, TextEncoder + +_MODULE_PREFIX = "module." + + +class KModel(nn.Module): + """Language-blind Kokoro synthesizer; one phoneme sequence per forward pass.""" + + def __init__(self, config: str | Path | dict[str, Any], model: str | Path) -> None: + super().__init__() + if not isinstance(config, dict): + with Path(config).open(encoding="utf-8") as reader: + config = json.load(reader) + self.vocab: dict[str, int] = config["vocab"] + self.bert = CustomAlbert(AlbertConfig(vocab_size=config["n_token"], **config["plbert"])) + self.bert_encoder = nn.Linear(self.bert.config.hidden_size, config["hidden_dim"]) + self.context_length: int = self.bert.config.max_position_embeddings + self.predictor = ProsodyPredictor( + style_dim=config["style_dim"], + d_hid=config["hidden_dim"], + nlayers=config["n_layer"], + max_dur=config["max_dur"], + dropout=config["dropout"], + ) + self.text_encoder = TextEncoder( + channels=config["hidden_dim"], + kernel_size=config["text_encoder_kernel_size"], + depth=config["n_layer"], + n_symbols=config["n_token"], + ) + self.decoder = Decoder( + dim_in=config["hidden_dim"], style_dim=config["style_dim"], dim_out=config["n_mels"], **config["istftnet"] + ) + checkpoint = torch.load(str(model), map_location="cpu", weights_only=True) + for key, state_dict in checkpoint.items(): + module = getattr(self, key, None) + if not isinstance(module, nn.Module): + msg = f"Kokoro checkpoint has an unknown component {key!r}" + raise ValueError(msg) + try: + module.load_state_dict(state_dict) + except RuntimeError: + # The released checkpoint stores DataParallel names ("module." prefix). + stripped = {k.removeprefix(_MODULE_PREFIX): v for k, v in state_dict.items()} + module.load_state_dict(stripped, strict=False) + + @property + def device(self) -> torch.device: + return self.bert.device + + @torch.no_grad() + def forward_with_tokens( + self, input_ids: torch.Tensor, ref_s: torch.Tensor, speed: float = 1 + ) -> tuple[torch.Tensor, torch.Tensor]: + input_lengths = torch.full( + (input_ids.shape[0],), input_ids.shape[-1], device=input_ids.device, dtype=torch.long + ) + text_mask = ( + torch.arange(int(input_lengths.max())) + .unsqueeze(0) + .expand(input_lengths.shape[0], -1) + .type_as(input_lengths) + ) + text_mask = torch.gt(text_mask + 1, input_lengths.unsqueeze(1)).to(self.device) + bert_dur = self.bert(input_ids, attention_mask=(~text_mask).int()) + d_en = self.bert_encoder(bert_dur).transpose(-1, -2) + s = ref_s[:, 128:] + d = self.predictor.text_encoder(d_en, s, input_lengths, text_mask) + x, _ = self.predictor.lstm(d) + duration = self.predictor.duration_proj(x) + duration = torch.sigmoid(duration).sum(dim=-1) / speed + pred_dur = torch.round(duration).clamp(min=1).long().squeeze() + indices = torch.repeat_interleave(torch.arange(input_ids.shape[1], device=self.device), pred_dur) + pred_aln_trg = torch.zeros((input_ids.shape[1], indices.shape[0]), device=self.device) + pred_aln_trg[indices, torch.arange(indices.shape[0])] = 1 + pred_aln_trg = pred_aln_trg.unsqueeze(0).to(self.device) + en = d.transpose(-1, -2) @ pred_aln_trg + f0_pred, n_pred = self.predictor.F0Ntrain(en, s) + t_en = self.text_encoder(input_ids, input_lengths, text_mask) + asr = t_en @ pred_aln_trg + audio = self.decoder(asr, f0_pred, n_pred, ref_s[:, :128]).squeeze() + return audio, pred_dur + + def forward(self, phonemes: str, ref_s: torch.Tensor, speed: float = 1) -> torch.Tensor: + """Audio for one phoneme string; characters outside the vocabulary are skipped.""" + input_ids = [self.vocab[p] for p in phonemes if p in self.vocab] + if len(input_ids) + 2 > self.context_length: + msg = f"{len(input_ids) + 2} phoneme ids exceed the context length {self.context_length}" + raise ValueError(msg) + ids = torch.LongTensor([[0, *input_ids, 0]]).to(self.device) + audio, _ = self.forward_with_tokens(ids, ref_s.to(self.device), speed) + return audio.squeeze().cpu() diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/modules.py b/packages/sie_server/src/sie_server/adapters/kokoro/modules.py new file mode 100644 index 000000000..677ba0daf --- /dev/null +++ b/packages/sie_server/src/sie_server/adapters/kokoro/modules.py @@ -0,0 +1,205 @@ +"""Text encoder, prosody predictor and ALBERT wrapper of Kokoro-82M. + +Adapted from ``kokoro/modules.py`` of kokoro 0.9.4 (https://github.com/hexgrad/kokoro, +Apache-2.0), itself adapted from StyleTTS 2 (https://github.com/yl4579/StyleTTS2, MIT). +See ``NOTICE`` in this directory. Changes: inference only, type annotations, the +unused training-time ``ProsodyPredictor.forward`` removed, and weight initialisation +dropped because every parameter is loaded from the checkpoint. + +Module and attribute names match the checkpoint's state dict and must not change. +""" + +from __future__ import annotations + +from typing import Any + +import torch +import torch.nn.functional as F +from torch import nn +from torch.nn.utils import weight_norm +from transformers import AlbertModel + +from sie_server.adapters.kokoro.istftnet import AdainResBlk1d + + +def _cpu_lengths(lengths: torch.Tensor) -> torch.Tensor: + return lengths if lengths.device == torch.device("cpu") else lengths.to("cpu") + + +class LinearNorm(nn.Module): + def __init__(self, in_dim: int, out_dim: int, bias: bool = True) -> None: + super().__init__() + self.linear_layer = nn.Linear(in_dim, out_dim, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + return self.linear_layer(x) + + +class LayerNorm(nn.Module): + def __init__(self, channels: int, eps: float = 1e-5) -> None: + super().__init__() + self.channels = channels + self.eps = eps + self.gamma = nn.Parameter(torch.ones(channels)) + self.beta = nn.Parameter(torch.zeros(channels)) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + x = x.transpose(1, -1) + x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps) + return x.transpose(1, -1) + + +class TextEncoder(nn.Module): + def __init__(self, channels: int, kernel_size: int, depth: int, n_symbols: int) -> None: + super().__init__() + self.embedding = nn.Embedding(n_symbols, channels) + padding = (kernel_size - 1) // 2 + actv = nn.LeakyReLU(0.2) + self.cnn = nn.ModuleList( + [ + nn.Sequential( + weight_norm(nn.Conv1d(channels, channels, kernel_size=kernel_size, padding=padding)), + LayerNorm(channels), + actv, + nn.Dropout(0.2), + ) + for _ in range(depth) + ] + ) + self.lstm = nn.LSTM(channels, channels // 2, 1, batch_first=True, bidirectional=True) + + def forward(self, x: torch.Tensor, input_lengths: torch.Tensor, m: torch.Tensor) -> torch.Tensor: + x = self.embedding(x) # [B, T, emb] + x = x.transpose(1, 2) # [B, emb, T] + m = m.unsqueeze(1) + x.masked_fill_(m, 0.0) + for c in self.cnn: + x = c(x) + x.masked_fill_(m, 0.0) + x = x.transpose(1, 2) # [B, T, chn] + packed = nn.utils.rnn.pack_padded_sequence( + x, _cpu_lengths(input_lengths), batch_first=True, enforce_sorted=False + ) + self.lstm.flatten_parameters() + packed, _ = self.lstm(packed) + x, _ = nn.utils.rnn.pad_packed_sequence(packed, batch_first=True) + x = x.transpose(-1, -2) + x_pad = torch.zeros([x.shape[0], x.shape[1], m.shape[-1]], device=x.device) + x_pad[:, :, : x.shape[-1]] = x + x_pad.masked_fill_(m, 0.0) + return x_pad + + +class AdaLayerNorm(nn.Module): + def __init__(self, style_dim: int, channels: int, eps: float = 1e-5) -> None: + super().__init__() + self.channels = channels + self.eps = eps + self.fc = nn.Linear(style_dim, channels * 2) + + def forward(self, x: torch.Tensor, s: torch.Tensor) -> torch.Tensor: + x = x.transpose(-1, -2) + x = x.transpose(1, -1) + h = self.fc(s) + h = h.view(h.size(0), h.size(1), 1) + gamma, beta = torch.chunk(h, chunks=2, dim=1) + gamma, beta = gamma.transpose(1, -1), beta.transpose(1, -1) + x = F.layer_norm(x, (self.channels,), eps=self.eps) + x = (1 + gamma) * x + beta + return x.transpose(1, -1).transpose(-1, -2) + + +class ProsodyPredictor(nn.Module): + def __init__(self, style_dim: int, d_hid: int, nlayers: int, max_dur: int = 50, dropout: float = 0.1) -> None: + super().__init__() + self.text_encoder = DurationEncoder(sty_dim=style_dim, d_model=d_hid, nlayers=nlayers, dropout=dropout) + self.lstm = nn.LSTM(d_hid + style_dim, d_hid // 2, 1, batch_first=True, bidirectional=True) + self.duration_proj = LinearNorm(d_hid, max_dur) + self.shared = nn.LSTM(d_hid + style_dim, d_hid // 2, 1, batch_first=True, bidirectional=True) + self.F0 = nn.ModuleList( + [ + AdainResBlk1d(d_hid, d_hid, style_dim, dropout_p=dropout), + AdainResBlk1d(d_hid, d_hid // 2, style_dim, upsample=True, dropout_p=dropout), + AdainResBlk1d(d_hid // 2, d_hid // 2, style_dim, dropout_p=dropout), + ] + ) + self.N = nn.ModuleList( + [ + AdainResBlk1d(d_hid, d_hid, style_dim, dropout_p=dropout), + AdainResBlk1d(d_hid, d_hid // 2, style_dim, upsample=True, dropout_p=dropout), + AdainResBlk1d(d_hid // 2, d_hid // 2, style_dim, dropout_p=dropout), + ] + ) + self.F0_proj = nn.Conv1d(d_hid // 2, 1, 1, 1, 0) + self.N_proj = nn.Conv1d(d_hid // 2, 1, 1, 1, 0) + + def F0Ntrain(self, x: torch.Tensor, s: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: # noqa: N802 + x, _ = self.shared(x.transpose(-1, -2)) + f0 = x.transpose(-1, -2) + for block in self.F0: + f0 = block(f0, s) + f0 = self.F0_proj(f0) + n = x.transpose(-1, -2) + for block in self.N: + n = block(n, s) + n = self.N_proj(n) + return f0.squeeze(1), n.squeeze(1) + + +class DurationEncoder(nn.Module): + def __init__(self, sty_dim: int, d_model: int, nlayers: int, dropout: float = 0.1) -> None: + super().__init__() + self.lstms = nn.ModuleList() + for _ in range(nlayers): + self.lstms.append( + nn.LSTM( + d_model + sty_dim, + d_model // 2, + num_layers=1, + batch_first=True, + bidirectional=True, + dropout=dropout, + ) + ) + self.lstms.append(AdaLayerNorm(sty_dim, d_model)) + self.dropout = dropout + self.d_model = d_model + self.sty_dim = sty_dim + + def forward( + self, x: torch.Tensor, style: torch.Tensor, text_lengths: torch.Tensor, m: torch.Tensor + ) -> torch.Tensor: + masks = m + x = x.permute(2, 0, 1) + s = style.expand(x.shape[0], x.shape[1], -1) + x = torch.cat([x, s], dim=-1) + x.masked_fill_(masks.unsqueeze(-1).transpose(0, 1), 0.0) + x = x.transpose(0, 1) + x = x.transpose(-1, -2) + for block in self.lstms: + if isinstance(block, AdaLayerNorm): + x = block(x.transpose(-1, -2), style).transpose(-1, -2) + x = torch.cat([x, s.permute(1, 2, 0)], dim=1) + x.masked_fill_(masks.unsqueeze(-1).transpose(-1, -2), 0.0) + elif isinstance(block, nn.LSTM): + x = x.transpose(-1, -2) + packed = nn.utils.rnn.pack_padded_sequence( + x, _cpu_lengths(text_lengths), batch_first=True, enforce_sorted=False + ) + block.flatten_parameters() + packed, _ = block(packed) + x, _ = nn.utils.rnn.pad_packed_sequence(packed, batch_first=True) + x = F.dropout(x, p=self.dropout, training=False) + x = x.transpose(-1, -2) + x_pad = torch.zeros([x.shape[0], x.shape[1], m.shape[-1]], device=x.device) + x_pad[:, :, : x.shape[-1]] = x + x = x_pad + return x.transpose(-1, -2) + + +class CustomAlbert(AlbertModel): + """ALBERT that returns only the last hidden state.""" + + def forward(self, *args: Any, **kwargs: Any) -> torch.Tensor: # ty: ignore[invalid-method-override] + outputs = super().forward(*args, **kwargs) + return outputs.last_hidden_state diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py b/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py new file mode 100644 index 000000000..cbb25da0e --- /dev/null +++ b/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py @@ -0,0 +1,116 @@ +"""English text-to-phoneme chunking and synthesis loop for Kokoro-82M. + +Adapted from ``kokoro/pipeline.py`` of kokoro 0.9.4 (https://github.com/hexgrad/kokoro, +Apache-2.0). See ``NOTICE`` in this directory. Changes: English only (American and +British), voices are read from local files, no word timestamps, and words outside +misaki's lexicon are read by ``g2p_fallback.Fallback`` around a letter-to-sound +model passed in by the caller. Before each text is phonemized, the fallback reads +all of its out-of-lexicon words in one batch. + +``misaki`` is imported by the caller's ``load()``; it is only installed with the +bundles that serve Kokoro. +""" + +from __future__ import annotations + +import re +from collections.abc import Iterator +from dataclasses import dataclass +from pathlib import Path +from typing import Any + +import torch + +from sie_server.adapters.kokoro.g2p_fallback import Fallback, LetterToSound +from sie_server.adapters.kokoro.model import KModel + +#: Longest phoneme string ``KModel`` reads in one forward pass (512 ids minus the two boundary ids). +MAX_PHONEMES = 510 +_WATERFALL = ("!.?…", ":;", ",—") +_BUMPS = (")", "”") + + +@dataclass +class Result: + graphemes: str + phonemes: str + audio: torch.Tensor | None = None + + +class EnglishPipeline: + """Text to phoneme chunks to audio, for one English variant and one shared ``KModel``.""" + + def __init__(self, model: KModel, *, british: bool, letter_to_sound: LetterToSound) -> None: + from misaki import en # ty: ignore[unresolved-import] + + self.model = model + self.british = british + # ``unk=""``: a word neither the lexicon nor the fallback can read is left silent. + self.g2p = en.G2P(trf=False, british=british, fallback=None, unk="") + self.fallback = Fallback(self.g2p, letter_to_sound, british=british, subtokenize=en.subtokenize) + self.g2p.fallback = self.fallback + self._voices: dict[str, torch.Tensor] = {} + + def load_voice(self, path: str | Path) -> torch.Tensor: + key = str(path) + pack = self._voices.get(key) + if pack is None: + pack = torch.load(key, map_location="cpu", weights_only=True) + self._voices[key] = pack + return pack + + def __call__(self, text: str, voice: str | Path, speed: float = 1) -> Iterator[Result]: + pack = self.load_voice(voice).to(self.model.device) + paragraphs = [graphemes for graphemes in re.split(r"\n+", text.strip()) if graphemes.strip()] + self.fallback.prefetch(paragraphs) + for graphemes in paragraphs: + _, tokens = self.g2p(graphemes) + for gs, ps in _chunks(tokens): + if not ps: + continue + ps = ps[:MAX_PHONEMES] + audio = self.model(ps, pack[len(ps) - 1], speed) + yield Result(graphemes=gs, phonemes=ps, audio=audio) + + +def _tokens_to_ps(tokens: list[Any]) -> str: + return "".join(t.phonemes + (" " if t.whitespace else "") for t in tokens).strip() + + +def _tokens_to_text(tokens: list[Any]) -> str: + return "".join(t.text + t.whitespace for t in tokens).strip() + + +def _waterfall_last(tokens: list[Any], next_count: int) -> int: + """Index after the last strong punctuation that keeps the rest under ``MAX_PHONEMES``.""" + for marks in _WATERFALL: + z = next((i for i, t in reversed(list(enumerate(tokens))) if t.phonemes in set(marks)), None) + if z is None: + continue + z += 1 + if z < len(tokens) and tokens[z].phonemes in _BUMPS: + z += 1 + if next_count - len(_tokens_to_ps(tokens[:z])) <= MAX_PHONEMES: + return z + return len(tokens) + + +def _chunks(tokens: list[Any]) -> Iterator[tuple[str, str]]: + """Split misaki tokens into chunks of at most ``MAX_PHONEMES`` phonemes, preferring punctuation.""" + tks: list[Any] = [] + pcount = 0 + for t in tokens: + t.phonemes = "" if t.phonemes is None else t.phonemes + next_ps = t.phonemes + (" " if t.whitespace else "") + next_pcount = pcount + len(next_ps.rstrip()) + if next_pcount > MAX_PHONEMES: + z = _waterfall_last(tks, next_pcount) + yield _tokens_to_text(tks[:z]), _tokens_to_ps(tks[:z]) + tks = tks[z:] + pcount = len(_tokens_to_ps(tks)) + if not tks: + next_ps = next_ps.lstrip() + tks.append(t) + pcount += len(next_ps) + if tks: + yield _tokens_to_text(tks), _tokens_to_ps(tks) diff --git a/packages/sie_server/tests/adapters/test_kokoro.py b/packages/sie_server/tests/adapters/test_kokoro.py index 50766ca54..f624735fc 100644 --- a/packages/sie_server/tests/adapters/test_kokoro.py +++ b/packages/sie_server/tests/adapters/test_kokoro.py @@ -1,8 +1,11 @@ from __future__ import annotations import base64 +import importlib +import importlib.abc import io import json +import re import sys import wave from pathlib import Path @@ -13,7 +16,9 @@ import pytest import torch from sie_sdk.bundle_utils import match_bundle_models +from sie_server.adapters.kokoro import adapter as kokoro_adapter from sie_server.adapters.kokoro.adapter import SAMPLE_RATE, KokoroAdapter, wav_bytes +from sie_server.adapters.kokoro.g2p_fallback import arpabet_to_misaki from sie_server.core.loader import load_model_configs, reject_unknown_loadtime_options, resolve_adapter_class from sie_server.types.inputs import InvalidInputError, Item @@ -29,8 +34,7 @@ class _FakeKModel: instances: ClassVar[list[_FakeKModel]] = [] - def __init__(self, repo_id: str | None = None, config: str | None = None, model: str | None = None) -> None: - self.repo_id = repo_id + def __init__(self, config: Path, model: Path) -> None: self.config = config self.model = model self.vocab = VOCAB @@ -45,15 +49,28 @@ def eval(self) -> _FakeKModel: return self -class _FakeKPipeline: - instances: ClassVar[list[_FakeKPipeline]] = [] +class _FakeLetterToSound: + """Reads a chunk as "K AE1 T" (``kˈæt``) once per three letters.""" - def __init__(self, lang_code: str, repo_id: str | None = None, model: Any = True) -> None: - self.lang_code = lang_code - self.repo_id = repo_id + instances: ClassVar[list[_FakeLetterToSound]] = [] + + def __init__(self, directory: Path) -> None: + self.directory = directory + _FakeLetterToSound.instances.append(self) + + def arpabet(self, chunks: list[str]) -> list[tuple[str, ...]]: + return [("K", "AE1", "T") * max(1, len(chunk) // 3) for chunk in chunks] + + +class _FakeEnglishPipeline: + instances: ClassVar[list[_FakeEnglishPipeline]] = [] + + def __init__(self, model: Any, *, british: bool, letter_to_sound: Any) -> None: + self.lang_code = "b" if british else "a" self.model = model + self.letter_to_sound = letter_to_sound self.calls: list[tuple[str, str, float]] = [] - _FakeKPipeline.instances.append(self) + _FakeEnglishPipeline.instances.append(self) def __call__(self, text: str, voice: str, speed: float = 1.0) -> Any: # One chunk per sentence; the "phonemes" are the sentence's characters, @@ -69,33 +86,36 @@ def __call__(self, text: str, voice: str, speed: float = 1.0) -> Any: @pytest.fixture def kokoro_module(monkeypatch: pytest.MonkeyPatch) -> ModuleType: - module = ModuleType("kokoro") - module.KModel = _FakeKModel # type: ignore[attr-defined] - module.KPipeline = _FakeKPipeline # type: ignore[attr-defined] + monkeypatch.setattr(kokoro_adapter, "KModel", _FakeKModel) + monkeypatch.setattr(kokoro_adapter, "EnglishPipeline", _FakeEnglishPipeline) + monkeypatch.setattr(kokoro_adapter, "LetterToSound", _FakeLetterToSound) _FakeKModel.instances.clear() - _FakeKPipeline.instances.clear() - monkeypatch.setitem(sys.modules, "kokoro", module) - return module + _FakeEnglishPipeline.instances.clear() + _FakeLetterToSound.instances.clear() + return kokoro_adapter @pytest.fixture def checkpoint(tmp_path: Path) -> Path: - (tmp_path / "config.json").write_text(json.dumps({"vocab": VOCAB})) - (tmp_path / "kokoro-v1_0.pth").write_bytes(b"") - (tmp_path / "voices").mkdir() + directory = tmp_path / "kokoro" + (directory / "voices").mkdir(parents=True) + (directory / "config.json").write_text(json.dumps({"vocab": VOCAB})) + (directory / "kokoro-v1_0.pth").write_bytes(b"") for voice in ("af_heart", "bf_emma"): - (tmp_path / "voices" / f"{voice}.pt").write_bytes(b"") - return tmp_path + (directory / "voices" / f"{voice}.pt").write_bytes(b"") + # A local directory stands in for the letter-to-sound snapshot. + (tmp_path / "g2p").mkdir() + return directory def _loaded(checkpoint: Path, **kwargs: Any) -> KokoroAdapter: - adapter = KokoroAdapter(checkpoint, **kwargs) + adapter = KokoroAdapter(checkpoint, g2p_model=str(checkpoint.parent / "g2p"), **kwargs) adapter.load("cpu") return adapter -def _pipeline(lang: str) -> _FakeKPipeline: - return next(pipeline for pipeline in _FakeKPipeline.instances if pipeline.lang_code == lang) +def _pipeline(lang: str) -> _FakeEnglishPipeline: + return next(pipeline for pipeline in _FakeEnglishPipeline.instances if pipeline.lang_code == lang) def _decode_wav(entry: dict[str, Any]) -> tuple[wave._wave_params, np.ndarray]: @@ -111,17 +131,43 @@ def test_load_builds_the_model_from_local_files_and_one_pipeline_per_english( adapter = _loaded(checkpoint) (model,) = _FakeKModel.instances - assert model.config == str(checkpoint / "config.json") - assert model.model == str(checkpoint / "kokoro-v1_0.pth") + assert model.config == checkpoint / "config.json" + assert model.model == checkpoint / "kokoro-v1_0.pth" assert model.device == "cpu" - assert sorted(pipeline.lang_code for pipeline in _FakeKPipeline.instances) == ["a", "b"] - assert all(pipeline.model is model for pipeline in _FakeKPipeline.instances) + assert sorted(pipeline.lang_code for pipeline in _FakeEnglishPipeline.instances) == ["a", "b"] + assert all(pipeline.model is model for pipeline in _FakeEnglishPipeline.instances) + # Both pipelines share one letter-to-sound model. + (letter_to_sound,) = _FakeLetterToSound.instances + assert letter_to_sound.directory == checkpoint.parent / "g2p" + assert all(pipeline.letter_to_sound is letter_to_sound for pipeline in _FakeEnglishPipeline.instances) adapter.unload() with pytest.raises(RuntimeError, match="Model not loaded"): adapter.extract([Item(text="Hello.")]) +def test_load_resolves_both_pinned_checkpoints_once( + kokoro_module: ModuleType, checkpoint: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + calls: list[tuple[str, str | None, tuple[str, ...]]] = [] + + def resolve(name: str, *, revision: str | None, allow_patterns: Any) -> Path: + calls.append((str(name), revision, tuple(allow_patterns))) + return checkpoint if name == MODEL_ID else checkpoint.parent / "g2p" + + monkeypatch.setattr(kokoro_module, "resolve_checkpoint", resolve) + adapter = KokoroAdapter(MODEL_ID, revision="f3ff3571791e39611d31c381e3a41a3af07b4987") + adapter.load("cpu") + adapter.extract([Item(text="Hello.")]) + + assert [(name, revision) for name, revision, _ in calls] == [ + (MODEL_ID, "f3ff3571791e39611d31c381e3a41a3af07b4987"), + ("cisco-ai/mini-bart-g2p", "0fbbf8c590f9db920939a2bc4befbaac26eebc4c"), + ] + assert "model.safetensors" in calls[1][2] + assert not any(pattern.startswith("onnx") for pattern in calls[1][2]) + + def test_load_requires_the_default_voice(kokoro_module: ModuleType, checkpoint: Path) -> None: (checkpoint / "voices" / "af_heart.pt").unlink() with pytest.raises(FileNotFoundError, match="af_heart"): @@ -275,4 +321,115 @@ def test_model_config_is_pinned_text_extract_and_routed_by_default_bundle() -> N adapter_class = resolve_adapter_class(config, MODELS) assert adapter_class is KokoroAdapter reject_unknown_loadtime_options(adapter_class, profile.loadtime, model_name=MODEL_ID) + assert profile.loadtime == { + "g2p_model": "cisco-ai/mini-bart-g2p", + "g2p_revision": "0fbbf8c590f9db920939a2bc4befbaac26eebc4c", + } assert MODEL_ID in match_bundle_models(BUNDLES / "default.yaml", MODELS) + + +_ESPEAK_MODULES = ("misaki.espeak", "phonemizer", "espeakng_loader") + + +class _BlockEspeak(importlib.abc.MetaPathFinder): + def find_spec(self, fullname: str, path: Any = None, target: Any = None) -> None: + if fullname in _ESPEAK_MODULES or fullname.startswith(tuple(f"{name}." for name in _ESPEAK_MODULES)): + raise ModuleNotFoundError(f"No module named {fullname!r}", name=fullname) + + +class _LexiconlessG2P: + """Stands in for ``misaki.en.G2P``: every word goes to the fallback.""" + + def __init__(self, trf: bool, british: bool, fallback: Any, unk: str) -> None: + assert trf is False + assert unk == "" + self.fallback = fallback + self.lexicon = SimpleNamespace(get_NNP=lambda word: (None, None)) + + def __call__(self, text: str) -> tuple[str, list[Any]]: + tokens = [] + for word in text.split(): + token = SimpleNamespace(text=word, whitespace=" ", phonemes=None) + token.phonemes, _ = self.fallback(token) + tokens.append(token) + return "", tokens + + +def _tiny_checkpoint(directory: Path) -> Path: + """A Kokoro-shaped checkpoint with random weights and a small encoder.""" + phonemes = sorted(set("".join(arpabet_to_misaki([p], british=b) for p in _ARPABET for b in (False, True)))) + vocab = {p: index for index, p in enumerate(phonemes, start=1)} + config = { + "vocab": vocab, + "n_token": len(vocab) + 1, + "hidden_dim": 512, + "style_dim": 128, + "n_layer": 1, + "max_dur": 8, + "dropout": 0.2, + "text_encoder_kernel_size": 5, + "n_mels": 80, + "plbert": { + "hidden_size": 32, + "num_attention_heads": 2, + "intermediate_size": 64, + "max_position_embeddings": 128, + "num_hidden_layers": 1, + "embedding_size": 16, + }, + "istftnet": { + "upsample_kernel_sizes": [20, 12], + "upsample_rates": [10, 6], + "gen_istft_hop_size": 5, + "gen_istft_n_fft": 20, + "resblock_dilation_sizes": [[1, 3, 5]], + "resblock_kernel_sizes": [3], + "upsample_initial_channel": 512, + }, + } + (directory / "config.json").write_text(json.dumps(config)) + # No tensors: every parameter keeps its random initialisation. + torch.save({}, directory / "kokoro-v1_0.pth") + (directory / "voices").mkdir() + torch.save(torch.randn(128, 1, 256), directory / "voices" / "af_heart.pt") + return directory + + +_ARPABET = ("AA1", "AE1", "AH0", "AH1", "AO1", "AW1", "AY1", "EH1", "ER0", "ER1", "EY1", "IH1", "IY0", "IY1", "OW1", + "OY1", "UH1", "UW1", "B", "CH", "D", "DH", "F", "G", "HH", "JH", "K", "L", "M", "N", "NG", "P", "R", "S", + "SH", "T", "TH", "V", "W", "Y", "Z", "ZH", "AA2") # fmt: skip + + +def test_adapter_loads_and_speaks_without_the_espeak_packages(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: + # Import the adapter afresh with the espeak-based modules unimportable and a + # misaki whose English G2P has no lexicon, so every word uses the fallback. + for name in [name for name in sys.modules if name.startswith(("sie_server.adapters.kokoro", *_ESPEAK_MODULES))]: + monkeypatch.delitem(sys.modules, name) + monkeypatch.setattr(sys, "meta_path", [_BlockEspeak(), *sys.meta_path]) + misaki = ModuleType("misaki") + english = ModuleType("misaki.en") + english.G2P = _LexiconlessG2P # ty: ignore[unresolved-attribute] + english.subtokenize = lambda text: re.findall(r"\w+|[^\w\s]", text) # ty: ignore[unresolved-attribute] + misaki.en = english # ty: ignore[unresolved-attribute] + monkeypatch.setitem(sys.modules, "misaki", misaki) + monkeypatch.setitem(sys.modules, "misaki.en", english) + for name in _ESPEAK_MODULES: + with pytest.raises(ModuleNotFoundError): + importlib.import_module(name) + + module = importlib.import_module("sie_server.adapters.kokoro.adapter") + monkeypatch.setattr(module, "LetterToSound", _FakeLetterToSound) + (tmp_path / "g2p").mkdir() + (tmp_path / "kokoro").mkdir() + adapter = module.KokoroAdapter(_tiny_checkpoint(tmp_path / "kokoro"), g2p_model=str(tmp_path / "g2p")) + adapter.load("cpu") + torch.manual_seed(0) + output = adapter.extract([Item(text="Zorvexa quibbleberry")]) + + assert output.errors is None + assert output.data is not None + assert output.data[0]["duration_ms"] > 0 + # Both invented words were spelled: more than the two boundary ids were read. + assert output.input_token_counts is not None + assert output.input_token_counts[0] > 10 + assert not any(name in sys.modules for name in _ESPEAK_MODULES) From 42aab2e92ac70db2168d97299a2c0f0a293a9a70 Mon Sep 17 00:00:00 2001 From: Shai Shmuel Date: Mon, 30 Nov 2026 13:54:09 +0200 Subject: [PATCH 3/6] build(server): drop kokoro and the espeak packages from the default bundle The adapter no longer imports kokoro or misaki.espeak, so the default bundle lists misaki without its en extra, plus num2words, spaCy and the en_core_web_sm wheel that misaki.en imports. cuda12-default-amd64, cpu-default-amd64 and cpu-default-arm64 are recompiled with the cutoffs already recorded in their manifests (--exclude-newer 2026-10-18T00:00:00Z --root-exclude-newer 2026-11-06T20:00:00Z). Each lock loses 17 packages: kokoro, espeakng-loader, phonemizer-fork, spacy-curated-transformers and the packages only they required (babel, csvw, curated-tokenizers, curated-transformers, dlinfo, isodate, language-tags, pyparsing, rdflib, rfc3986, segments, termcolor, uritemplate). No package is added and no version changes. --- .../cpu-default-amd64/manifest.json | 4 +- .../cpu-default-amd64/pylock.toml | 101 ------------------ .../cpu-default-arm64/manifest.json | 4 +- .../cpu-default-arm64/pylock.toml | 101 ------------------ .../cuda12-default-amd64/manifest.json | 4 +- .../cuda12-default-amd64/pylock.toml | 101 ------------------ packages/sie_server/bundles/default.yaml | 9 +- 7 files changed, 9 insertions(+), 315 deletions(-) diff --git a/packages/sie_server/bundle-locks/cpu-default-amd64/manifest.json b/packages/sie_server/bundle-locks/cpu-default-amd64/manifest.json index 8b65dfeb1..3dacfb840 100644 --- a/packages/sie_server/bundle-locks/cpu-default-amd64/manifest.json +++ b/packages/sie_server/bundle-locks/cpu-default-amd64/manifest.json @@ -22,10 +22,10 @@ "unsafe-best-match" ], "inputs": { - "requirements_sha256": "80006e6e0fb7d92e02da60e0c152752ec9b972782c6714218e9a4217e7f028a0", + "requirements_sha256": "9a6c8aad1198407cf99b917428d559547ba2d8e500b7651fc6759d6e7612ae4c", "root_versions_sha256": "baaee3f4ed167d22897e99edc787077a74b2ce56dbbf986ebc4e1a80bdde6f24" }, - "lock_sha256": "d0fade75e5e3f71d905fd4b07bc5da0c7e6411df624aa76fe9b8b57110125e82", + "lock_sha256": "4ad5b63580b4ea239d7e4d6a70d69baa86bd1887bba3b75317c64118856891b3", "policy_sha256": "63f7cb65d9bcfc5ce9d06397da86a90d8d50e05db0eb367824d599eba0459590", "root_exclude_newer": "2026-11-06T20:00:00Z", "schema_version": 1, diff --git a/packages/sie_server/bundle-locks/cpu-default-amd64/pylock.toml b/packages/sie_server/bundle-locks/cpu-default-amd64/pylock.toml index b40519a4f..cd70df257 100644 --- a/packages/sie_server/bundle-locks/cpu-default-amd64/pylock.toml +++ b/packages/sie_server/bundle-locks/cpu-default-amd64/pylock.toml @@ -64,12 +64,6 @@ version = "26.1.0" sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", upload-time = 2026-03-19T14:22:25Z, size = 952055, hashes = { sha256 = "d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32" } } wheels = [{ url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", upload-time = 2026-03-19T14:22:23Z, size = 67548, hashes = { sha256 = "c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309" } }] -[[packages]] -name = "babel" -version = "2.18.0" -sdist = { url = "https://files.pythonhosted.org/packages/7d/b2/51899539b6ceeeb420d40ed3cd4b7a40519404f9baf3d4ac99dc413a834b/babel-2.18.0.tar.gz", upload-time = 2026-02-01T12:30:56Z, size = 9959554, hashes = { sha256 = "b80b99a14bd085fcacfa15c9165f651fbb3406e66cc603abf11c5750937c992d" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/77/f5/21d2de20e8b8b0408f0681956ca2c69f1320a3848ac50e6e7f39c6159675/babel-2.18.0-py3-none-any.whl", upload-time = 2026-02-01T12:30:53Z, size = 10196845, hashes = { sha256 = "e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35" } }] - [[packages]] name = "beautifulsoup4" version = "4.14.3" @@ -132,24 +126,6 @@ version = "1.3.3" sdist = { url = "https://files.pythonhosted.org/packages/ca/65/efd0fe8a936fc8ca2978cb7b82581fb20d901c6039e746a808f746b7647b/confection-1.3.3.tar.gz", upload-time = 2026-03-24T18:45:24Z, size = 54895, hashes = { sha256 = "f0f6810d567ff73993fe74d218ca5e1ffb6a44fb03f391257fc5d033546cbfaa" } } wheels = [{ url = "https://files.pythonhosted.org/packages/8d/e4/d66708bdf0d92fb4d49b22cdff4b10cec38aca5dcd7e81d909bb55c65cd7/confection-1.3.3-py3-none-any.whl", upload-time = 2026-03-24T18:45:22Z, size = 35902, hashes = { sha256 = "b9fef9ee84b237ef4611ec3eb5797b70e13063e6310ad9f15536373f5e313c82" } }] -[[packages]] -name = "csvw" -version = "4.1.1" -sdist = { url = "https://files.pythonhosted.org/packages/3f/ab/8c7b1c103a91656d023be24f824a6faab25d9ecc4a43310b134793200458/csvw-4.1.1.tar.gz", upload-time = 2026-10-17T08:44:09Z, size = 83386, hashes = { sha256 = "5714d43d744e4069e2b6d0e58a67829ca1bf8d0578aad92cfc74e87d69e6cb31" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/fe/9e/a4e6f6aea5f0dedd53523c653c8f368eb6a2392bce09d36ac36de1db2c0f/csvw-4.1.1-py2.py3-none-any.whl", upload-time = 2026-10-17T08:44:08Z, size = 69365, hashes = { sha256 = "fce2c461899290771eaec28c770e2fd0f6bc1324edb81d688c89e09cf222fcdb" } }] - -[[packages]] -name = "curated-tokenizers" -version = "0.0.10" -sdist = { url = "https://files.pythonhosted.org/packages/6d/3c/5d98e3fdbae12a0079d5ac06849bce200dd0cbf88b404d4d0fef4f7e3860/curated_tokenizers-0.0.10.tar.gz", upload-time = 2026-08-24T10:05:27Z, size = 2237645, hashes = { sha256 = "1c2b506e9c49e999b41939d783e788e021de5586a66a594b222fc2592aa169cf" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/37/fb/20d524a76f8bd226733931b67063c87ecead3b58a7cc3543c27ca46b63c7/curated_tokenizers-0.0.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", upload-time = 2026-08-24T10:04:01Z, size = 6309412, hashes = { sha256 = "841743db1da4a4a1298675584771ed973945c31ea9f6dde9f06e9eb6b3974bf3" } }] - -[[packages]] -name = "curated-transformers" -version = "0.1.1" -sdist = { url = "https://files.pythonhosted.org/packages/70/06/6c12c149a7f737dacc76b4c3949dbc7ff87d622567b86996896ae4d104aa/curated-transformers-0.1.1.tar.gz", upload-time = 2023-05-24T07:29:22Z, size = 16313, hashes = { sha256 = "4671f03314df30efda2ec2b59bc7692ea34fcea44cb65382342c16684e8a2119" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/d6/67/3b72b3fdfcadab61bc8f59c17e63770e526ffabd583ed32f174a7c01af85/curated_transformers-0.1.1-py2.py3-none-any.whl", upload-time = 2023-05-24T07:29:21Z, size = 25972, hashes = { sha256 = "d716063d73d803c6925d2dab56fde9b9ab8e89e663c2c0587804944ba488ff01" } }] - [[packages]] name = "cymem" version = "2.0.13" @@ -174,12 +150,6 @@ version = "0.3.8" sdist = { url = "https://files.pythonhosted.org/packages/17/4d/ac7ffa80c69ea1df30a8aa11b3578692a5118e7cd1aa157e3ef73b092d15/dill-0.3.8.tar.gz", upload-time = 2024-01-27T23:42:16Z, size = 184847, hashes = { sha256 = "3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca" } } wheels = [{ url = "https://files.pythonhosted.org/packages/c9/7a/cef76fd8438a42f96db64ddaa85280485a9c395e7df3db8158cfec1eee34/dill-0.3.8-py3-none-any.whl", upload-time = 2024-01-27T23:42:14Z, size = 116252, hashes = { sha256 = "c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7" } }] -[[packages]] -name = "dlinfo" -version = "2.0.0" -sdist = { url = "https://files.pythonhosted.org/packages/85/8e/8f2f94cd40af1b51e8e371a83b385d622170d42f98776441a6118f4dd682/dlinfo-2.0.0.tar.gz", upload-time = 2025-01-16T15:43:10Z, size = 12727, hashes = { sha256 = "88a2bc04f51d01bc604cdc9eb1c3cc0bde89057532ca6a3e71a41f6235433e17" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/da/90/022c79d6e5e6f843268c10b84d4a021ee3afba0621d3c176d3ff2024bfc8/dlinfo-2.0.0-py3-none-any.whl", upload-time = 2025-01-16T15:43:09Z, size = 3654, hashes = { sha256 = "b32cc18e3ea67c0ca9ca409e5b41eed863bd1363dbc9dd3de90fedf11b61e7bc" } }] - [[packages]] name = "docling" version = "2.99.0" @@ -226,11 +196,6 @@ name = "en-core-web-sm" version = "3.8.0" archive = { url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl", hashes = { sha256 = "1932429db727d4bff3deed6b34cfc05df17794f4a52eeb26cf8928f7c1a0fb85" } } -[[packages]] -name = "espeakng-loader" -version = "0.2.4" -wheels = [{ url = "https://files.pythonhosted.org/packages/de/1e/25ec5ab07528c0fbb215a61800a38eca05c8a99445515a02d7fa5debcb32/espeakng_loader-0.2.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", upload-time = 2025-01-17T01:22:43Z, size = 10078484, hashes = { sha256 = "08721baf27d13d461f6be6eed9a65277e70d68234ff484fd8b9897b222cdcb6d" } }] - [[packages]] name = "et-xmlfile" version = "2.0.0" @@ -372,12 +337,6 @@ version = "0.5.11" sdist = { url = "https://files.pythonhosted.org/packages/80/c6/f02811c51fec845ee87a10bb3675516a2d71935b203e5ddb80b7eb59b1da/ir_datasets-0.5.11.tar.gz", upload-time = 2025-06-24T07:58:31Z, size = 758463, hashes = { sha256 = "06c90af634ae5063c813286b35065debca1a974d26e136403d899f3ecd7ad463" } } wheels = [{ url = "https://files.pythonhosted.org/packages/81/38/73fa582d6997362d9b4901b2a8ba1177b2d2896aa59ab8d069a3884e2e0d/ir_datasets-0.5.11-py3-none-any.whl", upload-time = 2025-06-24T07:58:29Z, size = 866095, hashes = { sha256 = "ae78549e5a7fa45e50462b7acb9f0765fc344fec6054108bf3dd063050555206" } }] -[[packages]] -name = "isodate" -version = "0.7.2" -sdist = { url = "https://files.pythonhosted.org/packages/54/4d/e940025e2ce31a8ce1202635910747e5a87cc3a6a6bb2d00973375014749/isodate-0.7.2.tar.gz", upload-time = 2024-10-08T23:04:11Z, size = 29705, hashes = { sha256 = "4cd1aa0f43ca76f4a6c6c0292a85f40b35ec2e43e315b59f06e6d32171a953e6" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/15/aa/0aca39a37d3c7eb941ba736ede56d689e7be91cab5d9ca846bde3999eba6/isodate-0.7.2-py3-none-any.whl", upload-time = 2024-10-08T23:04:09Z, size = 22320, hashes = { sha256 = "28009937d8031054830160fce6d409ed342816b543597cece116d966c6d99e15" } }] - [[packages]] name = "jinja2" version = "3.1.6" @@ -413,18 +372,6 @@ version = "2025.9.1" sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", upload-time = 2025-09-08T01:34:59Z, size = 32855, hashes = { sha256 = "b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d" } } wheels = [{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", upload-time = 2025-09-08T01:34:57Z, size = 18437, hashes = { sha256 = "98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe" } }] -[[packages]] -name = "kokoro" -version = "0.9.4" -sdist = { url = "https://files.pythonhosted.org/packages/e8/48/88b8cdf28b068d070195c2817175549dee48e7682e3ab8994bee5f69217e/kokoro-0.9.4.tar.gz", upload-time = 2025-04-05T22:01:35Z, size = 26215928, hashes = { sha256 = "fbf633262797f8cf46fdac3315cf9cade67dc8b762c0feccf334892772fb9ac4" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/ea/cc/75f41633c75224ba820a4533163bc8b070b6bf25416014074c63284c2d4e/kokoro-0.9.4-py3-none-any.whl", upload-time = 2025-04-05T22:01:23Z, size = 32592, hashes = { sha256 = "a129dc6364a286bd6a92c396e9862459d3d3e45f2c15596ed5a94dcee5789efd" } }] - -[[packages]] -name = "language-tags" -version = "1.3.1" -sdist = { url = "https://files.pythonhosted.org/packages/39/d1/b37165bed9016c19e2cdecf4176fbd902a014fb8a87dd44415438e190969/language_tags-1.3.1.tar.gz", upload-time = 2026-05-08T11:46:24Z, size = 222642, hashes = { sha256 = "b15f05505dad3ad296a1782d5a6083fd141309186094d1ab08095348f4203f37" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/0a/21/b48b9e8408b3faec9fb7cb2f68352c7724add35a980c948eaceb29ac41e4/language_tags-1.3.1-py3-none-any.whl", upload-time = 2026-05-08T11:46:17Z, size = 216654, hashes = { sha256 = "f7db7ef8879523019603e09644a86d95ba60595ce5e5ea82d46e8971b0f68f7b" } }] - [[packages]] name = "latex2mathml" version = "3.81.0" @@ -593,12 +540,6 @@ version = "0.19.1" sdist = { url = "https://files.pythonhosted.org/packages/86/cf/037f1e3d5186496c05513a6754639e2dab3038a05f384284d49a9bd06a2d/peft-0.19.1.tar.gz", upload-time = 2026-04-16T15:46:45Z, size = 763738, hashes = { sha256 = "0d97542fe96dcdaa20d3b81c06f26f988618f416a73544ab23c3618ccb674a40" } } wheels = [{ url = "https://files.pythonhosted.org/packages/e8/b6/f54d676ed93cc2dd2234c3b172ea9c8c3d7d29361e66b1b23dec57a67465/peft-0.19.1-py3-none-any.whl", upload-time = 2026-04-16T15:46:42Z, size = 680692, hashes = { sha256 = "2113f72a81621b5913ef28f9022204c742df111890c5f49d812716a4a301e356" } }] -[[packages]] -name = "phonemizer-fork" -version = "3.3.2" -sdist = { url = "https://files.pythonhosted.org/packages/42/fa/9294d2f11890ca49d0bdac7a4da60cbe5686629bfd4987cae0ad75e051cc/phonemizer_fork-3.3.2.tar.gz", upload-time = 2025-01-30T13:02:31Z, size = 300989, hashes = { sha256 = "10e16e827d0443b087062e21b55e805c00989cf1343b2e81e734cae5f6c0cf69" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/64/f1/0dcce21b0ae16a82df4b6583f8f3ad8e55b35f7e98b6bf536a4dd225fa08/phonemizer_fork-3.3.2-py3-none-any.whl", upload-time = 2025-01-30T13:02:28Z, size = 82700, hashes = { sha256 = "97305c76f4183b3825dae8f4c032265fe78c9946ce58c47d4b62161349264b74" } }] - [[packages]] name = "pillow" version = "12.3.0" @@ -688,12 +629,6 @@ name = "pylatexenc" version = "2.10" sdist = { url = "https://files.pythonhosted.org/packages/5d/ab/34ec41718af73c00119d0351b7a2531d2ebddb51833a36448fc7b862be60/pylatexenc-2.10.tar.gz", upload-time = 2021-04-06T07:56:07Z, size = 162597, hashes = { sha256 = "3dd8fd84eb46dc30bee1e23eaab8d8fb5a7f507347b23e5f38ad9675c84f40d3" } } -[[packages]] -name = "pyparsing" -version = "3.3.3" -sdist = { url = "https://files.pythonhosted.org/packages/e4/11/b213bebff182584360cb8d17c72c1677fec5c5c228de439e63bcf8ab1c8f/pyparsing-3.3.3.tar.gz", upload-time = 2026-09-20T20:59:05Z, size = 1050487, hashes = { sha256 = "928ae7e20211f3b6f3915a72f06a0cfd29ab9d24279dd6346b6b1a7146397d36" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/38/bb/d215ee7c73b61497b28a5503f9f53523f294fcc936762b7caf90e0c1c2b5/pyparsing-3.3.3-py3-none-any.whl", upload-time = 2026-09-20T20:59:04Z, size = 126420, hashes = { sha256 = "ece8c00a69cf01b45d0b1dedabb469c90d8caf996d4fda40f147627a122849a4" } }] - [[packages]] name = "pypdfium2" version = "5.7.1" @@ -741,12 +676,6 @@ name = "rapidocr" version = "3.8.1" wheels = [{ url = "https://files.pythonhosted.org/packages/ea/4a/fa521d947f0fc7bb304bf11bec4cb66266bd81494588b4cb48dc01001719/rapidocr-3.8.1-py3-none-any.whl", upload-time = 2026-04-11T07:13:22Z, size = 15080319, hashes = { sha256 = "650044b1fbce9e6bae5cae462dcf8be754cde11e2f23fc51f65dcc08deae2c46" } }] -[[packages]] -name = "rdflib" -version = "7.1.4" -sdist = { url = "https://files.pythonhosted.org/packages/e8/7e/cb2d74466bd8495051ebe2d241b1cb1d4acf9740d481126aef19ef2697f5/rdflib-7.1.4.tar.gz", upload-time = 2025-03-29T02:23:02Z, size = 4692745, hashes = { sha256 = "fed46e24f26a788e2ab8e445f7077f00edcf95abb73bcef4b86cefa8b62dd174" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/f4/31/e9b6f04288dcd3fa60cb3179260d6dad81b92aef3063d679ac7d80a827ea/rdflib-7.1.4-py3-none-any.whl", upload-time = 2025-03-29T02:22:44Z, size = 565051, hashes = { sha256 = "72f4adb1990fa5241abd22ddaf36d7cafa5d91d9ff2ba13f3086d339b213d997" } }] - [[packages]] name = "referencing" version = "0.37.0" @@ -765,12 +694,6 @@ version = "2.33.1" sdist = { url = "https://files.pythonhosted.org/packages/5f/a4/98b9c7c6428a668bf7e42ebb7c79d576a1c3c1e3ae2d47e674b468388871/requests-2.33.1.tar.gz", upload-time = 2026-03-30T16:09:15Z, size = 134120, hashes = { sha256 = "18817f8c57c6263968bc123d237e3b8b08ac046f5456bd1e307ee8f4250d3517" } } wheels = [{ url = "https://files.pythonhosted.org/packages/d7/8e/7540e8a2036f79a125c1d2ebadf69ed7901608859186c856fa0388ef4197/requests-2.33.1-py3-none-any.whl", upload-time = 2026-03-30T16:09:13Z, size = 64947, hashes = { sha256 = "4e6d1ef462f3626a1f0a0a9c42dd93c63bad33f9f1c1937509b8c5c8718ab56a" } }] -[[packages]] -name = "rfc3986" -version = "1.5.0" -sdist = { url = "https://files.pythonhosted.org/packages/79/30/5b1b6c28c105629cc12b33bdcbb0b11b5bb1880c6cfbd955f9e792921aa8/rfc3986-1.5.0.tar.gz", upload-time = 2021-05-07T23:29:27Z, size = 49378, hashes = { sha256 = "270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/c4/e5/63ca2c4edf4e00657584608bee1001302bbf8c5f569340b78304f2f446cb/rfc3986-1.5.0-py2.py3-none-any.whl", upload-time = 2021-05-07T23:29:25Z, size = 31976, hashes = { sha256 = "a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97" } }] - [[packages]] name = "rich" version = "13.9.4" @@ -807,12 +730,6 @@ version = "1.17.1" sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", upload-time = 2026-02-23T00:26:24Z, size = 30573822, hashes = { sha256 = "95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0" } } wheels = [{ url = "https://files.pythonhosted.org/packages/01/8e/1e35281b8ab6d5d72ebe9911edcdffa3f36b04ed9d51dec6dd140396e220/scipy-1.17.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", upload-time = 2026-02-23T00:18:49Z, size = 35235890, hashes = { sha256 = "02ae3b274fde71c5e92ac4d54bc06c42d80e399fec704383dcd99b301df37458" } }] -[[packages]] -name = "segments" -version = "2.4.0" -sdist = { url = "https://files.pythonhosted.org/packages/8b/57/85cac3a8e32370e88fa5fa92812edb6025db7fcbed51452bd56ee1524957/segments-2.4.0.tar.gz", upload-time = 2026-03-07T10:01:28Z, size = 18662, hashes = { sha256 = "bba71f5520ddd54c8aa2f4d765a60618c6862162d6e7356a4a097f2223166f5b" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/be/60/eef9acce946177f92c9aabf432224d87ab908bafafac516a36ab924199f3/segments-2.4.0-py2.py3-none-any.whl", upload-time = 2026-03-07T10:01:27Z, size = 16321, hashes = { sha256 = "4021dc67f201cc03c864c74c618bdb163b1af629da3040babbaa37d8813f3db0" } }] - [[packages]] name = "semchunk" version = "3.2.5" @@ -877,12 +794,6 @@ name = "spacy" version = "3.8.14" wheels = [{ url = "https://files.pythonhosted.org/packages/8e/3f/1799af5f4ccc8eb7500e4a20ca301488134429dba08cda5be68ce6ab2992/spacy-3.8.14-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", upload-time = 2026-03-29T10:40:53Z, size = 33205838, hashes = { sha256 = "6d45715a24446f23b98ec3f09409a1d4111983d1d64613250ee38c3270e21853" } }] -[[packages]] -name = "spacy-curated-transformers" -version = "0.3.1" -sdist = { url = "https://files.pythonhosted.org/packages/d8/b3/a4fd3cf28008cbe1d95463b5c76a0d9c8da7b9ad4f06289c2be4aae62052/spacy_curated_transformers-0.3.1.tar.gz", upload-time = 2025-05-28T10:29:32Z, size = 218990, hashes = { sha256 = "7e53fccf64260e641b0a3f2b65b6d98381b86cef6eeb21ce279e8db849e8525d" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/42/d8/f053d43125ae4ad14f3e2a12a475a656128233f1f40a272c6e09a05c73e8/spacy_curated_transformers-0.3.1-py2.py3-none-any.whl", upload-time = 2025-05-28T10:29:31Z, size = 237943, hashes = { sha256 = "503559b6a1d6e44ec2c978e18ed871ce5c3d56871dc9216c0e1523428204e610" } }] - [[packages]] name = "spacy-legacy" version = "3.0.12" @@ -913,12 +824,6 @@ version = "0.10.0" sdist = { url = "https://files.pythonhosted.org/packages/46/58/8c37dea7bbf769b20d58e7ace7e5edfe65b849442b00ffcdd56be88697c6/tabulate-0.10.0.tar.gz", upload-time = 2026-03-04T18:55:34Z, size = 91754, hashes = { sha256 = "e2cfde8f79420f6deeffdeda9aaec3b6bc5abce947655d17ac662b126e48a60d" } } wheels = [{ url = "https://files.pythonhosted.org/packages/99/55/db07de81b5c630da5cbf5c7df646580ca26dfaefa593667fc6f2fe016d2e/tabulate-0.10.0-py3-none-any.whl", upload-time = 2026-03-04T18:55:31Z, size = 39814, hashes = { sha256 = "f0b0622e567335c8fabaaa659f1b33bcb6ddfe2e496071b743aa113f8774f2d3" } }] -[[packages]] -name = "termcolor" -version = "3.3.0" -sdist = { url = "https://files.pythonhosted.org/packages/46/79/cf31d7a93a8fdc6aa0fbb665be84426a8c5a557d9240b6239e9e11e35fc5/termcolor-3.3.0.tar.gz", upload-time = 2025-12-29T12:55:21Z, size = 14434, hashes = { sha256 = "348871ca648ec6a9a983a13ab626c0acce02f515b9e1983332b17af7979521c5" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/33/d1/8bb87d21e9aeb323cc03034f5eaf2c8f69841e40e4853c2627edf8111ed3/termcolor-3.3.0-py3-none-any.whl", upload-time = 2025-12-29T12:55:20Z, size = 7734, hashes = { sha256 = "cf642efadaf0a8ebbbf4bc7a31cec2f9b5f21a9f726f4ccbb08192c9c26f43a5" } }] - [[packages]] name = "thinc" version = "8.3.13" @@ -1031,12 +936,6 @@ version = "0.2.3" sdist = { url = "https://files.pythonhosted.org/packages/08/f1/72b313366285263aaba21a17714fbef597d7662a8737a928b2b4784eb46e/unlzw3-0.2.3.tar.gz", upload-time = 2024-12-20T16:05:55Z, size = 5426, hashes = { sha256 = "ede5d928c792fff9da406f20334f9739693327f448f383ae1df1774627197bbb" } } wheels = [{ url = "https://files.pythonhosted.org/packages/4d/fb/617af9b317ac75f5663285d3a3cc38903a76d63c6e7397768307545f4ff4/unlzw3-0.2.3-py3-none-any.whl", upload-time = 2024-12-20T16:05:53Z, size = 6729, hashes = { sha256 = "7760fb4f3afa1225623944c061991d89a061f7fb78665dbc4cddfdb562bb4a8b" } }] -[[packages]] -name = "uritemplate" -version = "4.2.0" -sdist = { url = "https://files.pythonhosted.org/packages/98/60/f174043244c5306c9988380d2cb10009f91563fc4b31293d27e17201af56/uritemplate-4.2.0.tar.gz", upload-time = 2025-06-02T15:12:06Z, size = 33267, hashes = { sha256 = "480c2ed180878955863323eea31b0ede668795de182617fef9c6ca09e6ec9d0e" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/a9/99/3ae339466c9183ea5b8ae87b34c0b897eda475d2aec2307cae60e5cd4f29/uritemplate-4.2.0-py3-none-any.whl", upload-time = 2025-06-02T15:12:03Z, size = 11488, hashes = { sha256 = "962201ba1c4edcab02e60f9a0d3821e82dfc5d2d6662a21abd533879bdb8a686" } }] - [[packages]] name = "urllib3" version = "2.7.0" diff --git a/packages/sie_server/bundle-locks/cpu-default-arm64/manifest.json b/packages/sie_server/bundle-locks/cpu-default-arm64/manifest.json index 256738042..f8e201e94 100644 --- a/packages/sie_server/bundle-locks/cpu-default-arm64/manifest.json +++ b/packages/sie_server/bundle-locks/cpu-default-arm64/manifest.json @@ -22,10 +22,10 @@ "unsafe-best-match" ], "inputs": { - "requirements_sha256": "80006e6e0fb7d92e02da60e0c152752ec9b972782c6714218e9a4217e7f028a0", + "requirements_sha256": "9a6c8aad1198407cf99b917428d559547ba2d8e500b7651fc6759d6e7612ae4c", "root_versions_sha256": "baaee3f4ed167d22897e99edc787077a74b2ce56dbbf986ebc4e1a80bdde6f24" }, - "lock_sha256": "99c6d12fce6416bda3f5dcf291b50cb32390b9411e00480ffad1e5dddce56965", + "lock_sha256": "4dc791149e865e5b390c94cb02a18ea8ebfa49799019cce62fcf3260c0ee86d3", "policy_sha256": "63f7cb65d9bcfc5ce9d06397da86a90d8d50e05db0eb367824d599eba0459590", "root_exclude_newer": "2026-11-06T20:00:00Z", "schema_version": 1, diff --git a/packages/sie_server/bundle-locks/cpu-default-arm64/pylock.toml b/packages/sie_server/bundle-locks/cpu-default-arm64/pylock.toml index 0c9fe51fc..ff01e6b60 100644 --- a/packages/sie_server/bundle-locks/cpu-default-arm64/pylock.toml +++ b/packages/sie_server/bundle-locks/cpu-default-arm64/pylock.toml @@ -64,12 +64,6 @@ version = "26.1.0" sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", upload-time = 2026-03-19T14:22:25Z, size = 952055, hashes = { sha256 = "d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32" } } wheels = [{ url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", upload-time = 2026-03-19T14:22:23Z, size = 67548, hashes = { sha256 = "c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309" } }] -[[packages]] -name = "babel" -version = "2.18.0" -sdist = { url = "https://files.pythonhosted.org/packages/7d/b2/51899539b6ceeeb420d40ed3cd4b7a40519404f9baf3d4ac99dc413a834b/babel-2.18.0.tar.gz", upload-time = 2026-02-01T12:30:56Z, size = 9959554, hashes = { sha256 = "b80b99a14bd085fcacfa15c9165f651fbb3406e66cc603abf11c5750937c992d" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/77/f5/21d2de20e8b8b0408f0681956ca2c69f1320a3848ac50e6e7f39c6159675/babel-2.18.0-py3-none-any.whl", upload-time = 2026-02-01T12:30:53Z, size = 10196845, hashes = { sha256 = "e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35" } }] - [[packages]] name = "beautifulsoup4" version = "4.14.3" @@ -132,24 +126,6 @@ version = "1.3.3" sdist = { url = "https://files.pythonhosted.org/packages/ca/65/efd0fe8a936fc8ca2978cb7b82581fb20d901c6039e746a808f746b7647b/confection-1.3.3.tar.gz", upload-time = 2026-03-24T18:45:24Z, size = 54895, hashes = { sha256 = "f0f6810d567ff73993fe74d218ca5e1ffb6a44fb03f391257fc5d033546cbfaa" } } wheels = [{ url = "https://files.pythonhosted.org/packages/8d/e4/d66708bdf0d92fb4d49b22cdff4b10cec38aca5dcd7e81d909bb55c65cd7/confection-1.3.3-py3-none-any.whl", upload-time = 2026-03-24T18:45:22Z, size = 35902, hashes = { sha256 = "b9fef9ee84b237ef4611ec3eb5797b70e13063e6310ad9f15536373f5e313c82" } }] -[[packages]] -name = "csvw" -version = "4.1.1" -sdist = { url = "https://files.pythonhosted.org/packages/3f/ab/8c7b1c103a91656d023be24f824a6faab25d9ecc4a43310b134793200458/csvw-4.1.1.tar.gz", upload-time = 2026-10-17T08:44:09Z, size = 83386, hashes = { sha256 = "5714d43d744e4069e2b6d0e58a67829ca1bf8d0578aad92cfc74e87d69e6cb31" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/fe/9e/a4e6f6aea5f0dedd53523c653c8f368eb6a2392bce09d36ac36de1db2c0f/csvw-4.1.1-py2.py3-none-any.whl", upload-time = 2026-10-17T08:44:08Z, size = 69365, hashes = { sha256 = "fce2c461899290771eaec28c770e2fd0f6bc1324edb81d688c89e09cf222fcdb" } }] - -[[packages]] -name = "curated-tokenizers" -version = "0.0.10" -sdist = { url = "https://files.pythonhosted.org/packages/6d/3c/5d98e3fdbae12a0079d5ac06849bce200dd0cbf88b404d4d0fef4f7e3860/curated_tokenizers-0.0.10.tar.gz", upload-time = 2026-08-24T10:05:27Z, size = 2237645, hashes = { sha256 = "1c2b506e9c49e999b41939d783e788e021de5586a66a594b222fc2592aa169cf" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/80/d2/266a0fe5e0cab7db9df706ec3ef4616a9687d07e757abf46fd1898cc294d/curated_tokenizers-0.0.10-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", upload-time = 2026-08-24T10:03:59Z, size = 6208507, hashes = { sha256 = "7094e2c5add10d187c35205bf472eba483f352182496614dfe4e754f271ad242" } }] - -[[packages]] -name = "curated-transformers" -version = "0.1.1" -sdist = { url = "https://files.pythonhosted.org/packages/70/06/6c12c149a7f737dacc76b4c3949dbc7ff87d622567b86996896ae4d104aa/curated-transformers-0.1.1.tar.gz", upload-time = 2023-05-24T07:29:22Z, size = 16313, hashes = { sha256 = "4671f03314df30efda2ec2b59bc7692ea34fcea44cb65382342c16684e8a2119" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/d6/67/3b72b3fdfcadab61bc8f59c17e63770e526ffabd583ed32f174a7c01af85/curated_transformers-0.1.1-py2.py3-none-any.whl", upload-time = 2023-05-24T07:29:21Z, size = 25972, hashes = { sha256 = "d716063d73d803c6925d2dab56fde9b9ab8e89e663c2c0587804944ba488ff01" } }] - [[packages]] name = "cymem" version = "2.0.13" @@ -174,12 +150,6 @@ version = "0.3.8" sdist = { url = "https://files.pythonhosted.org/packages/17/4d/ac7ffa80c69ea1df30a8aa11b3578692a5118e7cd1aa157e3ef73b092d15/dill-0.3.8.tar.gz", upload-time = 2024-01-27T23:42:16Z, size = 184847, hashes = { sha256 = "3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca" } } wheels = [{ url = "https://files.pythonhosted.org/packages/c9/7a/cef76fd8438a42f96db64ddaa85280485a9c395e7df3db8158cfec1eee34/dill-0.3.8-py3-none-any.whl", upload-time = 2024-01-27T23:42:14Z, size = 116252, hashes = { sha256 = "c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7" } }] -[[packages]] -name = "dlinfo" -version = "2.0.0" -sdist = { url = "https://files.pythonhosted.org/packages/85/8e/8f2f94cd40af1b51e8e371a83b385d622170d42f98776441a6118f4dd682/dlinfo-2.0.0.tar.gz", upload-time = 2025-01-16T15:43:10Z, size = 12727, hashes = { sha256 = "88a2bc04f51d01bc604cdc9eb1c3cc0bde89057532ca6a3e71a41f6235433e17" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/da/90/022c79d6e5e6f843268c10b84d4a021ee3afba0621d3c176d3ff2024bfc8/dlinfo-2.0.0-py3-none-any.whl", upload-time = 2025-01-16T15:43:09Z, size = 3654, hashes = { sha256 = "b32cc18e3ea67c0ca9ca409e5b41eed863bd1363dbc9dd3de90fedf11b61e7bc" } }] - [[packages]] name = "docling" version = "2.99.0" @@ -226,11 +196,6 @@ name = "en-core-web-sm" version = "3.8.0" archive = { url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl", hashes = { sha256 = "1932429db727d4bff3deed6b34cfc05df17794f4a52eeb26cf8928f7c1a0fb85" } } -[[packages]] -name = "espeakng-loader" -version = "0.2.4" -wheels = [{ url = "https://files.pythonhosted.org/packages/d9/ad/1b768d8daffc2996e07bbcb6f534d8de3202cd75fce1f1c45eced1ce6465/espeakng_loader-0.2.4-py3-none-manylinux_2_28_aarch64.whl", upload-time = 2025-01-17T01:22:42Z, size = 10037736, hashes = { sha256 = "d1e798141b46a050cdb75fcf3c17db969bb2c40394f3f4a48910655d547508b9" } }] - [[packages]] name = "et-xmlfile" version = "2.0.0" @@ -372,12 +337,6 @@ version = "0.5.11" sdist = { url = "https://files.pythonhosted.org/packages/80/c6/f02811c51fec845ee87a10bb3675516a2d71935b203e5ddb80b7eb59b1da/ir_datasets-0.5.11.tar.gz", upload-time = 2025-06-24T07:58:31Z, size = 758463, hashes = { sha256 = "06c90af634ae5063c813286b35065debca1a974d26e136403d899f3ecd7ad463" } } wheels = [{ url = "https://files.pythonhosted.org/packages/81/38/73fa582d6997362d9b4901b2a8ba1177b2d2896aa59ab8d069a3884e2e0d/ir_datasets-0.5.11-py3-none-any.whl", upload-time = 2025-06-24T07:58:29Z, size = 866095, hashes = { sha256 = "ae78549e5a7fa45e50462b7acb9f0765fc344fec6054108bf3dd063050555206" } }] -[[packages]] -name = "isodate" -version = "0.7.2" -sdist = { url = "https://files.pythonhosted.org/packages/54/4d/e940025e2ce31a8ce1202635910747e5a87cc3a6a6bb2d00973375014749/isodate-0.7.2.tar.gz", upload-time = 2024-10-08T23:04:11Z, size = 29705, hashes = { sha256 = "4cd1aa0f43ca76f4a6c6c0292a85f40b35ec2e43e315b59f06e6d32171a953e6" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/15/aa/0aca39a37d3c7eb941ba736ede56d689e7be91cab5d9ca846bde3999eba6/isodate-0.7.2-py3-none-any.whl", upload-time = 2024-10-08T23:04:09Z, size = 22320, hashes = { sha256 = "28009937d8031054830160fce6d409ed342816b543597cece116d966c6d99e15" } }] - [[packages]] name = "jinja2" version = "3.1.6" @@ -413,18 +372,6 @@ version = "2025.9.1" sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", upload-time = 2025-09-08T01:34:59Z, size = 32855, hashes = { sha256 = "b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d" } } wheels = [{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", upload-time = 2025-09-08T01:34:57Z, size = 18437, hashes = { sha256 = "98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe" } }] -[[packages]] -name = "kokoro" -version = "0.9.4" -sdist = { url = "https://files.pythonhosted.org/packages/e8/48/88b8cdf28b068d070195c2817175549dee48e7682e3ab8994bee5f69217e/kokoro-0.9.4.tar.gz", upload-time = 2025-04-05T22:01:35Z, size = 26215928, hashes = { sha256 = "fbf633262797f8cf46fdac3315cf9cade67dc8b762c0feccf334892772fb9ac4" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/ea/cc/75f41633c75224ba820a4533163bc8b070b6bf25416014074c63284c2d4e/kokoro-0.9.4-py3-none-any.whl", upload-time = 2025-04-05T22:01:23Z, size = 32592, hashes = { sha256 = "a129dc6364a286bd6a92c396e9862459d3d3e45f2c15596ed5a94dcee5789efd" } }] - -[[packages]] -name = "language-tags" -version = "1.3.1" -sdist = { url = "https://files.pythonhosted.org/packages/39/d1/b37165bed9016c19e2cdecf4176fbd902a014fb8a87dd44415438e190969/language_tags-1.3.1.tar.gz", upload-time = 2026-05-08T11:46:24Z, size = 222642, hashes = { sha256 = "b15f05505dad3ad296a1782d5a6083fd141309186094d1ab08095348f4203f37" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/0a/21/b48b9e8408b3faec9fb7cb2f68352c7724add35a980c948eaceb29ac41e4/language_tags-1.3.1-py3-none-any.whl", upload-time = 2026-05-08T11:46:17Z, size = 216654, hashes = { sha256 = "f7db7ef8879523019603e09644a86d95ba60595ce5e5ea82d46e8971b0f68f7b" } }] - [[packages]] name = "latex2mathml" version = "3.81.0" @@ -593,12 +540,6 @@ version = "0.19.1" sdist = { url = "https://files.pythonhosted.org/packages/86/cf/037f1e3d5186496c05513a6754639e2dab3038a05f384284d49a9bd06a2d/peft-0.19.1.tar.gz", upload-time = 2026-04-16T15:46:45Z, size = 763738, hashes = { sha256 = "0d97542fe96dcdaa20d3b81c06f26f988618f416a73544ab23c3618ccb674a40" } } wheels = [{ url = "https://files.pythonhosted.org/packages/e8/b6/f54d676ed93cc2dd2234c3b172ea9c8c3d7d29361e66b1b23dec57a67465/peft-0.19.1-py3-none-any.whl", upload-time = 2026-04-16T15:46:42Z, size = 680692, hashes = { sha256 = "2113f72a81621b5913ef28f9022204c742df111890c5f49d812716a4a301e356" } }] -[[packages]] -name = "phonemizer-fork" -version = "3.3.2" -sdist = { url = "https://files.pythonhosted.org/packages/42/fa/9294d2f11890ca49d0bdac7a4da60cbe5686629bfd4987cae0ad75e051cc/phonemizer_fork-3.3.2.tar.gz", upload-time = 2025-01-30T13:02:31Z, size = 300989, hashes = { sha256 = "10e16e827d0443b087062e21b55e805c00989cf1343b2e81e734cae5f6c0cf69" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/64/f1/0dcce21b0ae16a82df4b6583f8f3ad8e55b35f7e98b6bf536a4dd225fa08/phonemizer_fork-3.3.2-py3-none-any.whl", upload-time = 2025-01-30T13:02:28Z, size = 82700, hashes = { sha256 = "97305c76f4183b3825dae8f4c032265fe78c9946ce58c47d4b62161349264b74" } }] - [[packages]] name = "pillow" version = "12.3.0" @@ -688,12 +629,6 @@ name = "pylatexenc" version = "2.10" sdist = { url = "https://files.pythonhosted.org/packages/5d/ab/34ec41718af73c00119d0351b7a2531d2ebddb51833a36448fc7b862be60/pylatexenc-2.10.tar.gz", upload-time = 2021-04-06T07:56:07Z, size = 162597, hashes = { sha256 = "3dd8fd84eb46dc30bee1e23eaab8d8fb5a7f507347b23e5f38ad9675c84f40d3" } } -[[packages]] -name = "pyparsing" -version = "3.3.3" -sdist = { url = "https://files.pythonhosted.org/packages/e4/11/b213bebff182584360cb8d17c72c1677fec5c5c228de439e63bcf8ab1c8f/pyparsing-3.3.3.tar.gz", upload-time = 2026-09-20T20:59:05Z, size = 1050487, hashes = { sha256 = "928ae7e20211f3b6f3915a72f06a0cfd29ab9d24279dd6346b6b1a7146397d36" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/38/bb/d215ee7c73b61497b28a5503f9f53523f294fcc936762b7caf90e0c1c2b5/pyparsing-3.3.3-py3-none-any.whl", upload-time = 2026-09-20T20:59:04Z, size = 126420, hashes = { sha256 = "ece8c00a69cf01b45d0b1dedabb469c90d8caf996d4fda40f147627a122849a4" } }] - [[packages]] name = "pypdfium2" version = "5.7.1" @@ -741,12 +676,6 @@ name = "rapidocr" version = "3.8.1" wheels = [{ url = "https://files.pythonhosted.org/packages/ea/4a/fa521d947f0fc7bb304bf11bec4cb66266bd81494588b4cb48dc01001719/rapidocr-3.8.1-py3-none-any.whl", upload-time = 2026-04-11T07:13:22Z, size = 15080319, hashes = { sha256 = "650044b1fbce9e6bae5cae462dcf8be754cde11e2f23fc51f65dcc08deae2c46" } }] -[[packages]] -name = "rdflib" -version = "7.1.4" -sdist = { url = "https://files.pythonhosted.org/packages/e8/7e/cb2d74466bd8495051ebe2d241b1cb1d4acf9740d481126aef19ef2697f5/rdflib-7.1.4.tar.gz", upload-time = 2025-03-29T02:23:02Z, size = 4692745, hashes = { sha256 = "fed46e24f26a788e2ab8e445f7077f00edcf95abb73bcef4b86cefa8b62dd174" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/f4/31/e9b6f04288dcd3fa60cb3179260d6dad81b92aef3063d679ac7d80a827ea/rdflib-7.1.4-py3-none-any.whl", upload-time = 2025-03-29T02:22:44Z, size = 565051, hashes = { sha256 = "72f4adb1990fa5241abd22ddaf36d7cafa5d91d9ff2ba13f3086d339b213d997" } }] - [[packages]] name = "referencing" version = "0.37.0" @@ -765,12 +694,6 @@ version = "2.33.1" sdist = { url = "https://files.pythonhosted.org/packages/5f/a4/98b9c7c6428a668bf7e42ebb7c79d576a1c3c1e3ae2d47e674b468388871/requests-2.33.1.tar.gz", upload-time = 2026-03-30T16:09:15Z, size = 134120, hashes = { sha256 = "18817f8c57c6263968bc123d237e3b8b08ac046f5456bd1e307ee8f4250d3517" } } wheels = [{ url = "https://files.pythonhosted.org/packages/d7/8e/7540e8a2036f79a125c1d2ebadf69ed7901608859186c856fa0388ef4197/requests-2.33.1-py3-none-any.whl", upload-time = 2026-03-30T16:09:13Z, size = 64947, hashes = { sha256 = "4e6d1ef462f3626a1f0a0a9c42dd93c63bad33f9f1c1937509b8c5c8718ab56a" } }] -[[packages]] -name = "rfc3986" -version = "1.5.0" -sdist = { url = "https://files.pythonhosted.org/packages/79/30/5b1b6c28c105629cc12b33bdcbb0b11b5bb1880c6cfbd955f9e792921aa8/rfc3986-1.5.0.tar.gz", upload-time = 2021-05-07T23:29:27Z, size = 49378, hashes = { sha256 = "270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/c4/e5/63ca2c4edf4e00657584608bee1001302bbf8c5f569340b78304f2f446cb/rfc3986-1.5.0-py2.py3-none-any.whl", upload-time = 2021-05-07T23:29:25Z, size = 31976, hashes = { sha256 = "a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97" } }] - [[packages]] name = "rich" version = "13.9.4" @@ -807,12 +730,6 @@ version = "1.17.1" sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", upload-time = 2026-02-23T00:26:24Z, size = 30573822, hashes = { sha256 = "95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0" } } wheels = [{ url = "https://files.pythonhosted.org/packages/da/34/16f10e3042d2f1d6b66e0428308ab52224b6a23049cb2f5c1756f713815f/scipy-1.17.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", upload-time = 2026-02-23T00:18:35Z, size = 32927842, hashes = { sha256 = "e19ebea31758fac5893a2ac360fedd00116cbb7628e650842a6691ba7ca28a21" } }] -[[packages]] -name = "segments" -version = "2.4.0" -sdist = { url = "https://files.pythonhosted.org/packages/8b/57/85cac3a8e32370e88fa5fa92812edb6025db7fcbed51452bd56ee1524957/segments-2.4.0.tar.gz", upload-time = 2026-03-07T10:01:28Z, size = 18662, hashes = { sha256 = "bba71f5520ddd54c8aa2f4d765a60618c6862162d6e7356a4a097f2223166f5b" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/be/60/eef9acce946177f92c9aabf432224d87ab908bafafac516a36ab924199f3/segments-2.4.0-py2.py3-none-any.whl", upload-time = 2026-03-07T10:01:27Z, size = 16321, hashes = { sha256 = "4021dc67f201cc03c864c74c618bdb163b1af629da3040babbaa37d8813f3db0" } }] - [[packages]] name = "semchunk" version = "3.2.5" @@ -877,12 +794,6 @@ name = "spacy" version = "3.8.14" wheels = [{ url = "https://files.pythonhosted.org/packages/ff/e8/048d83b73b28686307bd9a60878a58de7b7b21b562ca4de8b5bd558031e9/spacy-3.8.14-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", upload-time = 2026-03-29T10:40:50Z, size = 32725099, hashes = { sha256 = "daeb64b048f12c059997281aed53eb8776d26416dd313cf17ad6f63124b2b564" } }] -[[packages]] -name = "spacy-curated-transformers" -version = "0.3.1" -sdist = { url = "https://files.pythonhosted.org/packages/d8/b3/a4fd3cf28008cbe1d95463b5c76a0d9c8da7b9ad4f06289c2be4aae62052/spacy_curated_transformers-0.3.1.tar.gz", upload-time = 2025-05-28T10:29:32Z, size = 218990, hashes = { sha256 = "7e53fccf64260e641b0a3f2b65b6d98381b86cef6eeb21ce279e8db849e8525d" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/42/d8/f053d43125ae4ad14f3e2a12a475a656128233f1f40a272c6e09a05c73e8/spacy_curated_transformers-0.3.1-py2.py3-none-any.whl", upload-time = 2025-05-28T10:29:31Z, size = 237943, hashes = { sha256 = "503559b6a1d6e44ec2c978e18ed871ce5c3d56871dc9216c0e1523428204e610" } }] - [[packages]] name = "spacy-legacy" version = "3.0.12" @@ -913,12 +824,6 @@ version = "0.10.0" sdist = { url = "https://files.pythonhosted.org/packages/46/58/8c37dea7bbf769b20d58e7ace7e5edfe65b849442b00ffcdd56be88697c6/tabulate-0.10.0.tar.gz", upload-time = 2026-03-04T18:55:34Z, size = 91754, hashes = { sha256 = "e2cfde8f79420f6deeffdeda9aaec3b6bc5abce947655d17ac662b126e48a60d" } } wheels = [{ url = "https://files.pythonhosted.org/packages/99/55/db07de81b5c630da5cbf5c7df646580ca26dfaefa593667fc6f2fe016d2e/tabulate-0.10.0-py3-none-any.whl", upload-time = 2026-03-04T18:55:31Z, size = 39814, hashes = { sha256 = "f0b0622e567335c8fabaaa659f1b33bcb6ddfe2e496071b743aa113f8774f2d3" } }] -[[packages]] -name = "termcolor" -version = "3.3.0" -sdist = { url = "https://files.pythonhosted.org/packages/46/79/cf31d7a93a8fdc6aa0fbb665be84426a8c5a557d9240b6239e9e11e35fc5/termcolor-3.3.0.tar.gz", upload-time = 2025-12-29T12:55:21Z, size = 14434, hashes = { sha256 = "348871ca648ec6a9a983a13ab626c0acce02f515b9e1983332b17af7979521c5" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/33/d1/8bb87d21e9aeb323cc03034f5eaf2c8f69841e40e4853c2627edf8111ed3/termcolor-3.3.0-py3-none-any.whl", upload-time = 2025-12-29T12:55:20Z, size = 7734, hashes = { sha256 = "cf642efadaf0a8ebbbf4bc7a31cec2f9b5f21a9f726f4ccbb08192c9c26f43a5" } }] - [[packages]] name = "thinc" version = "8.3.13" @@ -1031,12 +936,6 @@ version = "0.2.3" sdist = { url = "https://files.pythonhosted.org/packages/08/f1/72b313366285263aaba21a17714fbef597d7662a8737a928b2b4784eb46e/unlzw3-0.2.3.tar.gz", upload-time = 2024-12-20T16:05:55Z, size = 5426, hashes = { sha256 = "ede5d928c792fff9da406f20334f9739693327f448f383ae1df1774627197bbb" } } wheels = [{ url = "https://files.pythonhosted.org/packages/4d/fb/617af9b317ac75f5663285d3a3cc38903a76d63c6e7397768307545f4ff4/unlzw3-0.2.3-py3-none-any.whl", upload-time = 2024-12-20T16:05:53Z, size = 6729, hashes = { sha256 = "7760fb4f3afa1225623944c061991d89a061f7fb78665dbc4cddfdb562bb4a8b" } }] -[[packages]] -name = "uritemplate" -version = "4.2.0" -sdist = { url = "https://files.pythonhosted.org/packages/98/60/f174043244c5306c9988380d2cb10009f91563fc4b31293d27e17201af56/uritemplate-4.2.0.tar.gz", upload-time = 2025-06-02T15:12:06Z, size = 33267, hashes = { sha256 = "480c2ed180878955863323eea31b0ede668795de182617fef9c6ca09e6ec9d0e" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/a9/99/3ae339466c9183ea5b8ae87b34c0b897eda475d2aec2307cae60e5cd4f29/uritemplate-4.2.0-py3-none-any.whl", upload-time = 2025-06-02T15:12:03Z, size = 11488, hashes = { sha256 = "962201ba1c4edcab02e60f9a0d3821e82dfc5d2d6662a21abd533879bdb8a686" } }] - [[packages]] name = "urllib3" version = "2.7.0" diff --git a/packages/sie_server/bundle-locks/cuda12-default-amd64/manifest.json b/packages/sie_server/bundle-locks/cuda12-default-amd64/manifest.json index bff02b646..449c56b49 100644 --- a/packages/sie_server/bundle-locks/cuda12-default-amd64/manifest.json +++ b/packages/sie_server/bundle-locks/cuda12-default-amd64/manifest.json @@ -7,10 +7,10 @@ "https://pypi.org/simple" ], "inputs": { - "requirements_sha256": "e46bcb3ad45115ff56a57ad4d24f291f7261c0103cd9b54aa1bcac187c209814", + "requirements_sha256": "eba8b999eca8b70028b11ece44dd8da256f24fcc5716b4c89a057e0f035cfad4", "root_versions_sha256": "baaee3f4ed167d22897e99edc787077a74b2ce56dbbf986ebc4e1a80bdde6f24" }, - "lock_sha256": "5ea155772e3215dc92f85473be243daef8065ba56824e12297d70397c9446440", + "lock_sha256": "601bea17f9dbb7317f1186b7ad8f2e80c23a500f9c48ce4b1cbafa83269421e5", "policy_sha256": "63f7cb65d9bcfc5ce9d06397da86a90d8d50e05db0eb367824d599eba0459590", "root_exclude_newer": "2026-11-06T20:00:00Z", "schema_version": 1, diff --git a/packages/sie_server/bundle-locks/cuda12-default-amd64/pylock.toml b/packages/sie_server/bundle-locks/cuda12-default-amd64/pylock.toml index 60ef382be..f220527ed 100644 --- a/packages/sie_server/bundle-locks/cuda12-default-amd64/pylock.toml +++ b/packages/sie_server/bundle-locks/cuda12-default-amd64/pylock.toml @@ -64,12 +64,6 @@ version = "26.1.0" sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", upload-time = 2026-03-19T14:22:25Z, size = 952055, hashes = { sha256 = "d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32" } } wheels = [{ url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", upload-time = 2026-03-19T14:22:23Z, size = 67548, hashes = { sha256 = "c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309" } }] -[[packages]] -name = "babel" -version = "2.18.0" -sdist = { url = "https://files.pythonhosted.org/packages/7d/b2/51899539b6ceeeb420d40ed3cd4b7a40519404f9baf3d4ac99dc413a834b/babel-2.18.0.tar.gz", upload-time = 2026-02-01T12:30:56Z, size = 9959554, hashes = { sha256 = "b80b99a14bd085fcacfa15c9165f651fbb3406e66cc603abf11c5750937c992d" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/77/f5/21d2de20e8b8b0408f0681956ca2c69f1320a3848ac50e6e7f39c6159675/babel-2.18.0-py3-none-any.whl", upload-time = 2026-02-01T12:30:53Z, size = 10196845, hashes = { sha256 = "e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35" } }] - [[packages]] name = "beautifulsoup4" version = "4.14.3" @@ -132,24 +126,6 @@ version = "1.3.3" sdist = { url = "https://files.pythonhosted.org/packages/ca/65/efd0fe8a936fc8ca2978cb7b82581fb20d901c6039e746a808f746b7647b/confection-1.3.3.tar.gz", upload-time = 2026-03-24T18:45:24Z, size = 54895, hashes = { sha256 = "f0f6810d567ff73993fe74d218ca5e1ffb6a44fb03f391257fc5d033546cbfaa" } } wheels = [{ url = "https://files.pythonhosted.org/packages/8d/e4/d66708bdf0d92fb4d49b22cdff4b10cec38aca5dcd7e81d909bb55c65cd7/confection-1.3.3-py3-none-any.whl", upload-time = 2026-03-24T18:45:22Z, size = 35902, hashes = { sha256 = "b9fef9ee84b237ef4611ec3eb5797b70e13063e6310ad9f15536373f5e313c82" } }] -[[packages]] -name = "csvw" -version = "4.1.1" -sdist = { url = "https://files.pythonhosted.org/packages/3f/ab/8c7b1c103a91656d023be24f824a6faab25d9ecc4a43310b134793200458/csvw-4.1.1.tar.gz", upload-time = 2026-10-17T08:44:09Z, size = 83386, hashes = { sha256 = "5714d43d744e4069e2b6d0e58a67829ca1bf8d0578aad92cfc74e87d69e6cb31" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/fe/9e/a4e6f6aea5f0dedd53523c653c8f368eb6a2392bce09d36ac36de1db2c0f/csvw-4.1.1-py2.py3-none-any.whl", upload-time = 2026-10-17T08:44:08Z, size = 69365, hashes = { sha256 = "fce2c461899290771eaec28c770e2fd0f6bc1324edb81d688c89e09cf222fcdb" } }] - -[[packages]] -name = "curated-tokenizers" -version = "0.0.10" -sdist = { url = "https://files.pythonhosted.org/packages/6d/3c/5d98e3fdbae12a0079d5ac06849bce200dd0cbf88b404d4d0fef4f7e3860/curated_tokenizers-0.0.10.tar.gz", upload-time = 2026-08-24T10:05:27Z, size = 2237645, hashes = { sha256 = "1c2b506e9c49e999b41939d783e788e021de5586a66a594b222fc2592aa169cf" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/37/fb/20d524a76f8bd226733931b67063c87ecead3b58a7cc3543c27ca46b63c7/curated_tokenizers-0.0.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", upload-time = 2026-08-24T10:04:01Z, size = 6309412, hashes = { sha256 = "841743db1da4a4a1298675584771ed973945c31ea9f6dde9f06e9eb6b3974bf3" } }] - -[[packages]] -name = "curated-transformers" -version = "0.1.1" -sdist = { url = "https://files.pythonhosted.org/packages/70/06/6c12c149a7f737dacc76b4c3949dbc7ff87d622567b86996896ae4d104aa/curated-transformers-0.1.1.tar.gz", upload-time = 2023-05-24T07:29:22Z, size = 16313, hashes = { sha256 = "4671f03314df30efda2ec2b59bc7692ea34fcea44cb65382342c16684e8a2119" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/d6/67/3b72b3fdfcadab61bc8f59c17e63770e526ffabd583ed32f174a7c01af85/curated_transformers-0.1.1-py2.py3-none-any.whl", upload-time = 2023-05-24T07:29:21Z, size = 25972, hashes = { sha256 = "d716063d73d803c6925d2dab56fde9b9ab8e89e663c2c0587804944ba488ff01" } }] - [[packages]] name = "cymem" version = "2.0.13" @@ -174,12 +150,6 @@ version = "0.3.8" sdist = { url = "https://files.pythonhosted.org/packages/17/4d/ac7ffa80c69ea1df30a8aa11b3578692a5118e7cd1aa157e3ef73b092d15/dill-0.3.8.tar.gz", upload-time = 2024-01-27T23:42:16Z, size = 184847, hashes = { sha256 = "3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca" } } wheels = [{ url = "https://files.pythonhosted.org/packages/c9/7a/cef76fd8438a42f96db64ddaa85280485a9c395e7df3db8158cfec1eee34/dill-0.3.8-py3-none-any.whl", upload-time = 2024-01-27T23:42:14Z, size = 116252, hashes = { sha256 = "c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7" } }] -[[packages]] -name = "dlinfo" -version = "2.0.0" -sdist = { url = "https://files.pythonhosted.org/packages/85/8e/8f2f94cd40af1b51e8e371a83b385d622170d42f98776441a6118f4dd682/dlinfo-2.0.0.tar.gz", upload-time = 2025-01-16T15:43:10Z, size = 12727, hashes = { sha256 = "88a2bc04f51d01bc604cdc9eb1c3cc0bde89057532ca6a3e71a41f6235433e17" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/da/90/022c79d6e5e6f843268c10b84d4a021ee3afba0621d3c176d3ff2024bfc8/dlinfo-2.0.0-py3-none-any.whl", upload-time = 2025-01-16T15:43:09Z, size = 3654, hashes = { sha256 = "b32cc18e3ea67c0ca9ca409e5b41eed863bd1363dbc9dd3de90fedf11b61e7bc" } }] - [[packages]] name = "docling" version = "2.99.0" @@ -226,11 +196,6 @@ name = "en-core-web-sm" version = "3.8.0" archive = { url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl", hashes = { sha256 = "1932429db727d4bff3deed6b34cfc05df17794f4a52eeb26cf8928f7c1a0fb85" } } -[[packages]] -name = "espeakng-loader" -version = "0.2.4" -wheels = [{ url = "https://files.pythonhosted.org/packages/de/1e/25ec5ab07528c0fbb215a61800a38eca05c8a99445515a02d7fa5debcb32/espeakng_loader-0.2.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", upload-time = 2025-01-17T01:22:43Z, size = 10078484, hashes = { sha256 = "08721baf27d13d461f6be6eed9a65277e70d68234ff484fd8b9897b222cdcb6d" } }] - [[packages]] name = "et-xmlfile" version = "2.0.0" @@ -378,12 +343,6 @@ version = "0.5.11" sdist = { url = "https://files.pythonhosted.org/packages/80/c6/f02811c51fec845ee87a10bb3675516a2d71935b203e5ddb80b7eb59b1da/ir_datasets-0.5.11.tar.gz", upload-time = 2025-06-24T07:58:31Z, size = 758463, hashes = { sha256 = "06c90af634ae5063c813286b35065debca1a974d26e136403d899f3ecd7ad463" } } wheels = [{ url = "https://files.pythonhosted.org/packages/81/38/73fa582d6997362d9b4901b2a8ba1177b2d2896aa59ab8d069a3884e2e0d/ir_datasets-0.5.11-py3-none-any.whl", upload-time = 2025-06-24T07:58:29Z, size = 866095, hashes = { sha256 = "ae78549e5a7fa45e50462b7acb9f0765fc344fec6054108bf3dd063050555206" } }] -[[packages]] -name = "isodate" -version = "0.7.2" -sdist = { url = "https://files.pythonhosted.org/packages/54/4d/e940025e2ce31a8ce1202635910747e5a87cc3a6a6bb2d00973375014749/isodate-0.7.2.tar.gz", upload-time = 2024-10-08T23:04:11Z, size = 29705, hashes = { sha256 = "4cd1aa0f43ca76f4a6c6c0292a85f40b35ec2e43e315b59f06e6d32171a953e6" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/15/aa/0aca39a37d3c7eb941ba736ede56d689e7be91cab5d9ca846bde3999eba6/isodate-0.7.2-py3-none-any.whl", upload-time = 2024-10-08T23:04:09Z, size = 22320, hashes = { sha256 = "28009937d8031054830160fce6d409ed342816b543597cece116d966c6d99e15" } }] - [[packages]] name = "jinja2" version = "3.1.6" @@ -420,18 +379,6 @@ version = "2025.9.1" sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", upload-time = 2025-09-08T01:34:59Z, size = 32855, hashes = { sha256 = "b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d" } } wheels = [{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", upload-time = 2025-09-08T01:34:57Z, size = 18437, hashes = { sha256 = "98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe" } }] -[[packages]] -name = "kokoro" -version = "0.9.4" -sdist = { url = "https://files.pythonhosted.org/packages/e8/48/88b8cdf28b068d070195c2817175549dee48e7682e3ab8994bee5f69217e/kokoro-0.9.4.tar.gz", upload-time = 2025-04-05T22:01:35Z, size = 26215928, hashes = { sha256 = "fbf633262797f8cf46fdac3315cf9cade67dc8b762c0feccf334892772fb9ac4" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/ea/cc/75f41633c75224ba820a4533163bc8b070b6bf25416014074c63284c2d4e/kokoro-0.9.4-py3-none-any.whl", upload-time = 2025-04-05T22:01:23Z, size = 32592, hashes = { sha256 = "a129dc6364a286bd6a92c396e9862459d3d3e45f2c15596ed5a94dcee5789efd" } }] - -[[packages]] -name = "language-tags" -version = "1.3.1" -sdist = { url = "https://files.pythonhosted.org/packages/39/d1/b37165bed9016c19e2cdecf4176fbd902a014fb8a87dd44415438e190969/language_tags-1.3.1.tar.gz", upload-time = 2026-05-08T11:46:24Z, size = 222642, hashes = { sha256 = "b15f05505dad3ad296a1782d5a6083fd141309186094d1ab08095348f4203f37" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/0a/21/b48b9e8408b3faec9fb7cb2f68352c7724add35a980c948eaceb29ac41e4/language_tags-1.3.1-py3-none-any.whl", upload-time = 2026-05-08T11:46:17Z, size = 216654, hashes = { sha256 = "f7db7ef8879523019603e09644a86d95ba60595ce5e5ea82d46e8971b0f68f7b" } }] - [[packages]] name = "latex2mathml" version = "3.81.0" @@ -691,12 +638,6 @@ version = "0.19.1" sdist = { url = "https://files.pythonhosted.org/packages/86/cf/037f1e3d5186496c05513a6754639e2dab3038a05f384284d49a9bd06a2d/peft-0.19.1.tar.gz", upload-time = 2026-04-16T15:46:45Z, size = 763738, hashes = { sha256 = "0d97542fe96dcdaa20d3b81c06f26f988618f416a73544ab23c3618ccb674a40" } } wheels = [{ url = "https://files.pythonhosted.org/packages/e8/b6/f54d676ed93cc2dd2234c3b172ea9c8c3d7d29361e66b1b23dec57a67465/peft-0.19.1-py3-none-any.whl", upload-time = 2026-04-16T15:46:42Z, size = 680692, hashes = { sha256 = "2113f72a81621b5913ef28f9022204c742df111890c5f49d812716a4a301e356" } }] -[[packages]] -name = "phonemizer-fork" -version = "3.3.2" -sdist = { url = "https://files.pythonhosted.org/packages/42/fa/9294d2f11890ca49d0bdac7a4da60cbe5686629bfd4987cae0ad75e051cc/phonemizer_fork-3.3.2.tar.gz", upload-time = 2025-01-30T13:02:31Z, size = 300989, hashes = { sha256 = "10e16e827d0443b087062e21b55e805c00989cf1343b2e81e734cae5f6c0cf69" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/64/f1/0dcce21b0ae16a82df4b6583f8f3ad8e55b35f7e98b6bf536a4dd225fa08/phonemizer_fork-3.3.2-py3-none-any.whl", upload-time = 2025-01-30T13:02:28Z, size = 82700, hashes = { sha256 = "97305c76f4183b3825dae8f4c032265fe78c9946ce58c47d4b62161349264b74" } }] - [[packages]] name = "pillow" version = "12.3.0" @@ -786,12 +727,6 @@ name = "pylatexenc" version = "2.10" sdist = { url = "https://files.pythonhosted.org/packages/5d/ab/34ec41718af73c00119d0351b7a2531d2ebddb51833a36448fc7b862be60/pylatexenc-2.10.tar.gz", upload-time = 2021-04-06T07:56:07Z, size = 162597, hashes = { sha256 = "3dd8fd84eb46dc30bee1e23eaab8d8fb5a7f507347b23e5f38ad9675c84f40d3" } } -[[packages]] -name = "pyparsing" -version = "3.3.3" -sdist = { url = "https://files.pythonhosted.org/packages/e4/11/b213bebff182584360cb8d17c72c1677fec5c5c228de439e63bcf8ab1c8f/pyparsing-3.3.3.tar.gz", upload-time = 2026-09-20T20:59:05Z, size = 1050487, hashes = { sha256 = "928ae7e20211f3b6f3915a72f06a0cfd29ab9d24279dd6346b6b1a7146397d36" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/38/bb/d215ee7c73b61497b28a5503f9f53523f294fcc936762b7caf90e0c1c2b5/pyparsing-3.3.3-py3-none-any.whl", upload-time = 2026-09-20T20:59:04Z, size = 126420, hashes = { sha256 = "ece8c00a69cf01b45d0b1dedabb469c90d8caf996d4fda40f147627a122849a4" } }] - [[packages]] name = "pypdfium2" version = "5.7.1" @@ -839,12 +774,6 @@ name = "rapidocr" version = "3.8.1" wheels = [{ url = "https://files.pythonhosted.org/packages/ea/4a/fa521d947f0fc7bb304bf11bec4cb66266bd81494588b4cb48dc01001719/rapidocr-3.8.1-py3-none-any.whl", upload-time = 2026-04-11T07:13:22Z, size = 15080319, hashes = { sha256 = "650044b1fbce9e6bae5cae462dcf8be754cde11e2f23fc51f65dcc08deae2c46" } }] -[[packages]] -name = "rdflib" -version = "7.1.4" -sdist = { url = "https://files.pythonhosted.org/packages/e8/7e/cb2d74466bd8495051ebe2d241b1cb1d4acf9740d481126aef19ef2697f5/rdflib-7.1.4.tar.gz", upload-time = 2025-03-29T02:23:02Z, size = 4692745, hashes = { sha256 = "fed46e24f26a788e2ab8e445f7077f00edcf95abb73bcef4b86cefa8b62dd174" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/f4/31/e9b6f04288dcd3fa60cb3179260d6dad81b92aef3063d679ac7d80a827ea/rdflib-7.1.4-py3-none-any.whl", upload-time = 2025-03-29T02:22:44Z, size = 565051, hashes = { sha256 = "72f4adb1990fa5241abd22ddaf36d7cafa5d91d9ff2ba13f3086d339b213d997" } }] - [[packages]] name = "referencing" version = "0.37.0" @@ -863,12 +792,6 @@ version = "2.33.1" sdist = { url = "https://files.pythonhosted.org/packages/5f/a4/98b9c7c6428a668bf7e42ebb7c79d576a1c3c1e3ae2d47e674b468388871/requests-2.33.1.tar.gz", upload-time = 2026-03-30T16:09:15Z, size = 134120, hashes = { sha256 = "18817f8c57c6263968bc123d237e3b8b08ac046f5456bd1e307ee8f4250d3517" } } wheels = [{ url = "https://files.pythonhosted.org/packages/d7/8e/7540e8a2036f79a125c1d2ebadf69ed7901608859186c856fa0388ef4197/requests-2.33.1-py3-none-any.whl", upload-time = 2026-03-30T16:09:13Z, size = 64947, hashes = { sha256 = "4e6d1ef462f3626a1f0a0a9c42dd93c63bad33f9f1c1937509b8c5c8718ab56a" } }] -[[packages]] -name = "rfc3986" -version = "1.5.0" -sdist = { url = "https://files.pythonhosted.org/packages/79/30/5b1b6c28c105629cc12b33bdcbb0b11b5bb1880c6cfbd955f9e792921aa8/rfc3986-1.5.0.tar.gz", upload-time = 2021-05-07T23:29:27Z, size = 49378, hashes = { sha256 = "270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/c4/e5/63ca2c4edf4e00657584608bee1001302bbf8c5f569340b78304f2f446cb/rfc3986-1.5.0-py2.py3-none-any.whl", upload-time = 2021-05-07T23:29:25Z, size = 31976, hashes = { sha256 = "a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97" } }] - [[packages]] name = "rich" version = "13.9.4" @@ -905,12 +828,6 @@ version = "1.17.1" sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", upload-time = 2026-02-23T00:26:24Z, size = 30573822, hashes = { sha256 = "95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0" } } wheels = [{ url = "https://files.pythonhosted.org/packages/01/8e/1e35281b8ab6d5d72ebe9911edcdffa3f36b04ed9d51dec6dd140396e220/scipy-1.17.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", upload-time = 2026-02-23T00:18:49Z, size = 35235890, hashes = { sha256 = "02ae3b274fde71c5e92ac4d54bc06c42d80e399fec704383dcd99b301df37458" } }] -[[packages]] -name = "segments" -version = "2.4.0" -sdist = { url = "https://files.pythonhosted.org/packages/8b/57/85cac3a8e32370e88fa5fa92812edb6025db7fcbed51452bd56ee1524957/segments-2.4.0.tar.gz", upload-time = 2026-03-07T10:01:28Z, size = 18662, hashes = { sha256 = "bba71f5520ddd54c8aa2f4d765a60618c6862162d6e7356a4a097f2223166f5b" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/be/60/eef9acce946177f92c9aabf432224d87ab908bafafac516a36ab924199f3/segments-2.4.0-py2.py3-none-any.whl", upload-time = 2026-03-07T10:01:27Z, size = 16321, hashes = { sha256 = "4021dc67f201cc03c864c74c618bdb163b1af629da3040babbaa37d8813f3db0" } }] - [[packages]] name = "semchunk" version = "3.2.5" @@ -975,12 +892,6 @@ name = "spacy" version = "3.8.14" wheels = [{ url = "https://files.pythonhosted.org/packages/8e/3f/1799af5f4ccc8eb7500e4a20ca301488134429dba08cda5be68ce6ab2992/spacy-3.8.14-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", upload-time = 2026-03-29T10:40:53Z, size = 33205838, hashes = { sha256 = "6d45715a24446f23b98ec3f09409a1d4111983d1d64613250ee38c3270e21853" } }] -[[packages]] -name = "spacy-curated-transformers" -version = "0.3.1" -sdist = { url = "https://files.pythonhosted.org/packages/d8/b3/a4fd3cf28008cbe1d95463b5c76a0d9c8da7b9ad4f06289c2be4aae62052/spacy_curated_transformers-0.3.1.tar.gz", upload-time = 2025-05-28T10:29:32Z, size = 218990, hashes = { sha256 = "7e53fccf64260e641b0a3f2b65b6d98381b86cef6eeb21ce279e8db849e8525d" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/42/d8/f053d43125ae4ad14f3e2a12a475a656128233f1f40a272c6e09a05c73e8/spacy_curated_transformers-0.3.1-py2.py3-none-any.whl", upload-time = 2025-05-28T10:29:31Z, size = 237943, hashes = { sha256 = "503559b6a1d6e44ec2c978e18ed871ce5c3d56871dc9216c0e1523428204e610" } }] - [[packages]] name = "spacy-legacy" version = "3.0.12" @@ -1011,12 +922,6 @@ version = "0.10.0" sdist = { url = "https://files.pythonhosted.org/packages/46/58/8c37dea7bbf769b20d58e7ace7e5edfe65b849442b00ffcdd56be88697c6/tabulate-0.10.0.tar.gz", upload-time = 2026-03-04T18:55:34Z, size = 91754, hashes = { sha256 = "e2cfde8f79420f6deeffdeda9aaec3b6bc5abce947655d17ac662b126e48a60d" } } wheels = [{ url = "https://files.pythonhosted.org/packages/99/55/db07de81b5c630da5cbf5c7df646580ca26dfaefa593667fc6f2fe016d2e/tabulate-0.10.0-py3-none-any.whl", upload-time = 2026-03-04T18:55:31Z, size = 39814, hashes = { sha256 = "f0b0622e567335c8fabaaa659f1b33bcb6ddfe2e496071b743aa113f8774f2d3" } }] -[[packages]] -name = "termcolor" -version = "3.3.0" -sdist = { url = "https://files.pythonhosted.org/packages/46/79/cf31d7a93a8fdc6aa0fbb665be84426a8c5a557d9240b6239e9e11e35fc5/termcolor-3.3.0.tar.gz", upload-time = 2025-12-29T12:55:21Z, size = 14434, hashes = { sha256 = "348871ca648ec6a9a983a13ab626c0acce02f515b9e1983332b17af7979521c5" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/33/d1/8bb87d21e9aeb323cc03034f5eaf2c8f69841e40e4853c2627edf8111ed3/termcolor-3.3.0-py3-none-any.whl", upload-time = 2025-12-29T12:55:20Z, size = 7734, hashes = { sha256 = "cf642efadaf0a8ebbbf4bc7a31cec2f9b5f21a9f726f4ccbb08192c9c26f43a5" } }] - [[packages]] name = "thinc" version = "8.3.13" @@ -1135,12 +1040,6 @@ version = "0.2.3" sdist = { url = "https://files.pythonhosted.org/packages/08/f1/72b313366285263aaba21a17714fbef597d7662a8737a928b2b4784eb46e/unlzw3-0.2.3.tar.gz", upload-time = 2024-12-20T16:05:55Z, size = 5426, hashes = { sha256 = "ede5d928c792fff9da406f20334f9739693327f448f383ae1df1774627197bbb" } } wheels = [{ url = "https://files.pythonhosted.org/packages/4d/fb/617af9b317ac75f5663285d3a3cc38903a76d63c6e7397768307545f4ff4/unlzw3-0.2.3-py3-none-any.whl", upload-time = 2024-12-20T16:05:53Z, size = 6729, hashes = { sha256 = "7760fb4f3afa1225623944c061991d89a061f7fb78665dbc4cddfdb562bb4a8b" } }] -[[packages]] -name = "uritemplate" -version = "4.2.0" -sdist = { url = "https://files.pythonhosted.org/packages/98/60/f174043244c5306c9988380d2cb10009f91563fc4b31293d27e17201af56/uritemplate-4.2.0.tar.gz", upload-time = 2025-06-02T15:12:06Z, size = 33267, hashes = { sha256 = "480c2ed180878955863323eea31b0ede668795de182617fef9c6ca09e6ec9d0e" } } -wheels = [{ url = "https://files.pythonhosted.org/packages/a9/99/3ae339466c9183ea5b8ae87b34c0b897eda475d2aec2307cae60e5cd4f29/uritemplate-4.2.0-py3-none-any.whl", upload-time = 2025-06-02T15:12:03Z, size = 11488, hashes = { sha256 = "962201ba1c4edcab02e60f9a0d3821e82dfc5d2d6662a21abd533879bdb8a686" } }] - [[packages]] name = "urllib3" version = "2.7.0" diff --git a/packages/sie_server/bundles/default.yaml b/packages/sie_server/bundles/default.yaml index a9426b5a2..4db0c340d 100644 --- a/packages/sie_server/bundles/default.yaml +++ b/packages/sie_server/bundles/default.yaml @@ -108,13 +108,10 @@ deps: # Pinned to the compatibility pair of the immutable artifact revision in # models/docling.yaml; see packages/sie_server/pyproject.toml (#2872). docling: '>=2.99,<2.100' - # kokoro (Kokoro-82M text-to-speech). kokoro requires misaki[en]; the - # packages of that extra the adapter imports are listed with their own ranges. - kokoro: '==0.9.4' + # kokoro (Kokoro-82M text-to-speech). The adapter carries the model code and + # its own out-of-lexicon fallback, so it needs misaki's English G2P only: + # misaki without extras, plus the English packages misaki.en imports. misaki: '==0.9.4' - # Ships the espeak-ng library and data that misaki's fallback G2P loads. - espeakng-loader: '>=0.2.4,<0.3' - phonemizer-fork: '>=3.3.2,<4' num2words: '>=0.5.14,<1' # 3.8.16 and later need click>=8.2.1, above the root lock's click. spacy: '>=3.8,<3.8.16' From 13478eedbe7de554fd673e913f2e3c154a9ab53a Mon Sep 17 00:00:00 2001 From: Shai Shmuel Date: Mon, 30 Nov 2026 13:54:09 +0200 Subject: [PATCH 4/6] docs: describe how Kokoro-82M speaks words outside its lexicon --- packages/sie_server/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/sie_server/README.md b/packages/sie_server/README.md index 26edd95e7..060de43d9 100644 --- a/packages/sie_server/README.md +++ b/packages/sie_server/README.md @@ -779,6 +779,15 @@ audio may last up to four minutes; a longer item fails alone with number of phoneme ids the model read for the items that returned audio; a refused item counts nothing. Items are synthesized one at a time. +Text becomes phonemes through misaki's English lexicon. A word outside it, such +as a rare name or an invented word, is read by the `cisco-ai/mini-bart-g2p` +letter-to-sound model (Apache-2.0, 16 MB), so it is spoken, though less reliably +than a dictionary word. Tokens with digits or symbols, such as `5:30`, `km/h` or +an e-mail address, are split and read piece by piece, and short words without +vowels, such as `mg`, are spelled. The model is loaded at a pinned revision +alongside the Kokoro checkpoint (loadtime options `g2p_model` and +`g2p_revision`), so a server without Hub access needs both in its cache. + ### ModernBERT CUDA graphs The ModernBERT flash-attention adapters, for dense embeddings From 9334d8e88c2ab70b877fe9544b75a1d5fba09e79 Mon Sep 17 00:00:00 2001 From: Shai Shmuel Date: Mon, 30 Nov 2026 15:25:15 +0200 Subject: [PATCH 5/6] fix(server): refuse incomplete Kokoro checkpoints and keep every phoneme Checkpoint loading now fails when a component is absent, or when a component's state dict has unknown names or lacks parameters other than the instance-norm affine parameters the released checkpoint does not store. Before, such a checkpoint was served with constructor weights. Phoneme chunking counted one character too few after a split at punctuation, so a chunk could reach 511 phonemes and lose its last one. The space after the last kept token is now counted. A single token longer than one forward pass, such as a long pronunciation override, is read in consecutive pieces instead of losing its tail. Paragraphs are prefetched and phonemized in groups no larger than the parse cache, so a text with more paragraphs than the cache holds is not parsed twice. --- .../adapters/kokoro/g2p_fallback.py | 4 +- .../src/sie_server/adapters/kokoro/model.py | 22 +++- .../sie_server/adapters/kokoro/pipeline.py | 29 +++-- .../sie_server/tests/adapters/test_kokoro.py | 112 +++++++++++++++++- 4 files changed, 151 insertions(+), 16 deletions(-) diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py b/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py index cfbfea006..97ca6ced1 100644 --- a/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py +++ b/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py @@ -81,7 +81,7 @@ _BATCH_SIZE = 256 _CACHE_SIZE = 4096 # spaCy parses kept between the collecting pass and the real pass. -_PARSE_CACHE_SIZE = 64 +PARSE_CACHE_SIZE = 64 # Symbols said as words inside a token. misaki has words for % & + @ too, but # spaCy sometimes tags a lone one as punctuation, and misaki then drops it. @@ -159,7 +159,7 @@ def __call__(self, text: str) -> Any: doc = self._nlp(text) with self._lock: self._docs[text] = doc - while len(self._docs) > _PARSE_CACHE_SIZE: + while len(self._docs) > PARSE_CACHE_SIZE: self._docs.popitem(last=False) return doc diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/model.py b/packages/sie_server/src/sie_server/adapters/kokoro/model.py index 8faa7df84..002024381 100644 --- a/packages/sie_server/src/sie_server/adapters/kokoro/model.py +++ b/packages/sie_server/src/sie_server/adapters/kokoro/model.py @@ -20,6 +20,11 @@ from sie_server.adapters.kokoro.modules import CustomAlbert, ProsodyPredictor, TextEncoder _MODULE_PREFIX = "module." +#: Components a Kokoro checkpoint must hold, one state dict each. +_COMPONENTS = ("bert", "bert_encoder", "predictor", "text_encoder", "decoder") +#: The released checkpoint does not store the affine parameters of the instance +#: norms inside its adaptive normalization layers; they keep their constructor values. +_UNSAVED_SUFFIXES = (".norm.weight", ".norm.bias") class KModel(nn.Module): @@ -50,7 +55,15 @@ def __init__(self, config: str | Path | dict[str, Any], model: str | Path) -> No self.decoder = Decoder( dim_in=config["hidden_dim"], style_dim=config["style_dim"], dim_out=config["n_mels"], **config["istftnet"] ) + self._load_checkpoint(model) + + def _load_checkpoint(self, model: str | Path) -> None: + """Load every component's weights, refusing a checkpoint that does not fit the model.""" checkpoint = torch.load(str(model), map_location="cpu", weights_only=True) + absent = [key for key in _COMPONENTS if key not in checkpoint] + if absent: + msg = f"Kokoro checkpoint is missing components {absent}" + raise ValueError(msg) for key, state_dict in checkpoint.items(): module = getattr(self, key, None) if not isinstance(module, nn.Module): @@ -61,7 +74,14 @@ def __init__(self, config: str | Path | dict[str, Any], model: str | Path) -> No except RuntimeError: # The released checkpoint stores DataParallel names ("module." prefix). stripped = {k.removeprefix(_MODULE_PREFIX): v for k, v in state_dict.items()} - module.load_state_dict(stripped, strict=False) + result = module.load_state_dict(stripped, strict=False) + missing = [name for name in result.missing_keys if not name.endswith(_UNSAVED_SUFFIXES)] + if missing or result.unexpected_keys: + msg = ( + f"Kokoro checkpoint component {key!r} does not match the model: " + f"missing {missing[:5]}, unexpected {result.unexpected_keys[:5]}" + ) + raise ValueError(msg) from None @property def device(self) -> torch.device: diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py b/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py index cbb25da0e..9d686395e 100644 --- a/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py +++ b/packages/sie_server/src/sie_server/adapters/kokoro/pipeline.py @@ -21,7 +21,7 @@ import torch -from sie_server.adapters.kokoro.g2p_fallback import Fallback, LetterToSound +from sie_server.adapters.kokoro.g2p_fallback import PARSE_CACHE_SIZE, Fallback, LetterToSound from sie_server.adapters.kokoro.model import KModel #: Longest phoneme string ``KModel`` reads in one forward pass (512 ids minus the two boundary ids). @@ -62,15 +62,20 @@ def load_voice(self, path: str | Path) -> torch.Tensor: def __call__(self, text: str, voice: str | Path, speed: float = 1) -> Iterator[Result]: pack = self.load_voice(voice).to(self.model.device) paragraphs = [graphemes for graphemes in re.split(r"\n+", text.strip()) if graphemes.strip()] - self.fallback.prefetch(paragraphs) - for graphemes in paragraphs: - _, tokens = self.g2p(graphemes) - for gs, ps in _chunks(tokens): - if not ps: - continue - ps = ps[:MAX_PHONEMES] - audio = self.model(ps, pack[len(ps) - 1], speed) - yield Result(graphemes=gs, phonemes=ps, audio=audio) + # Prefetch in groups no larger than the parse cache, so every parse made + # while collecting is still there when the same paragraph is phonemized. + for start in range(0, len(paragraphs), PARSE_CACHE_SIZE): + group = paragraphs[start : start + PARSE_CACHE_SIZE] + self.fallback.prefetch(group) + for graphemes in group: + _, tokens = self.g2p(graphemes) + for gs, chunk in _chunks(tokens): + # One token can be longer than a forward pass (a long pronunciation + # override): read it in consecutive pieces instead of dropping its tail. + for at in range(0, len(chunk), MAX_PHONEMES): + ps = chunk[at : at + MAX_PHONEMES] + audio = self.model(ps, pack[len(ps) - 1], speed) + yield Result(graphemes=gs, phonemes=ps, audio=audio) def _tokens_to_ps(tokens: list[Any]) -> str: @@ -107,7 +112,9 @@ def _chunks(tokens: list[Any]) -> Iterator[tuple[str, str]]: z = _waterfall_last(tks, next_pcount) yield _tokens_to_text(tks[:z]), _tokens_to_ps(tks[:z]) tks = tks[z:] - pcount = len(_tokens_to_ps(tks)) + # ``_tokens_to_ps`` strips the space after the last kept token, which the + # next token will follow. + pcount = len(_tokens_to_ps(tks)) + (1 if tks and tks[-1].whitespace else 0) if not tks: next_ps = next_ps.lstrip() tks.append(t) diff --git a/packages/sie_server/tests/adapters/test_kokoro.py b/packages/sie_server/tests/adapters/test_kokoro.py index f624735fc..a0d69dcd4 100644 --- a/packages/sie_server/tests/adapters/test_kokoro.py +++ b/packages/sie_server/tests/adapters/test_kokoro.py @@ -388,13 +388,24 @@ def _tiny_checkpoint(directory: Path) -> Path: }, } (directory / "config.json").write_text(json.dumps(config)) - # No tensors: every parameter keeps its random initialisation. - torch.save({}, directory / "kokoro-v1_0.pth") + torch.save(_random_state(config), directory / "kokoro-v1_0.pth") (directory / "voices").mkdir() torch.save(torch.randn(128, 1, 256), directory / "voices" / "af_heart.pt") return directory +def _random_state(config: dict[str, Any]) -> dict[str, dict[str, torch.Tensor]]: + """One randomly initialised state dict per Kokoro component.""" + model_module = importlib.import_module("sie_server.adapters.kokoro.model") + + class _Unloaded(model_module.KModel): + def _load_checkpoint(self, model: str | Path) -> None: + pass + + built = _Unloaded(config, "unused") + return {key: getattr(built, key).state_dict() for key in model_module._COMPONENTS} + + _ARPABET = ("AA1", "AE1", "AH0", "AH1", "AO1", "AW1", "AY1", "EH1", "ER0", "ER1", "EY1", "IH1", "IY0", "IY1", "OW1", "OY1", "UH1", "UW1", "B", "CH", "D", "DH", "F", "G", "HH", "JH", "K", "L", "M", "N", "NG", "P", "R", "S", "SH", "T", "TH", "V", "W", "Y", "Z", "ZH", "AA2") # fmt: skip @@ -433,3 +444,100 @@ def test_adapter_loads_and_speaks_without_the_espeak_packages(monkeypatch: pytes assert output.input_token_counts is not None assert output.input_token_counts[0] > 10 assert not any(name in sys.modules for name in _ESPEAK_MODULES) + + +def _tiny_model_files(tmp_path: Path) -> tuple[ModuleType, dict[str, Any], dict[str, dict[str, torch.Tensor]], Path]: + directory = _tiny_checkpoint(tmp_path) + config = json.loads((directory / "config.json").read_text()) + return importlib.import_module("sie_server.adapters.kokoro.model"), config, _random_state(config), directory + + +def test_model_loads_a_prefixed_checkpoint_without_instance_norm_parameters(tmp_path: Path) -> None: + # The released checkpoint has DataParallel names and no instance-norm affine parameters. + module, config, state, directory = _tiny_model_files(tmp_path) + released = { + key: { + f"module.{name}": value for name, value in component.items() if not name.endswith(module._UNSAVED_SUFFIXES) + } + for key, component in state.items() + } + assert any(len(released[key]) < len(state[key]) for key in state) + torch.save(released, directory / "released.pth") + + model = module.KModel(config, directory / "released.pth") + + assert torch.equal(model.bert_encoder.weight, state["bert_encoder"]["weight"]) + + +def test_model_rejects_a_checkpoint_without_a_component(tmp_path: Path) -> None: + module, config, state, directory = _tiny_model_files(tmp_path) + del state["decoder"] + torch.save(state, directory / "partial.pth") + + with pytest.raises(ValueError, match=r"missing components \['decoder'\]"): + module.KModel(config, directory / "partial.pth") + + +def test_model_rejects_a_component_with_missing_or_unknown_parameters(tmp_path: Path) -> None: + module, config, state, directory = _tiny_model_files(tmp_path) + missing = {**state, "bert_encoder": {"module.bias": state["bert_encoder"]["bias"]}} + torch.save(missing, directory / "missing.pth") + with pytest.raises(ValueError, match="bert_encoder"): + module.KModel(config, directory / "missing.pth") + + unknown = {**state, "bert_encoder": {**state["bert_encoder"], "extra": torch.zeros(1)}} + torch.save(unknown, directory / "unknown.pth") + with pytest.raises(ValueError, match="bert_encoder"): + module.KModel(config, directory / "unknown.pth") + + +def _token(phonemes: str, *, space: bool = True) -> SimpleNamespace: + return SimpleNamespace(text=phonemes, phonemes=phonemes, whitespace=" " if space else "") + + +def test_chunks_count_the_space_after_a_punctuation_split() -> None: + pipeline = importlib.import_module("sie_server.adapters.kokoro.pipeline") + # A period, 85 five-phoneme words and a last one-phoneme word: the split after the + # period keeps 84 words, and the space before the 85th has to be counted. + tokens = [_token("."), *[_token("abcde") for _ in range(85)], _token("f", space=False)] + + chunks = [phonemes for _, phonemes in pipeline._chunks(tokens)] + + assert all(len(phonemes) <= pipeline.MAX_PHONEMES for phonemes in chunks) + assert "".join(chunks).replace(" ", "") == "." + "abcde" * 85 + "f" + + +def test_a_token_longer_than_one_pass_is_read_in_pieces(monkeypatch: pytest.MonkeyPatch) -> None: + pipeline = importlib.import_module("sie_server.adapters.kokoro.pipeline") + long_token = "a" * (2 * pipeline.MAX_PHONEMES + 7) + speaker = pipeline.EnglishPipeline.__new__(pipeline.EnglishPipeline) + read: list[str] = [] + speaker.model = lambda ps, ref, speed: read.append(ps) or torch.zeros(1) + speaker.model.device = "cpu" # ty: ignore[unresolved-attribute] + speaker.g2p = lambda text: ("", [_token(long_token, space=False)]) + speaker.fallback = SimpleNamespace(prefetch=lambda texts: None) + speaker._voices = {"voice": torch.zeros(pipeline.MAX_PHONEMES, 1, 4)} + + results = list(speaker("text", "voice")) + + assert [len(ps) for ps in read] == [pipeline.MAX_PHONEMES, pipeline.MAX_PHONEMES, 7] + assert "".join(result.phonemes for result in results) == long_token + + +def test_paragraphs_are_prefetched_in_groups_the_parse_cache_can_hold() -> None: + pipeline = importlib.import_module("sie_server.adapters.kokoro.pipeline") + speaker = pipeline.EnglishPipeline.__new__(pipeline.EnglishPipeline) + events: list[tuple[str, int]] = [] + speaker.model = lambda ps, ref, speed: torch.zeros(1) + speaker.model.device = "cpu" # ty: ignore[unresolved-attribute] + speaker.g2p = lambda text: (events.append(("g2p", 1)) or "", [_token("a")]) + speaker.fallback = SimpleNamespace(prefetch=lambda texts: events.append(("prefetch", len(texts)))) + speaker._voices = {"voice": torch.zeros(pipeline.MAX_PHONEMES, 1, 4)} + count = pipeline.PARSE_CACHE_SIZE + 1 + + list(speaker("\n".join(f"line {index}" for index in range(count)), "voice")) + + # The first group is prefetched and spoken before the second group is prefetched. + assert events[0] == ("prefetch", pipeline.PARSE_CACHE_SIZE) + assert events[pipeline.PARSE_CACHE_SIZE + 1] == ("prefetch", 1) + assert sum(1 for kind, _ in events if kind == "g2p") == count From a09034de0b68f647fe1bcc0a7b4b91db34e4c3e9 Mon Sep 17 00:00:00 2001 From: Shai Shmuel Date: Mon, 30 Nov 2026 15:56:54 +0200 Subject: [PATCH 6/6] fix(server): keep paragraph parses apart from split-token parses Reading a token with digits or symbols parses its pieces through the same recent-parse cache as whole paragraphs, so a group of paragraphs with many such tokens could push its own paragraph parses out before they were phonemized. Nested parses now have their own bounded cache. --- .../adapters/kokoro/g2p_fallback.py | 28 ++++++++++++------- .../sie_server/tests/adapters/test_kokoro.py | 6 ++-- .../tests/adapters/test_kokoro_g2p.py | 26 +++++++++++++++++ 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py b/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py index 97ca6ced1..7889c8a8f 100644 --- a/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py +++ b/packages/sie_server/src/sie_server/adapters/kokoro/g2p_fallback.py @@ -143,24 +143,32 @@ def _bounded(phonemes: str) -> str: class _RecentParses: - """Wraps a spaCy pipeline and returns the same parse for a text seen recently.""" + """Wraps a spaCy pipeline and returns the same parse for a text seen recently. - def __init__(self, nlp: Callable[[str], Any]) -> None: + Texts parsed while a split token is being read (``nested()`` is true) are kept + apart from whole paragraphs, so they cannot push a paragraph's parse out + before the paragraph is phonemized. + """ + + def __init__(self, nlp: Callable[[str], Any], nested: Callable[[], bool]) -> None: self._nlp = nlp - self._docs: OrderedDict[str, Any] = OrderedDict() + self._nested = nested + self._paragraphs: OrderedDict[str, Any] = OrderedDict() + self._pieces: OrderedDict[str, Any] = OrderedDict() self._lock = threading.Lock() def __call__(self, text: str) -> Any: + docs = self._pieces if self._nested() else self._paragraphs with self._lock: - doc = self._docs.get(text) + doc = docs.get(text) if doc is not None: - self._docs.move_to_end(text) + docs.move_to_end(text) return doc doc = self._nlp(text) with self._lock: - self._docs[text] = doc - while len(self._docs) > PARSE_CACHE_SIZE: - self._docs.popitem(last=False) + docs[text] = doc + while len(docs) > PARSE_CACHE_SIZE: + docs.popitem(last=False) return doc @@ -234,10 +242,10 @@ def __init__( self.letter_to_sound = letter_to_sound self.british = british self._subtokenize = subtokenize - if hasattr(g2p, "nlp"): - g2p.nlp = _RecentParses(g2p.nlp) # Re-entry depth and the collecting pass belong to the calling thread. self._state = threading.local() + if hasattr(g2p, "nlp"): + g2p.nlp = _RecentParses(g2p.nlp, nested=lambda: getattr(self._state, "depth", 0) > 0) def prefetch(self, texts: Iterable[str]) -> None: """Read every letter chunk misaki would ask for in ``texts`` in one batched model call.""" diff --git a/packages/sie_server/tests/adapters/test_kokoro.py b/packages/sie_server/tests/adapters/test_kokoro.py index a0d69dcd4..cadee12cf 100644 --- a/packages/sie_server/tests/adapters/test_kokoro.py +++ b/packages/sie_server/tests/adapters/test_kokoro.py @@ -509,19 +509,19 @@ def test_chunks_count_the_space_after_a_punctuation_split() -> None: def test_a_token_longer_than_one_pass_is_read_in_pieces(monkeypatch: pytest.MonkeyPatch) -> None: pipeline = importlib.import_module("sie_server.adapters.kokoro.pipeline") - long_token = "a" * (2 * pipeline.MAX_PHONEMES + 7) + long_phonemes = "a" * (2 * pipeline.MAX_PHONEMES + 7) speaker = pipeline.EnglishPipeline.__new__(pipeline.EnglishPipeline) read: list[str] = [] speaker.model = lambda ps, ref, speed: read.append(ps) or torch.zeros(1) speaker.model.device = "cpu" # ty: ignore[unresolved-attribute] - speaker.g2p = lambda text: ("", [_token(long_token, space=False)]) + speaker.g2p = lambda text: ("", [_token(long_phonemes, space=False)]) speaker.fallback = SimpleNamespace(prefetch=lambda texts: None) speaker._voices = {"voice": torch.zeros(pipeline.MAX_PHONEMES, 1, 4)} results = list(speaker("text", "voice")) assert [len(ps) for ps in read] == [pipeline.MAX_PHONEMES, pipeline.MAX_PHONEMES, 7] - assert "".join(result.phonemes for result in results) == long_token + assert "".join(result.phonemes for result in results) == long_phonemes def test_paragraphs_are_prefetched_in_groups_the_parse_cache_can_hold() -> None: diff --git a/packages/sie_server/tests/adapters/test_kokoro_g2p.py b/packages/sie_server/tests/adapters/test_kokoro_g2p.py index 24e963778..be26106a3 100644 --- a/packages/sie_server/tests/adapters/test_kokoro_g2p.py +++ b/packages/sie_server/tests/adapters/test_kokoro_g2p.py @@ -224,6 +224,32 @@ def test_the_real_pass_reuses_the_collecting_pass_parse() -> None: assert fallback.g2p is g2p +class _ParsingG2P(_FakeG2P): + """Like misaki, parses every text it is given, nested calls included.""" + + def __call__(self, text: str) -> tuple[str, list[Any]]: + self.nlp(text) # ty: ignore[unresolved-attribute] + return super().__call__(text) + + +def test_split_tokens_do_not_push_paragraph_parses_out_of_the_cache() -> None: + g2p, lts = _ParsingG2P(), _FakeLetterToSound() + parsed: list[str] = [] + g2p.nlp = lambda text: parsed.append(text) or text # ty: ignore[unresolved-attribute] + fallback = Fallback(g2p, lts, british=False, subtokenize=_subtokenize) # ty: ignore[invalid-argument-type] + g2p.fallback = fallback + # A full group of paragraphs, each with two split tokens that are parsed on their own. + paragraphs = [f"cat {index}:31 cat{index}@example.com" for index in range(g2p_fallback.PARSE_CACHE_SIZE)] + + fallback.prefetch(paragraphs) + for paragraph in paragraphs: + g2p(paragraph) + + nested = [text for text in parsed if text not in paragraphs] + assert len(set(nested)) > g2p_fallback.PARSE_CACHE_SIZE + assert all(parsed.count(paragraph) == 1 for paragraph in paragraphs) + + def test_reentry_depth_is_per_thread() -> None: # Defect: the re-entry counter was shared, so another thread inside a split # token made this thread's "5:30" skip the split and lose its digits.