stt leaves the platform for the transcribe plugin
Speech-to-text is now plugins/transcribe — sidecar, its own config, its own skill and a task for the file browser's context menu. The transcription logic moved BYTE FOR BYTE: 416 lines whose every decision has a reason attached, from the two-pass detect-then-transcribe to the 25 language priming prompts to timeout:false. Verified identical rather than assumed. Removed here: api/stt/, server-settings/stt.ts and its mount, POST /chat/stt, POST /file-browser/transcribe, the FileViewer handler behind the button hidden last release, the Settings screen, the dead useAudioRecording hook and the orphaned locale keys across all six locales. blobToWav stayed. It lived in the same file as the dead hook and is still used by DictateDialog — unrelated to STT, and deleting by file rather than by use is how that would have gone. No permission entry to remove: STT never had one, living under server-admin, chat and files. The registry count is unchanged and docs:check is green. The plugin ships a task that will not appear in the menu yet — the platform loads a plugin's skills, affordances and notifications from its own directory but not its tasks. That loader is the remaining piece of docs/plugin-capabilities.md and is deliberately not built here. 1426 pass, tsgo clean, 18 plugins discovered with none broken. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Officer-Session: 656f5c85-e49a-4f1f-b9f3-042a04b4d043
This commit is contained in:
@@ -6,9 +6,7 @@ import { getOwnerHomeDir, DATA_PATH } from '@@/data-path';
|
||||
import { resolveHomeDir } from '@@/user-home';
|
||||
import * as errors from '@@/custom-errors';
|
||||
import { readTtsConfig } from '@@/api/server-settings/tts';
|
||||
import { readSttConfig } from '@@/api/server-settings/stt';
|
||||
import { readOcrConfig } from '@@/api/server-settings/ocr';
|
||||
import { transcribeAudio } from '@@/api/stt/transcribe';
|
||||
import { getUserSettings } from 'officerdb';
|
||||
|
||||
async function getUserTtsVoice(userId: number): Promise<string | null> {
|
||||
@@ -1104,46 +1102,6 @@ router.post('/extract', async (ctx) => {
|
||||
return ctx.json({ extractedPath });
|
||||
});
|
||||
|
||||
// Transcribe audio via Whisper with caching
|
||||
// Workflow: detect language → check user's spoken languages → translate if needed → transcribe
|
||||
router.post('/transcribe', async (ctx) => {
|
||||
const user = ctx.get('user');
|
||||
const { path: filePath, root, saveNextTo } = ctx.get('body') as { path: string; root?: string; saveNextTo?: boolean };
|
||||
if (!filePath) throw errors.BAD_REQUEST('path is required');
|
||||
|
||||
const rootDir = getRootDir(user, root);
|
||||
const absPath = resolveUserPath(rootDir, filePath);
|
||||
const s = await stat(absPath);
|
||||
if (s.isDirectory()) throw errors.BAD_REQUEST('Cannot transcribe a directory');
|
||||
|
||||
// No caching: a transcription is always produced fresh and overwrites any previous one.
|
||||
const { dir, name } = parsePath(filePath.replace(/^\/+/, ''));
|
||||
|
||||
const sttConfig = await readSttConfig();
|
||||
const whisperUrl = sttConfig?.url;
|
||||
if (!whisperUrl) throw errors.BAD_REQUEST('Whisper not configured — set it up in Settings → Speech to Text');
|
||||
|
||||
const settings = await getUserSettings(user.id);
|
||||
const spokenLanguages = (settings.languages as { spoken?: string[] })?.spoken ?? [];
|
||||
|
||||
let text: string;
|
||||
try {
|
||||
const result = await transcribeAudio({ file: Bun.file(absPath), whisperUrl, spokenLanguages });
|
||||
text = result.text;
|
||||
} catch (err) {
|
||||
throw errors.BAD_REQUEST(err instanceof Error ? err.message : 'Transcription failed');
|
||||
}
|
||||
|
||||
if (saveNextTo) {
|
||||
const siblingRel = dir ? `${dir}/${name}.md` : `${name}.md`;
|
||||
const siblingAbs = resolveUserPath(rootDir, siblingRel);
|
||||
await Bun.write(siblingAbs, text);
|
||||
return ctx.json({ transcriptionPath: `/${siblingRel}`, transcriptionRoot: root ?? 'home', cached: false });
|
||||
}
|
||||
|
||||
return ctx.json({ text, cached: false });
|
||||
});
|
||||
|
||||
// Search files by name
|
||||
router.get('/search', async (ctx) => {
|
||||
const user = ctx.get('user');
|
||||
|
||||
Reference in New Issue
Block a user