InferenceResult (end-to-end-speech/speech_model.py)

ai-agent-book · chapter6/end-to-end-speech/speech_model.py · python · Apache-2.0
voice

Python client for local MiniCPM-o 4.5 inference with audio/text support.

# Source: https://github.com/bojieli/ai-agent-book | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Native local MiniCPM-o 4.5 inference for Experiment 6-5."""

from __future__ import annotations

import hashlib
import time
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import Any


MODEL_ID = "openbmb/MiniCPM-o-4_5"
MODEL_REVISION = "1f761131fa83f5ed3cd6f2f22b225c4501d154fa"


@dataclass
class InferenceResult:
    mode: str
    response: str
    latency_seconds: float
    transcript: str | None = None
    stage_latencies: dict[str, float] | None = None
    output_audio: dict[str, Any] | None = None

    def to_dict(self) -> dict[str, Any]:
       

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key