mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 05:40:26 +02:00
tts: fix kokoro AlbertModel import for transformers 5.x (plugin architecture)
- Monkey-patch transformers.AlbertModel in plugins/kokoro/__init__.py before kokoro imports it - Works with transformers 4.x (no-op) and 5.x (adds moved symbol) - No pinning, forks, or extra files needed
This commit is contained in:
@@ -34,6 +34,13 @@ from .engine import KokoroEngine
|
|||||||
|
|
||||||
def _load_kpipeline() -> Any:
|
def _load_kpipeline() -> Any:
|
||||||
"""Lazy-load Kokoro dependencies."""
|
"""Lazy-load Kokoro dependencies."""
|
||||||
|
# Transformers 5.x moved AlbertModel out of top-level imports.
|
||||||
|
# Monkey-patch before kokoro imports it.
|
||||||
|
import transformers
|
||||||
|
if not hasattr(transformers, "AlbertModel"):
|
||||||
|
from transformers.models.albert import AlbertModel as _AlbertModel
|
||||||
|
transformers.AlbertModel = _AlbertModel
|
||||||
|
|
||||||
from kokoro import KPipeline # type: ignore[import-not-found]
|
from kokoro import KPipeline # type: ignore[import-not-found]
|
||||||
return KPipeline
|
return KPipeline
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user