mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Introduce static type checking with pyright (#255)
This commit is contained in:
committed by
GitHub
parent
d7995b8116
commit
0767030997
@@ -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]: ...
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user