zrt 0.0.1b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zrt/__init__.py +41 -0
- zrt/agents/__init__.py +312 -0
- zrt/agents/_agent_registry.py +878 -0
- zrt/agents/_client_meta.py +97 -0
- zrt/agents/_config_builders.py +484 -0
- zrt/agents/_grpc_bridge.py +953 -0
- zrt/agents/_legacy_register.py +382 -0
- zrt/agents/_zrt_auth.py +37 -0
- zrt/agents/a2a.py +18 -0
- zrt/agents/agent.py +113 -0
- zrt/agents/agent_runtime_pb2.py +418 -0
- zrt/agents/agent_runtime_pb2_grpc.py +664 -0
- zrt/agents/audio_track.py +70 -0
- zrt/agents/background_audio.py +16 -0
- zrt/agents/chat.py +78 -0
- zrt/agents/config.py +91 -0
- zrt/agents/debug/__init__.py +3 -0
- zrt/agents/debug/http_server.py +215 -0
- zrt/agents/debug/tracing.py +90 -0
- zrt/agents/denoise.py +27 -0
- zrt/agents/dtmf_handler.py +49 -0
- zrt/agents/enums.py +112 -0
- zrt/agents/event_emitter.py +81 -0
- zrt/agents/execution/__init__.py +3 -0
- zrt/agents/execution/types.py +3 -0
- zrt/agents/fallback.py +57 -0
- zrt/agents/handoff.py +14 -0
- zrt/agents/images.py +60 -0
- zrt/agents/inference/__init__.py +9 -0
- zrt/agents/inference/denoise.py +10 -0
- zrt/agents/inference/llm.py +51 -0
- zrt/agents/inference/realtime.py +43 -0
- zrt/agents/inference/stt.py +89 -0
- zrt/agents/inference/tts.py +95 -0
- zrt/agents/inference/turn.py +87 -0
- zrt/agents/job.py +524 -0
- zrt/agents/knowledge_base.py +53 -0
- zrt/agents/mcp.py +18 -0
- zrt/agents/metrics.py +3 -0
- zrt/agents/pipeline.py +528 -0
- zrt/agents/providers.py +228 -0
- zrt/agents/session.py +1119 -0
- zrt/agents/tools.py +130 -0
- zrt/agents/utils.py +22 -0
- zrt/agents/utterance.py +70 -0
- zrt/agents/voice_mail_detector.py +40 -0
- zrt/plugins/__init__.py +1 -0
- zrt/plugins/anthropic/__init__.py +2 -0
- zrt/plugins/anthropic/llm.py +30 -0
- zrt/plugins/assemblyai/__init__.py +2 -0
- zrt/plugins/assemblyai/stt.py +19 -0
- zrt/plugins/aws/__init__.py +2 -0
- zrt/plugins/aws/tts.py +18 -0
- zrt/plugins/azure/__init__.py +4 -0
- zrt/plugins/azure/stt.py +18 -0
- zrt/plugins/azure/tts.py +17 -0
- zrt/plugins/azure/voice_live.py +76 -0
- zrt/plugins/cambai/__init__.py +2 -0
- zrt/plugins/cambai/tts.py +16 -0
- zrt/plugins/cartesia/__init__.py +7 -0
- zrt/plugins/cartesia/tts.py +80 -0
- zrt/plugins/cerebras/__init__.py +2 -0
- zrt/plugins/cerebras/llm.py +16 -0
- zrt/plugins/cometapi/__init__.py +2 -0
- zrt/plugins/cometapi/llm.py +16 -0
- zrt/plugins/deepgram/__init__.py +2 -0
- zrt/plugins/deepgram/stt.py +45 -0
- zrt/plugins/elevenlabs/__init__.py +2 -0
- zrt/plugins/elevenlabs/tts.py +46 -0
- zrt/plugins/gemini_realtime/__init__.py +2 -0
- zrt/plugins/gemini_realtime/realtime.py +84 -0
- zrt/plugins/gladia/__init__.py +2 -0
- zrt/plugins/gladia/stt.py +17 -0
- zrt/plugins/google/__init__.py +4 -0
- zrt/plugins/google/llm.py +71 -0
- zrt/plugins/google/stt.py +19 -0
- zrt/plugins/google/tts.py +68 -0
- zrt/plugins/groq/__init__.py +3 -0
- zrt/plugins/groq/llm.py +16 -0
- zrt/plugins/groq/tts.py +17 -0
- zrt/plugins/humeai/__init__.py +2 -0
- zrt/plugins/humeai/tts.py +16 -0
- zrt/plugins/inworldai/__init__.py +2 -0
- zrt/plugins/inworldai/tts.py +16 -0
- zrt/plugins/lmnt/__init__.py +2 -0
- zrt/plugins/lmnt/tts.py +16 -0
- zrt/plugins/murfai/__init__.py +2 -0
- zrt/plugins/murfai/tts.py +16 -0
- zrt/plugins/navana/__init__.py +2 -0
- zrt/plugins/navana/turn_detector.py +12 -0
- zrt/plugins/neuphonic/__init__.py +2 -0
- zrt/plugins/neuphonic/tts.py +16 -0
- zrt/plugins/nvidia/__init__.py +3 -0
- zrt/plugins/nvidia/stt.py +16 -0
- zrt/plugins/nvidia/tts.py +15 -0
- zrt/plugins/openai/__init__.py +2 -0
- zrt/plugins/openai/llm.py +42 -0
- zrt/plugins/openai_realtime/__init__.py +2 -0
- zrt/plugins/openai_realtime/realtime.py +69 -0
- zrt/plugins/papla/__init__.py +2 -0
- zrt/plugins/papla/tts.py +15 -0
- zrt/plugins/resemble/__init__.py +2 -0
- zrt/plugins/resemble/tts.py +15 -0
- zrt/plugins/rime/__init__.py +2 -0
- zrt/plugins/rime/tts.py +16 -0
- zrt/plugins/rnnoise/__init__.py +2 -0
- zrt/plugins/rnnoise/denoise.py +8 -0
- zrt/plugins/sarvamai/__init__.py +4 -0
- zrt/plugins/sarvamai/llm.py +17 -0
- zrt/plugins/sarvamai/stt.py +34 -0
- zrt/plugins/sarvamai/tts.py +35 -0
- zrt/plugins/silero/__init__.py +5 -0
- zrt/plugins/silero/vad.py +37 -0
- zrt/plugins/smallestai/__init__.py +2 -0
- zrt/plugins/smallestai/tts.py +16 -0
- zrt/plugins/speechify/__init__.py +2 -0
- zrt/plugins/speechify/tts.py +16 -0
- zrt/plugins/turn_detector/__init__.py +23 -0
- zrt/plugins/turn_detector/detector.py +13 -0
- zrt/plugins/turn_detector/detector_v2.py +13 -0
- zrt/plugins/turn_detector/namo_v2.py +20 -0
- zrt/plugins/ultravox/__init__.py +2 -0
- zrt/plugins/ultravox/realtime.py +67 -0
- zrt/plugins/xai/__init__.py +3 -0
- zrt/plugins/xai/llm.py +16 -0
- zrt/plugins/xai/realtime.py +72 -0
- zrt/py.typed +0 -0
- zrt-0.0.1b1.dist-info/METADATA +234 -0
- zrt-0.0.1b1.dist-info/RECORD +132 -0
- zrt-0.0.1b1.dist-info/WHEEL +5 -0
- zrt-0.0.1b1.dist-info/licenses/LICENSE +54 -0
- zrt-0.0.1b1.dist-info/top_level.txt +1 -0
zrt/__init__.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Zero Runtime (ZRT) — Python SDK.
|
|
2
|
+
|
|
3
|
+
Thin runtime SDK: you author agents and the ZRT cloud runtime executes the
|
|
4
|
+
real-time pipeline (media, VAD, turn detection, STT, LLM, TTS) over gRPC. The
|
|
5
|
+
agent-facing API lives in ``zrt.agents`` with providers under ``zrt.plugins``.
|
|
6
|
+
|
|
7
|
+
This top-level module stays dependency-free (no gRPC stubs) so importing
|
|
8
|
+
``zrt`` is cheap.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any, Dict, Optional
|
|
14
|
+
|
|
15
|
+
__version__ = "0.0.1b1"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class PubSubPublishConfig:
|
|
20
|
+
"""Config for publishing a message on a room pubsub topic.
|
|
21
|
+
|
|
22
|
+
Fields:
|
|
23
|
+
* ``topic`` — pubsub topic name (e.g. ``"CHAT"``, ``"AGENT_EVENT"``).
|
|
24
|
+
* ``message`` — payload body (string or JSON-serializable value).
|
|
25
|
+
* ``mode`` — ``"sendOnly"`` (default) or ``"sendAndPersist"``.
|
|
26
|
+
* ``send_only`` — legacy alias; ``True`` forces ``mode='sendOnly'``.
|
|
27
|
+
* ``payload`` — optional structured payload alongside ``message``.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
topic: str
|
|
31
|
+
message: Any = ""
|
|
32
|
+
mode: str = "sendOnly"
|
|
33
|
+
send_only: bool = False
|
|
34
|
+
payload: Optional[Dict[str, Any]] = None
|
|
35
|
+
|
|
36
|
+
def __post_init__(self) -> None:
|
|
37
|
+
if self.send_only:
|
|
38
|
+
self.mode = "sendOnly"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
__all__ = ["PubSubPublishConfig", "__version__"]
|
zrt/agents/__init__.py
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
def setup_logging(level=logging.INFO):
|
|
7
|
+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
|
8
|
+
console_handler = logging.StreamHandler(sys.stdout)
|
|
9
|
+
console_handler.setFormatter(formatter)
|
|
10
|
+
logger = logging.getLogger('zrt.agents')
|
|
11
|
+
logger.setLevel(level)
|
|
12
|
+
for handler in logger.handlers[:]:
|
|
13
|
+
logger.removeHandler(handler)
|
|
14
|
+
logger.addHandler(console_handler)
|
|
15
|
+
logger.propagate = False
|
|
16
|
+
return logger
|
|
17
|
+
from .agent import Agent
|
|
18
|
+
from .session import AgentSession
|
|
19
|
+
from .pipeline import Pipeline, PipelineHooks, PipelineHookError
|
|
20
|
+
from .utterance import UtteranceHandle
|
|
21
|
+
from .enums import UserState, AgentState, PipelineMode, RealtimeMode, PipelineComponent, PipelineConfig, SpeechEventType, VADEventType, ChatRole, ToolChoice, RecordingFormat, RecordingChannelMode, RecordingTranscriptFormat, RecordingState
|
|
22
|
+
from .config import EOUConfig, InterruptConfig, RealtimeConfig, ContextWindow, RecordingConfig, S3StorageConfig, RecordingTranscriptConfig
|
|
23
|
+
from .tools import function_tool, is_function_tool, get_tool_info, FunctionTool, FunctionToolInfo, build_openai_schema, build_gemini_schema, build_nova_sonic_schema
|
|
24
|
+
from .providers import STT, STTResponse, SpeechData, LLM, LLMResponse, TTS, VAD, VADResponse, VADData, EOU
|
|
25
|
+
from .chat import ChatContext, ChatMessage, ChatContent, FunctionCall, FunctionCallOutput, ImageContent
|
|
26
|
+
from .event_emitter import EventEmitter
|
|
27
|
+
from .job import WorkerJob, JobContext, RoomOptions, RecordingOptions, Options, WebSocketConfig, WebRTCConfig, TracesOptions, MetricsOptions, LoggingOptions
|
|
28
|
+
|
|
29
|
+
class _StubMeta(type):
|
|
30
|
+
|
|
31
|
+
def __getattr__(cls, name):
|
|
32
|
+
return _Stub()
|
|
33
|
+
|
|
34
|
+
class _Stub(metaclass=_StubMeta):
|
|
35
|
+
|
|
36
|
+
def __init__(self, *args, **kwargs):
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
def __call__(self, *args, **kwargs):
|
|
40
|
+
return self
|
|
41
|
+
|
|
42
|
+
def __getattr__(self, name):
|
|
43
|
+
return _Stub()
|
|
44
|
+
|
|
45
|
+
class RealtimeBaseModel:
|
|
46
|
+
|
|
47
|
+
async def __aenter__(self):
|
|
48
|
+
return self
|
|
49
|
+
|
|
50
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
51
|
+
await self.aclose()
|
|
52
|
+
|
|
53
|
+
async def aclose(self) -> None:
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
async def cleanup(self) -> None:
|
|
57
|
+
await self.aclose()
|
|
58
|
+
|
|
59
|
+
def RealtimeLLMAdapter(realtime_model, agent=None):
|
|
60
|
+
try:
|
|
61
|
+
setattr(realtime_model, '_is_realtime_model', True)
|
|
62
|
+
except (AttributeError, TypeError):
|
|
63
|
+
pass
|
|
64
|
+
return realtime_model
|
|
65
|
+
ExecutorType = _Stub
|
|
66
|
+
ResourceType = _Stub
|
|
67
|
+
TaskType = _Stub
|
|
68
|
+
ResourceConfig = _Stub
|
|
69
|
+
TaskConfig = _Stub
|
|
70
|
+
TaskResult = _Stub
|
|
71
|
+
TaskStatus = _Stub
|
|
72
|
+
ResourceStatus = _Stub
|
|
73
|
+
ResourceInfo = _Stub
|
|
74
|
+
HealthMetrics = _Stub
|
|
75
|
+
ResourceManager = _Stub
|
|
76
|
+
ProcessResource = _Stub
|
|
77
|
+
ThreadResource = _Stub
|
|
78
|
+
TaskExecutor = _Stub
|
|
79
|
+
DedicatedInferenceResource = _Stub
|
|
80
|
+
CustomAudioStreamTrack = _Stub
|
|
81
|
+
TeeCustomAudioStreamTrack = _Stub
|
|
82
|
+
TeeMixingCustomAudioStreamTrack = _Stub
|
|
83
|
+
from .mcp import MCPServerStdio, MCPServerHTTP
|
|
84
|
+
from .a2a import AgentCard, A2AMessage
|
|
85
|
+
from .knowledge_base import KnowledgeBaseConfig, KnowledgeBase
|
|
86
|
+
from .images import EncodeOptions, ResizeOptions, encode, coerce_image_to_jpeg_bytes, DEFAULT_REALTIME_ENCODE_OPTIONS
|
|
87
|
+
from .dtmf_handler import DTMFHandler
|
|
88
|
+
from .voice_mail_detector import VoiceMailDetector
|
|
89
|
+
from .fallback import FallbackSTT, FallbackLLM, FallbackTTS
|
|
90
|
+
from .denoise import Denoise
|
|
91
|
+
ConversationalGraphResponse = _Stub
|
|
92
|
+
GraphPipelineAdapter = _Stub
|
|
93
|
+
from .background_audio import BackgroundAudioHandlerConfig
|
|
94
|
+
from .handoff import agent_switch, AGENT_SWITCH_KEY
|
|
95
|
+
|
|
96
|
+
class _EventBus:
|
|
97
|
+
|
|
98
|
+
def on(self, *args, **kwargs):
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
def emit(self, *args, **kwargs):
|
|
102
|
+
pass
|
|
103
|
+
global_event_emitter = _EventBus()
|
|
104
|
+
|
|
105
|
+
class EventTypes:
|
|
106
|
+
pass
|
|
107
|
+
|
|
108
|
+
class _MetricsCollector:
|
|
109
|
+
|
|
110
|
+
def __init__(self) -> None:
|
|
111
|
+
self.turns: list[dict] = []
|
|
112
|
+
|
|
113
|
+
def __getattr__(self, name):
|
|
114
|
+
return lambda *a, **kw: None
|
|
115
|
+
metrics_collector = _MetricsCollector()
|
|
116
|
+
|
|
117
|
+
class WorkerType:
|
|
118
|
+
ROOM = 'room'
|
|
119
|
+
PUBLISHER = 'publisher'
|
|
120
|
+
from dataclasses import dataclass as _ds_worker, field as _f_worker
|
|
121
|
+
|
|
122
|
+
@_ds_worker
|
|
123
|
+
class WorkerPermissions:
|
|
124
|
+
can_publish: bool = True
|
|
125
|
+
can_subscribe: bool = True
|
|
126
|
+
can_publish_data: bool = True
|
|
127
|
+
can_update_metadata: bool = True
|
|
128
|
+
hidden: bool = False
|
|
129
|
+
agent: bool = True
|
|
130
|
+
|
|
131
|
+
@_ds_worker
|
|
132
|
+
class WorkerOptions:
|
|
133
|
+
entrypoint_fnc: Any = None
|
|
134
|
+
request_fnc: Any = None
|
|
135
|
+
initialize_process_fnc: Any = None
|
|
136
|
+
executor_type: Any = None
|
|
137
|
+
num_idle_processes: int = 2
|
|
138
|
+
initialize_timeout: float = 10.0
|
|
139
|
+
close_timeout: float = 60.0
|
|
140
|
+
memory_warn_mb: float = 500.0
|
|
141
|
+
memory_limit_mb: float = 0.0
|
|
142
|
+
ping_interval: float = 30.0
|
|
143
|
+
max_processes: int = 10
|
|
144
|
+
agent_id: str = 'ZeroRuntimeAgent'
|
|
145
|
+
auth_token: Optional[str] = None
|
|
146
|
+
worker_type: str = WorkerType.ROOM
|
|
147
|
+
permissions: WorkerPermissions = _f_worker(default_factory=WorkerPermissions)
|
|
148
|
+
max_retry: int = 16
|
|
149
|
+
load_threshold: float = 0.75
|
|
150
|
+
register: bool = False
|
|
151
|
+
signaling_base_url: str = os.environ.get('ZRT_SIGNALING_URL', 'api.videosdk.live')
|
|
152
|
+
host: str = '0.0.0.0'
|
|
153
|
+
port: int = 8081
|
|
154
|
+
log_level: str = 'INFO'
|
|
155
|
+
|
|
156
|
+
class Worker:
|
|
157
|
+
|
|
158
|
+
def __init__(self, options: Optional[WorkerOptions]=None, default_room_options=None):
|
|
159
|
+
self.options = options
|
|
160
|
+
self.default_room_options = default_room_options
|
|
161
|
+
|
|
162
|
+
@staticmethod
|
|
163
|
+
def run_worker(options: Optional[WorkerOptions]=None, default_room_options=None):
|
|
164
|
+
if options is None or options.entrypoint_fnc is None:
|
|
165
|
+
raise ValueError('Worker.run_worker requires WorkerOptions(entrypoint_fnc=...). For the new API prefer WorkerJob(entrypoint=...).start().')
|
|
166
|
+
new_opts = Options(executor_type=options.executor_type, num_idle_processes=options.num_idle_processes, initialize_timeout=options.initialize_timeout, close_timeout=options.close_timeout, memory_warn_mb=options.memory_warn_mb, memory_limit_mb=options.memory_limit_mb, ping_interval=options.ping_interval, max_processes=options.max_processes, agent_id=options.agent_id, auth_token=options.auth_token, permissions=options.permissions, max_retry=options.max_retry, load_threshold=options.load_threshold, register=options.register, signaling_base_url=options.signaling_base_url, host=options.host, port=options.port, log_level=options.log_level)
|
|
167
|
+
jobctx = None
|
|
168
|
+
if default_room_options is not None:
|
|
169
|
+
jobctx = lambda: JobContext(room_options=default_room_options)
|
|
170
|
+
job = WorkerJob(entrypoint=options.entrypoint_fnc, jobctx=jobctx, options=new_opts)
|
|
171
|
+
job.start()
|
|
172
|
+
|
|
173
|
+
class FlushMarker:
|
|
174
|
+
|
|
175
|
+
def __repr__(self) -> str:
|
|
176
|
+
return '<FlushMarker>'
|
|
177
|
+
from .job import ObservabilityOptions
|
|
178
|
+
|
|
179
|
+
class TTSAudioCache:
|
|
180
|
+
|
|
181
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
182
|
+
self._files: dict[str, bytes] = {}
|
|
183
|
+
|
|
184
|
+
def add(self, key: str, data: bytes) -> None:
|
|
185
|
+
self._files[key] = data
|
|
186
|
+
|
|
187
|
+
def get(self, key: str) -> Optional[bytes]:
|
|
188
|
+
return self._files.get(key)
|
|
189
|
+
|
|
190
|
+
def clear(self) -> None:
|
|
191
|
+
self._files.clear()
|
|
192
|
+
|
|
193
|
+
def __contains__(self, key: str) -> bool:
|
|
194
|
+
return key in self._files
|
|
195
|
+
|
|
196
|
+
def load_audio_file(path: str) -> bytes:
|
|
197
|
+
try:
|
|
198
|
+
with open(path, 'rb') as f:
|
|
199
|
+
return f.read()
|
|
200
|
+
except (FileNotFoundError, IsADirectoryError, PermissionError):
|
|
201
|
+
return b''
|
|
202
|
+
|
|
203
|
+
class SentenceChunker:
|
|
204
|
+
|
|
205
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
206
|
+
pass
|
|
207
|
+
|
|
208
|
+
def chunk(self, text: str) -> list[str]:
|
|
209
|
+
return [text] if text else []
|
|
210
|
+
|
|
211
|
+
def __call__(self, text: str) -> list[str]:
|
|
212
|
+
return self.chunk(text)
|
|
213
|
+
|
|
214
|
+
class SentenceChunkStream:
|
|
215
|
+
|
|
216
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
217
|
+
pass
|
|
218
|
+
|
|
219
|
+
async def __aiter__(self):
|
|
220
|
+
if False:
|
|
221
|
+
yield ''
|
|
222
|
+
|
|
223
|
+
class BufferedSentenceChunkStream(SentenceChunkStream):
|
|
224
|
+
pass
|
|
225
|
+
|
|
226
|
+
class BasicSentenceChunker(SentenceChunker):
|
|
227
|
+
pass
|
|
228
|
+
|
|
229
|
+
class IndicSentenceChunker(SentenceChunker):
|
|
230
|
+
pass
|
|
231
|
+
|
|
232
|
+
class IndicScriptTransliterator:
|
|
233
|
+
|
|
234
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
235
|
+
pass
|
|
236
|
+
|
|
237
|
+
def transliterate(self, text: str, target_script: str='deva') -> str:
|
|
238
|
+
return text
|
|
239
|
+
|
|
240
|
+
class TextFilter:
|
|
241
|
+
|
|
242
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
243
|
+
pass
|
|
244
|
+
|
|
245
|
+
def filter(self, text: str) -> str:
|
|
246
|
+
return text
|
|
247
|
+
|
|
248
|
+
def __call__(self, text: str) -> str:
|
|
249
|
+
return self.filter(text)
|
|
250
|
+
|
|
251
|
+
class BasicTextFilter(TextFilter):
|
|
252
|
+
pass
|
|
253
|
+
|
|
254
|
+
class EnglishHyphenator:
|
|
255
|
+
|
|
256
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
257
|
+
pass
|
|
258
|
+
|
|
259
|
+
def hyphenate(self, word: str) -> str:
|
|
260
|
+
return word
|
|
261
|
+
|
|
262
|
+
def hyphenate_english(word: str) -> str:
|
|
263
|
+
return word
|
|
264
|
+
|
|
265
|
+
def detect_script(text: str) -> str:
|
|
266
|
+
return 'latin'
|
|
267
|
+
|
|
268
|
+
def normalize_lang_code(code: Optional[str]) -> str:
|
|
269
|
+
return (code or 'en').split('-')[0].lower()
|
|
270
|
+
|
|
271
|
+
def pre_warm_tokenizer(*args, **kwargs) -> None:
|
|
272
|
+
return None
|
|
273
|
+
INDIC_LANGS: list[str] = ['hi', 'bn', 'gu', 'kn', 'ml', 'mr', 'or', 'pa', 'ta', 'te', 'ur', 'as', 'sa', 'sd']
|
|
274
|
+
import asyncio as _asyncio_for_run_helpers
|
|
275
|
+
import contextvars as _contextvars
|
|
276
|
+
_STT_OBSERVATION_QUEUE: _contextvars.ContextVar = _contextvars.ContextVar('_zrt_stt_observation_queue', default=None)
|
|
277
|
+
|
|
278
|
+
async def run_stt(audio_stream):
|
|
279
|
+
queue = _STT_OBSERVATION_QUEUE.get()
|
|
280
|
+
if queue is None:
|
|
281
|
+
async for _ in audio_stream:
|
|
282
|
+
pass
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
async def _drain():
|
|
286
|
+
try:
|
|
287
|
+
async for _ in audio_stream:
|
|
288
|
+
pass
|
|
289
|
+
except Exception:
|
|
290
|
+
pass
|
|
291
|
+
drain_task = _asyncio_for_run_helpers.create_task(_drain())
|
|
292
|
+
try:
|
|
293
|
+
while True:
|
|
294
|
+
event = await queue.get()
|
|
295
|
+
if event is None:
|
|
296
|
+
return
|
|
297
|
+
yield event
|
|
298
|
+
finally:
|
|
299
|
+
drain_task.cancel()
|
|
300
|
+
try:
|
|
301
|
+
await drain_task
|
|
302
|
+
except BaseException:
|
|
303
|
+
pass
|
|
304
|
+
|
|
305
|
+
async def run_tts(text_stream):
|
|
306
|
+
async for _ in text_stream:
|
|
307
|
+
pass
|
|
308
|
+
|
|
309
|
+
async def segment_text(chunks, **kwargs):
|
|
310
|
+
async for chunk in chunks:
|
|
311
|
+
yield chunk
|
|
312
|
+
__all__ = ['Agent', 'AgentSession', 'Pipeline', 'PipelineHooks', 'PipelineHookError', 'UtteranceHandle', 'UserState', 'AgentState', 'PipelineMode', 'RealtimeMode', 'PipelineComponent', 'PipelineConfig', 'SpeechEventType', 'VADEventType', 'ChatRole', 'ToolChoice', 'EOUConfig', 'InterruptConfig', 'RealtimeConfig', 'ContextWindow', 'RecordingConfig', 'S3StorageConfig', 'RecordingTranscriptConfig', 'RecordingFormat', 'RecordingChannelMode', 'RecordingTranscriptFormat', 'RecordingState', 'function_tool', 'is_function_tool', 'get_tool_info', 'FunctionTool', 'FunctionToolInfo', 'build_openai_schema', 'build_gemini_schema', 'build_nova_sonic_schema', 'STT', 'STTResponse', 'SpeechData', 'LLM', 'LLMResponse', 'TTS', 'FlushMarker', 'VAD', 'VADResponse', 'VADData', 'EOU', 'ChatContext', 'ChatMessage', 'ChatContent', 'FunctionCall', 'FunctionCallOutput', 'ImageContent', 'EventEmitter', 'global_event_emitter', 'EventTypes', 'WorkerJob', 'JobContext', 'RoomOptions', 'RecordingOptions', 'Options', 'WebSocketConfig', 'WebRTCConfig', 'TracesOptions', 'MetricsOptions', 'LoggingOptions', 'ObservabilityOptions', 'Worker', 'WorkerOptions', 'WorkerType', 'WorkerPermissions', 'RealtimeBaseModel', 'RealtimeLLMAdapter', 'CustomAudioStreamTrack', 'TeeCustomAudioStreamTrack', 'TeeMixingCustomAudioStreamTrack', 'MCPServerStdio', 'MCPServerHTTP', 'AgentCard', 'A2AMessage', 'EncodeOptions', 'ResizeOptions', 'encode', 'coerce_image_to_jpeg_bytes', 'DEFAULT_REALTIME_ENCODE_OPTIONS', 'KnowledgeBaseConfig', 'KnowledgeBase', 'DTMFHandler', 'VoiceMailDetector', 'FallbackSTT', 'FallbackLLM', 'FallbackTTS', 'ConversationalGraphResponse', 'GraphPipelineAdapter', 'BackgroundAudioHandlerConfig', 'agent_switch', 'AGENT_SWITCH_KEY', 'ExecutorType', 'ResourceType', 'TaskType', 'ResourceConfig', 'TaskConfig', 'TaskResult', 'TaskStatus', 'ResourceStatus', 'ResourceInfo', 'HealthMetrics', 'ResourceManager', 'ProcessResource', 'ThreadResource', 'TaskExecutor', 'DedicatedInferenceResource', 'metrics_collector', 'setup_logging', 'run_stt', 'run_tts', 'segment_text', 'SentenceChunker', 'SentenceChunkStream', 'BufferedSentenceChunkStream', 'BasicSentenceChunker', 'IndicSentenceChunker', 'IndicScriptTransliterator', 'TextFilter', 'BasicTextFilter', 'EnglishHyphenator', 'hyphenate_english', 'detect_script', 'normalize_lang_code', 'INDIC_LANGS', 'pre_warm_tokenizer', 'TTSAudioCache', 'load_audio_file']
|