This commit is contained in:
2026-09-02 01:00:09 +03:00
parent 166744fe88
commit eaa46e7494
17 changed files with 1351 additions and 0 deletions
+125
View File
@@ -219,6 +219,94 @@ func Spec() map[string]any {
}),
},
},
"/api/v1/mic": map[string]any{
"get": map[string]any{
"summary": "List microphones",
"operationId": "listMics",
"responses": auth(map[string]any{
"200": okJSON("Capture devices", ref("MicList")),
"503": errResp("Microphone enumeration failed"),
}),
},
"delete": map[string]any{
"summary": "Stop microphone capture",
"operationId": "stopMic",
"responses": auth(map[string]any{
"204": map[string]any{"description": "Capture stopped"},
}),
},
},
"/api/v1/mic/chunk": map[string]any{
"get": map[string]any{
"summary": "Poll ~200ms of microphone audio",
"operationId": "micChunk",
"parameters": []map[string]any{
{"name": "device", "in": "query", "schema": map[string]any{"type": "integer", "minimum": 0, "default": 0}},
},
"responses": auth(map[string]any{
"200": map[string]any{
"description": "WAV audio chunk",
"content": map[string]any{
"audio/wav": map[string]any{"schema": map[string]string{"type": "string", "format": "binary"}},
},
},
"204": map[string]any{"description": "No audio buffered yet"},
"400": errResp("Invalid device"),
"503": errResp("Microphone capture failed"),
}),
},
},
"/api/v1/mic/record": map[string]any{
"post": map[string]any{
"summary": "Start recording microphone to AppData",
"operationId": "startMicRecord",
"parameters": []map[string]any{
{"name": "device", "in": "query", "schema": map[string]any{"type": "integer", "minimum": 0, "default": 0}},
},
"responses": auth(map[string]any{
"200": okJSON("Recording started", ref("MicRecordState")),
"409": errResp("Already recording"),
"400": errResp("Invalid device"),
"503": errResp("Could not start recording"),
}),
},
"delete": map[string]any{
"summary": "Stop recording",
"operationId": "stopMicRecord",
"responses": auth(map[string]any{
"200": okJSON("Recording stopped", ref("MicRecordState")),
"400": errResp("Not recording"),
}),
},
},
"/api/v1/mic/recordings": map[string]any{
"get": map[string]any{
"summary": "List saved microphone recordings",
"operationId": "listMicRecordings",
"responses": auth(map[string]any{
"200": okJSON("Recording files", ref("MicRecordingList")),
}),
},
},
"/api/v1/mic/download": map[string]any{
"get": map[string]any{
"summary": "Download a saved recording",
"operationId": "downloadMicRecording",
"parameters": []map[string]any{
{"name": "file", "in": "query", "required": true, "schema": map[string]string{"type": "string"}},
},
"responses": auth(map[string]any{
"200": map[string]any{
"description": "WAV file",
"content": map[string]any{
"audio/wav": map[string]any{"schema": map[string]string{"type": "string", "format": "binary"}},
},
},
"400": errResp("Invalid file name"),
"404": errResp("Recording not found"),
}),
},
},
"/api/v1/exec": map[string]any{
"post": map[string]any{
"summary": "Run a shell command",
@@ -559,6 +647,43 @@ func Spec() map[string]any {
"devices": map[string]any{"type": "array", "items": ref("WebcamDevice")},
},
},
"MicDevice": map[string]any{
"type": "object",
"properties": map[string]any{
"index": map[string]any{"type": "integer"},
"name": map[string]string{"type": "string"},
},
},
"MicList": map[string]any{
"type": "object",
"properties": map[string]any{
"devices": map[string]any{"type": "array", "items": ref("MicDevice")},
},
},
"MicRecordState": map[string]any{
"type": "object",
"properties": map[string]any{
"file": map[string]string{"type": "string"},
"size": map[string]any{"type": "integer", "format": "int64"},
"recording": map[string]any{"type": "boolean"},
},
},
"MicRecordingList": map[string]any{
"type": "object",
"properties": map[string]any{
"directory": map[string]string{"type": "string"},
"recording": map[string]any{"type": "boolean"},
"files": map[string]any{"type": "array", "items": ref("MicFile")},
},
},
"MicFile": map[string]any{
"type": "object",
"properties": map[string]any{
"name": map[string]string{"type": "string"},
"size": map[string]any{"type": "integer", "format": "int64"},
"modified_time": map[string]string{"type": "string", "format": "date-time"},
},
},
},
},
}