원클릭으로
local-onnx-pipeline
Patterns for building local ONNX inference pipelines with async streaming and TTS integration
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Patterns for building local ONNX inference pipelines with async streaming and TTS integration
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
{what this skill teaches agents}
{what this skill teaches agents}
Expert guidance for implementing OpenAI gpt-realtime-1.5, including WebRTC, WebSocket, and SIP configurations.
| name | local-onnx-pipeline |
| description | Patterns for building local ONNX inference pipelines with async streaming and TTS integration |
| domain | ai-inference |
| confidence | high |
| source | earned — Phase 2 Phi-4 ONNX + Piper TTS implementation |
When building local/offline AI inference pipelines using ONNX models with text-to-speech output, these patterns ensure non-blocking async operation, proper audio format handling, and graceful degradation.
ONNX inference is synchronous. Bridge to async generators via asyncio.Queue:
queue: asyncio.Queue[str | None] = asyncio.Queue()
def _run_inference():
# Sync ONNX generation loop
while not generator.is_done():
generator.generate_next_token()
token = tokenizer.decode(generator.get_last_tokens(1))
loop.call_soon_threadsafe(queue.put_nowait, token)
loop.call_soon_threadsafe(queue.put_nowait, None) # sentinel
asyncio.get_event_loop().run_in_executor(None, _run_inference)
while True:
token = await queue.get()
if token is None: break
yield token
Try GPU-specific packages in order:
onnxruntime_genai_cuda (NVIDIA)onnxruntime_genai_directml (Windows GPU)onnxruntime_genai (CPU fallback)np.interpSplit text at sentence boundaries before synthesis for lower first-audio latency.
Use asyncio.Lock to prevent overlapping inference on the same model instance.
When a cloud/local routing layer exists, always check cloud reachability before routing to cloud when a local alternative is available:
async def _check_cloud_reachable(self) -> bool:
try:
timeout = aiohttp.ClientTimeout(total=3, connect=2)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.get(endpoint, ssl=True):
return True
except Exception:
return False
Keep the timeout short (2-3s) so the fallback is fast.
Use a dedicated logger name (e.g., local-pipeline) across all modules in the pipeline. Log every step with session IDs and timing: