feat(onebot): get_record out_format — server-side voice transcode (#165)
#165: get_record gains an optional `out_format` (mp3/amr/wma/m4a/spx/ogg/ wav/flac, mirroring NapCat). When set, the QQ voice (SILK/AMR) is transcoded server-side and the result is attached as `data.base64`; the original info (file/url/file_size) is preserved. Absent ⇒ behaviour unchanged. This spares ASR consumers from shipping a SILK decoder. - protocol: convertAudioBytes(bytes, format, deps?) drives the bundled SILK-capable ffmpeg addon's convertFile through temp files (always cleaned up), with a format allowlist and an output-size cap. Pure/ injectable, unit-tested with a fake addon (6 cases). - core: ExtrasApi.convertRecord(source, format) = loadBinarySource (64 MiB cap) → convertAudioBytes. - onebot: get_record wires out_format; transcode failure (incl. an addon lacking SILK decode) degrades to ACTION_FAILED, never crashes. Adversarially reviewed: no path traversal (format allowlisted), no SSRF (source is the cached CDN url, not user input), cleanup covers every path, graceful degradation confirmed. Catalog regenerated. Real-machine e2e (does the shipped .node actually decode SILK?) is Phase 2.
This commit is contained in:
6 files changed
+241
-5
No files matched your search
@@ -5238,7 +5238,7 @@ export const ACTIONS: CatalogAction[] = [
|
||||
{
|
||||
"name": "get_record",
|
||||
"aliases": [],
|
||||
"summary": "获取语音信息",
|
||||
"summary": "获取语音信息;传 out_format 则服务端转码并附带 base64",
|
||||
"readOnly": true,
|
||||
"params": [
|
||||
{
|
||||
@@ -5260,6 +5260,33 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"default": "",
|
||||
"role": "file_id"
|
||||
},
|
||||
{
|
||||
"name": "out_format",
|
||||
"type": "enum",
|
||||
"required": false,
|
||||
"values": [
|
||||
"mp3",
|
||||
"amr",
|
||||
"wma",
|
||||
"m4a",
|
||||
"spx",
|
||||
"ogg",
|
||||
"wav",
|
||||
"flac"
|
||||
],
|
||||
"schema": {
|
||||
"enum": [
|
||||
"mp3",
|
||||
"amr",
|
||||
"wma",
|
||||
"m4a",
|
||||
"spx",
|
||||
"ogg",
|
||||
"wav",
|
||||
"flac"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
@@ -5275,6 +5302,18 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"x-role": "file_id"
|
||||
},
|
||||
"out_format": {
|
||||
"enum": [
|
||||
"mp3",
|
||||
"amr",
|
||||
"wma",
|
||||
"m4a",
|
||||
"spx",
|
||||
"ogg",
|
||||
"wav",
|
||||
"flac"
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
||||
Reference in new issue
Block a user