SillyTavern/SillyTavern · error

Internal Server Error

Error message

Internal Server Error

What it means

The HTTP 500 catch-all for the speech transcription route (POST using Transformers.js pipeline with task 'transcribe'). Any throw from getPipeline (model load), getWaveFile (audio decoding), or pipe(wav, ...) (inference) lands here. The error is console.error'd; only a bare 500 reaches the client, so the transcribe stage that failed must be identified from logs.

Source

Thrown at src/endpoints/speech.js:57

    return audioData;
}

router.post('/recognize', async (req, res) => {
    try {
        const TASK = 'automatic-speech-recognition';
        const { model, audio, lang } = req.body;
        const pipe = await getPipeline(TASK, model);
        const wav = getWaveFile(audio);
        const start = performance.now();
        const result = await pipe(wav, { language: lang || null, task: 'transcribe' });
        const end = performance.now();
        console.info(`Execution duration: ${(end - start) / 1000} seconds`);
        console.info('Transcribed audio:', result.text);

        return res.json({ text: result.text });
    } catch (error) {
        console.error(error);
        return res.sendStatus(500);
    }
});

router.post('/synthesize', async (req, res) => {
    try {
        const TASK = 'text-to-speech';
        const { text, model, speaker } = req.body;
        const pipe = await getPipeline(TASK, model);
        const speaker_embeddings = speaker
            ? new Float32Array(new Uint8Array(Buffer.from(speaker.startsWith('data:') ? speaker.split(',')[1] : speaker, 'base64')).buffer)
            : null;
        const start = performance.now();
        const result = await pipe(text, { speaker_embeddings: speaker_embeddings });
        const end = performance.now();
        console.debug(`Execution duration: ${(end - start) / 1000} seconds`);

        const wav = new wavefile.WaveFile();
        wav.fromScratch(1, result.sampling_rate, '32f', result.audio);

View on GitHub (pinned to 8172dcd0ee)

Solutions

  1. Read the server console - the logged error distinguishes model-load vs decode vs inference failures.
  2. Validate the audio payload is valid base64 of a WAV before sending, and that model is a supported automatic-speech-recognition model id.
  3. Pre-warm the pipeline by calling the endpoint once after install so the model downloads/caches succeed.
  4. Update transformers.js and onnxruntime-node to matching versions; clear the model cache if it is corrupt.

Example fix

// before
const wav = getWaveFile(audio);
const result = await pipe(wav, { language: lang || null, task: 'transcribe' });
// after - guard the decode step to get a precise error
let wav;
try { wav = getWaveFile(audio); }
catch (e) { return res.status(400).send({ error: 'Invalid audio payload' }); }
Defensive patterns

Strategy: validation

Validate before calling

function isValidAudioPayload(audio) {
  if (typeof audio !== 'string') return false;
  const b = audio.startsWith('data:') ? audio.split(',')[1] : audio;
  return /^[A-Za-z0-9+/]+={0,2}$/.test(b) && b.length % 4 === 0;
}

Type guard

/** @param {unknown} m */
const isSupportedSttModel = (m) => typeof m === 'string' && m.startsWith('Xenova/') || typeof m === 'string' && m.startsWith('onnx-community/') || typeof m === 'string' && m.startsWith('openai/whisper');

Try / catch

try { const { text } = await transcribe(audio, model, lang); }
catch (e) {
  if (/tensor|dtype|onnx/i.test(e.message)) handleModelVersion();
  else if (/decode|wav|base64/i.test(e.message)) handleBadAudio();
  else handleInference(e);
}

Prevention

When it happens

Trigger: Model name is missing or not downloadable; audio base64 is malformed so getWaveFile throws; the WebGPU/Transformers.js runtime hits an out-of-memory or unsupported-dtype error during inference; the language code is invalid; the model cache is corrupt.

Common situations: First request after adding a new STT model id that has not been cached; client sends audio/wav bytes that are not valid base64 or not a real WAV; Node/Transformers.js version mismatch causing ONNX runtime failure; low-memory host.

Understand the failure class

Related errors


AI-assisted analysis of SillyTavern/SillyTavern@8172dcd0ee (2026-08-13). Data as JSON: /api/errors/02861b45712a74e4. Report an issue: GitHub.