Add runtime.stt.transcribeAudioFile for plugin STT access

Expose audio transcription through the PluginRuntime so external
plugins (e.g. marmot) can use openclaw's media-understanding provider
framework without importing unexported internal modules.

The new transcribeAudioFile() wraps runCapability({capability: "audio"})
and reads provider/model/apiKey from tools.media.audio in the config,
matching the pattern used by the Discord VC implementation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
benthecarman
2026-02-20 21:52:08 -06:00
committed by Peter Steinberger
parent f7b0378ccb
commit faa4ffec03
4 changed files with 61 additions and 0 deletions

View File

@@ -95,6 +95,7 @@ import { buildTemplateMessageFromPayload } from "../../line/template-messages.js
import { getChildLogger } from "../../logging.js";
import { normalizeLogLevel } from "../../logging/levels.js";
import { convertMarkdownTables } from "../../markdown/tables.js";
import { transcribeAudioFile } from "../../media-understanding/transcribe-audio.js";
import { isVoiceCompatibleAudio } from "../../media/audio.js";
import { mediaKindFromMime } from "../../media/constants.js";
import { fetchRemoteMedia } from "../../media/fetch.js";
@@ -244,6 +245,7 @@ export function createPluginRuntime(): PluginRuntime {
system: createRuntimeSystem(),
media: createRuntimeMedia(),
tts: { textToSpeechTelephony },
stt: { transcribeAudioFile },
tools: createRuntimeTools(),
channel: createRuntimeChannel(),
logging: createRuntimeLogging(),

View File

@@ -25,6 +25,8 @@ type UpsertChannelPairingRequestForAccount = (
type FetchRemoteMedia = typeof import("../../media/fetch.js").fetchRemoteMedia;
type SaveMediaBuffer = typeof import("../../media/store.js").saveMediaBuffer;
type TextToSpeechTelephony = typeof import("../../tts/tts.js").textToSpeechTelephony;
type TranscribeAudioFile =
typeof import("../../media-understanding/transcribe-audio.js").transcribeAudioFile;
type BuildMentionRegexes = typeof import("../../auto-reply/reply/mentions.js").buildMentionRegexes;
type MatchesMentionPatterns =
typeof import("../../auto-reply/reply/mentions.js").matchesMentionPatterns;
@@ -207,6 +209,9 @@ export type PluginRuntime = {
tts: {
textToSpeechTelephony: TextToSpeechTelephony;
};
stt: {
transcribeAudioFile: TranscribeAudioFile;
};
tools: {
createMemoryGetTool: CreateMemoryGetTool;
createMemorySearchTool: CreateMemorySearchTool;