mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 05:40:26 +02:00
- Normalize Pipeline public API: create_pipeline(plugin_id, *, lang_code, device) - EngineConfig: add lang_code field per Architecture Amendment #1 - Kokoro plugin reads config.lang_code (fixes functional regression) - Static voice catalog in PluginManifest.voices (None = dynamic/VoiceLister) - get_voices() reads from manifest without creating Engine - Remove dead kwargs (sample_rate, auto_download, total_steps) from SuperTonic - Clean up unused imports and dead code in engine implementations - Fix test expectations for VoiceLister (mock overrides) - Add clear_preview_pipelines() for resource management
93 lines
2.3 KiB
Python
93 lines
2.3 KiB
Python
"""Fake plugin for testing the plugin loader.
|
|
|
|
This is a minimal valid plugin that satisfies the Plugin API contract.
|
|
It does NOT perform any real TTS synthesis.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from abogen.tts_plugin.engine import Engine, EngineSession
|
|
from abogen.tts_plugin.errors import EngineError
|
|
from abogen.tts_plugin.host_context import HostContext
|
|
from abogen.tts_plugin.manifest import (
|
|
AudioFormatManifest,
|
|
EngineManifest,
|
|
PluginManifest,
|
|
VoiceSourceManifest,
|
|
)
|
|
from abogen.tts_plugin.types import (
|
|
AudioFormat,
|
|
Duration,
|
|
EngineConfig,
|
|
ParameterValues,
|
|
SynthesisRequest,
|
|
SynthesizedAudio,
|
|
)
|
|
|
|
|
|
class FakeSession:
|
|
"""Minimal EngineSession implementation for testing."""
|
|
|
|
def __init__(self) -> None:
|
|
self._disposed = False
|
|
|
|
def synthesize(self, request: SynthesisRequest) -> SynthesizedAudio:
|
|
if self._disposed:
|
|
raise EngineError("Session disposed")
|
|
return SynthesizedAudio(
|
|
data=b"\x00" * 100,
|
|
format=AudioFormat(mime="audio/wav", extension="wav"),
|
|
duration=Duration(seconds=1.0),
|
|
)
|
|
|
|
def dispose(self) -> None:
|
|
self._disposed = True
|
|
|
|
|
|
class FakeEngine:
|
|
"""Minimal Engine implementation for testing."""
|
|
|
|
def __init__(self) -> None:
|
|
self._disposed = False
|
|
|
|
def createSession(self) -> EngineSession:
|
|
if self._disposed:
|
|
raise EngineError("Engine disposed")
|
|
return FakeSession()
|
|
|
|
def dispose(self) -> None:
|
|
self._disposed = True
|
|
|
|
|
|
PLUGIN_MANIFEST = PluginManifest(
|
|
id="fake_plugin",
|
|
name="Fake Plugin",
|
|
version="1.0.0",
|
|
api_version="1.0",
|
|
description="A fake plugin for testing",
|
|
author="Test Author",
|
|
capabilities=(),
|
|
engine=EngineManifest(
|
|
voiceSources=(
|
|
VoiceSourceManifest(id="builtin", name="Builtin", type="list"),
|
|
),
|
|
audioFormats=(
|
|
AudioFormatManifest(mime="audio/wav", extension="wav"),
|
|
),
|
|
),
|
|
)
|
|
|
|
MODEL_REQUIREMENTS: list[Any] = []
|
|
|
|
|
|
def create_engine(
|
|
context: HostContext,
|
|
model_path: Path | None,
|
|
config: EngineConfig,
|
|
) -> Engine:
|
|
"""Create a fake engine instance."""
|
|
return FakeEngine()
|