Introduce static type checking with pyright (#255)

This commit is contained in:
Marcus Valtonen Örnhag
2025-04-05 20:19:05 +02:00
committed by GitHub
parent d7995b8116
commit 0767030997
6 changed files with 45 additions and 26 deletions

View File

@@ -2,7 +2,7 @@ import asyncio
import re
from dataclasses import dataclass
from functools import lru_cache
from typing import AsyncGenerator, Generator, Literal, Protocol
from typing import AsyncGenerator, Generator, Literal, Protocol, TypeVar
import numpy as np
from huggingface_hub import hf_hub_download
@@ -13,17 +13,20 @@ class TTSOptions:
pass
class TTSModel(Protocol):
T = TypeVar("T", bound=TTSOptions, contravariant=True)
class TTSModel(Protocol[T]):
def tts(
self, text: str, options: TTSOptions | None = None
self, text: str, options: T | None = None
) -> tuple[int, NDArray[np.float32]]: ...
async def stream_tts(
self, text: str, options: TTSOptions | None = None
def stream_tts(
self, text: str, options: T | None = None
) -> AsyncGenerator[tuple[int, NDArray[np.float32]], None]: ...
def stream_tts_sync(
self, text: str, options: TTSOptions | None = None
self, text: str, options: T | None = None
) -> Generator[tuple[int, NDArray[np.float32]], None, None]: ...