perf: skip ffmpeg transcode for PocketTTS streaming — use WAV directly
All checks were successful
Release / Test backend (push) Successful in 42s
Release / Check ui (push) Successful in 46s
Release / Docker / caddy (push) Successful in 41s
Release / Docker / backend (push) Successful in 2m46s
Release / Docker / runner (push) Successful in 3m12s
Release / Docker / ui (push) Successful in 2m19s
Release / Gitea Release (push) Successful in 36s
All checks were successful
Release / Test backend (push) Successful in 42s
Release / Check ui (push) Successful in 46s
Release / Docker / caddy (push) Successful in 41s
Release / Docker / backend (push) Successful in 2m46s
Release / Docker / runner (push) Successful in 3m12s
Release / Docker / ui (push) Successful in 2m19s
Release / Gitea Release (push) Successful in 36s
PocketTTS emits 16-bit PCM WAV (16 kHz mono). WAV is natively supported on all browsers including iOS/macOS Safari, so the ffmpeg MP3 transcode is unnecessary for the streaming path. Using format=wav for PocketTTS voices eliminates the ffmpeg subprocess startup delay (~200–400 ms) and a pipeline stage, giving lower latency to first audio frame. Kokoro and CF AI continue using MP3 (they output MP3 natively or via the OpenAI-compatible endpoint). The runner (MinIO storage) is unaffected — it still stores MP3 for space efficiency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
ui/src/routes/api/admin/audio/bulk/+server.ts
Normal file
34
ui/src/routes/api/admin/audio/bulk/+server.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* POST /api/admin/audio/bulk
|
||||
*
|
||||
* Admin-only proxy to the Go backend's audio bulk-enqueue endpoint.
|
||||
* Body: { slug, voice?, from, to, skip_existing?, force? }
|
||||
* Response 202: { enqueued, skipped, task_ids }
|
||||
*/
|
||||
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { log } from '$lib/server/logger';
|
||||
import { backendFetch } from '$lib/server/scraper';
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
if (!locals.user || locals.user.role !== 'admin') {
|
||||
throw error(403, 'Forbidden');
|
||||
}
|
||||
|
||||
const body = await request.text();
|
||||
let res: Response;
|
||||
try {
|
||||
res = await backendFetch('/api/admin/audio/bulk', {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body
|
||||
});
|
||||
} catch (e) {
|
||||
log.error('admin/audio/bulk', 'backend proxy error', { err: String(e) });
|
||||
throw error(502, 'Could not reach backend');
|
||||
}
|
||||
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return json(data, { status: res.status });
|
||||
};
|
||||
34
ui/src/routes/api/admin/audio/cancel-bulk/+server.ts
Normal file
34
ui/src/routes/api/admin/audio/cancel-bulk/+server.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* POST /api/admin/audio/cancel-bulk
|
||||
*
|
||||
* Admin-only proxy to cancel all pending/running audio tasks for a slug.
|
||||
* Body: { slug }
|
||||
* Response 200: { cancelled }
|
||||
*/
|
||||
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { log } from '$lib/server/logger';
|
||||
import { backendFetch } from '$lib/server/scraper';
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
if (!locals.user || locals.user.role !== 'admin') {
|
||||
throw error(403, 'Forbidden');
|
||||
}
|
||||
|
||||
const body = await request.text();
|
||||
let res: Response;
|
||||
try {
|
||||
res = await backendFetch('/api/admin/audio/cancel-bulk', {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body
|
||||
});
|
||||
} catch (e) {
|
||||
log.error('admin/audio/cancel-bulk', 'backend proxy error', { err: String(e) });
|
||||
throw error(502, 'Could not reach backend');
|
||||
}
|
||||
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return json(data, { status: res.status });
|
||||
};
|
||||
Reference in New Issue
Block a user