Skip to content

puter.ai.speech2txt says mp3 file might be corrupted or unsupported when posted as base64 #2655

@miikakuisma

Description

@miikakuisma

When I send mp3 to puter.ai.speech2txt as base64 it returns with

Error:
400 Audio file might be corrupted or unsupported

Full error:
{
  "success": false,
  "error": "400 Audio file might be corrupted or unsupported"
}

However if I send wav or m4a it gets transcribed.

You can reproduce the issue on this sample page:
https://silly-morning-1299.puter.site/

and here the code for that page:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>speech2txt test</title>
  <script src="https://js.puter.com/v2/"></script>
  <style>
    body { font-family: system-ui, sans-serif; max-width: 600px; margin: 40px auto; padding: 0 20px; }
    input, pre { margin-top: 12px; }
    pre { background: #f5f5f5; padding: 12px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; min-height: 40px; }
    .error { color: #dc2626; }
  </style>
</head>
<body>
  <h2>speech2txt test</h2>
  <input type="file" id="file" accept="audio/*">
  <pre id="out">Select an audio file to test...</pre>
  <script>
    const out = document.getElementById('out');
    document.getElementById('file').addEventListener('change', async (e) => {
      const file = e.target.files[0];
      if (!file) return;
      out.textContent = `Testing ${file.name} (${file.type}, ${(file.size/1024).toFixed(1)} KB)...\n`;
      try {
        const dataUrl = await new Promise((res, rej) => {
          const r = new FileReader();
          r.onload = () => res(r.result);
          r.onerror = () => rej(r.error);
          r.readAsDataURL(file);
        });
        const result = await puter.ai.speech2txt({ audio: dataUrl });
        const text = typeof result === 'string' ? result : (result.text || JSON.stringify(result, null, 2));
        out.textContent += `\nResult: ${text}\n\nRaw: ${JSON.stringify(result, null, 2)}`;
      } catch (err) {
        out.innerHTML = out.textContent + `\n<span class="error">Error: ${err?.message || JSON.stringify(err, null, 2)}</span>`;
      }
    });
  </script>
</body>
</html>

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions