ワンクリックで
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 ページを確認してインストールできます。
{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.
SOC 職業分類に基づく
| 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: