-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
53 lines (35 loc) · 1.19 KB
/
types.py
File metadata and controls
53 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from __future__ import annotations
from dataclasses import dataclass
from typing import AsyncIterator, Protocol, runtime_checkable
@runtime_checkable
class SpeechRecognizer(Protocol):
async def transcribe(self, pcm_bytes: bytes) -> str: ...
@runtime_checkable
class StreamingSpeechSession(Protocol):
async def push_audio(self, pcm_bytes: bytes) -> None: ...
async def finish(self) -> str: ...
async def abort(self) -> None: ...
@runtime_checkable
class StreamingSpeechRecognizer(SpeechRecognizer, Protocol):
async def start_stream(self) -> StreamingSpeechSession: ...
@runtime_checkable
class SpeechSynthesizer(Protocol):
async def synthesize(self, text: str) -> bytes: ...
@dataclass(frozen=True)
class AudioFormat:
sample_rate_hz: int
channels: int
sample_width: int
@runtime_checkable
class StreamingSpeechSynthesizer(SpeechSynthesizer, Protocol):
@property
def output_format(self) -> AudioFormat: ...
def synthesize_stream(self, text: str) -> AsyncIterator[bytes]: ...
__all__ = [
"AudioFormat",
"SpeechRecognizer",
"StreamingSpeechRecognizer",
"StreamingSpeechSession",
"SpeechSynthesizer",
"StreamingSpeechSynthesizer",
]