JSON 输出

转录与模型使用稳定、明确的 JSON 契约。

概览

本地网关默认位于 127.0.0.1:1117,并使用 App 内展示的 API key 鉴权。转录、对齐和分句沿用桌面端与 CLI 的结构化文稿约定;模型与兼容 API 则各自遵循对应的响应契约,并不强行共用一种 JSON 形态。

POST /v1/audio/transcriptions  →  {task:"transcribe", duration, language?, text, segments[], usage}
POST /v1/audio/alignments      →  {task:"align", duration, text, segments[], usage}
POST /v1/text/segmentations    →  {task:"segment", text, segments[]}
GET  /v1/models                →  {object:"list", data[]}

POST /v1/audio/transcriptions

Multipart 上传。response_format 支持 json、verbose_json、text 与 diarized_json;verbose_json 和 diarized_json 可通过 timestamp_granularities[] 请求词级或片段级时间戳。流式输出使用 JSON 模式 SSE,不适用于 text 或 diarized_json,且仅桌面网关支持——Headless 服务对 stream=true 返回 400。

curl http://127.0.0.1:1117/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-edgespeak-..." \
  -F file=@meeting.m4a \
  -F model="lattice-2-flash" \
  -F response_format=verbose_json \
  -F "timestamp_granularities[]=word"

{
  "task": "transcribe",
  "duration": 19.69,
  "language": "English",
  "text": "EdgeSpeak AI is a high-performance engine ...",
  "segments": [
    {
      "id": 0,
      "start": 0.0,
      "end": 6.44,
      "text": "EdgeSpeak AI is a high-performance engine designed for ...",
      "words": [
        { "word": "EdgeSpeak", "start": 0.22, "end": 0.64, "score": 0.991 }
      ]
    }
  ],
  "usage": { "type": "duration", "seconds": 19.69 }
}

POST /v1/audio/alignments

强制对齐:给定文稿,引擎只找时间。参考文本放 text 字段,或 text_path——本机绝对路径,由网关直接读取。响应恒无 language 键;score 是 [0, 1] 置信度。

curl http://127.0.0.1:1117/v1/audio/alignments \
  -H "Authorization: Bearer sk-edgespeak-..." \
  -F file=@meeting.m4a \
  -F text="LattifAI is a high performance engine ..."

{
  "task": "align",
  "duration": 19.6909375,
  "text": "LattifAI is a high performance engine ...",
  "segments": [
    {
      "id": 0,
      "start": 0.22,
      "end": 19.52,
      "text": "LattifAI is a high performance engine ...",
      "words": [
        { "word": "LattifAI", "start": 0.22, "end": 1.04, "score": 0.8463 }
      ]
    }
  ],
  "usage": { "type": "duration", "seconds": 19.6909375 }
}

POST /v1/text/segmentations

语义分句,JSON 请求体:纯文本用 text,带时间戳用 segments[]。纯文本输入的句子不含 start 和 end;speaker、start、end 只在输入携带时出现。可选 threshold (默认 0.35)、min_chars、max_chars。

curl http://127.0.0.1:1117/v1/text/segmentations \
  -H "Authorization: Bearer sk-edgespeak-..." \
  -H "Content-Type: application/json" \
  -d '{"text": "LattifAI is a high-performance engine designed for the structuring of audio and video content assets. It runs entirely on local compute, ensuring your data security."}'

{
  "task": "segment",
  "text": "LattifAI is a high-performance engine ... It runs entirely on local compute ...",
  "segments": [
    { "text": "LattifAI is a high-performance engine designed for the structuring of audio and video content assets." },
    { "text": "It runs entirely on local compute, ensuring your data security." }
  ]
}

GET /v1/models

列出可用模型。每条模型记录直接提供 supported_endpoints、features、execution_location 与 default_for;模型 ID 是运行时返回的规范值,调用方应读取响应,不要自行拼接或硬编码。

curl http://127.0.0.1:1117/v1/models \
  -H "Authorization: Bearer sk-edgespeak-..."

{
  "object": "list",
  "data": [
    {
      "id": "EdgeSpeak/Lattice-2-Flash",
      "object": "model",
      "created": 0,
      "owned_by": "EdgeSpeak",
      "supported_endpoints": ["/v1/audio/transcriptions"],
      "features": [],
      "execution_location": "local",
      "default_for": ["/v1/audio/transcriptions"]
    },
    {
      "id": "Qwen/Qwen3.5-4B",
      "object": "model",
      "created": 0,
      "owned_by": "EdgeSpeak",
      "supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/messages", "/v1/tokenize"],
      "features": ["reasoning", "vision", "tool_calling"],
      "execution_location": "local",
      "default_for": []
    }
  ]
}

字段语义

语音文稿中的时间值单位为秒。segments[] 常见元素为 {id, start, end, text, words?};词条目为 {word, start, end, score?},score 是 [0, 1] 置信度。词级时间戳位于 segments[].words。转录和对齐通常以 {"type": "duration", "seconds": …} 表示 usage;其他 API 使用各自契约。可选键可能省略,JSON 键序不保证,请按键名取值。