Generate a free MP3 narration from supplied {script} text using a selected SpeakScribe voice, then return the generated audio/download URL.
Use Cases
Use for text-to-speech narration tasks on speakscribe.me when the requested voice is available as a voice-page slug, for example portuguese/pt-br-antonioneural.
Automation Flow
- If SpeakScribe presents Cloudflare protection, solve it with the browser agent's Cloudflare solver before relying on page controls.
- Navigate directly to
https://speakscribe.me/voices/{language}/{voice-slug}. - On the loaded voice page, use one page evaluation to set the
textareavalue through the Alpine component and call its generation method directly. This avoids an extra click round-trip:
async () => {
const textarea = document.querySelector('textarea');
if (!textarea) throw new Error('SpeakScribe textarea not found');
const data = window.Alpine?.$data(textarea);
if (!data || typeof data.generate !== 'function') throw new Error('SpeakScribe generator unavailable');
data.text = {script};
textarea.value = {script};
textarea.dispatchEvent(new Event('input', {bubbles: true}));
textarea.dispatchEvent(new Event('change', {bubbles: true}));
await data.generate();
for (let i = 0; i < 120; i++) {
if (data.audioUrl || document.querySelector('audio[src], audio source[src]')) break;
if (data.error) throw new Error(String(data.error));
await new Promise(resolve => setTimeout(resolve, 500));
}
const abs = value => { try { return new URL(value, location.href).href; } catch (_) { return null; } };
const audioUrls = [...document.querySelectorAll('audio[src], audio source[src]')]
.map(el => abs(el.getAttribute('src'))).filter(Boolean);
if (data.audioUrl) audioUrls.push(abs(data.audioUrl));
const downloadUrls = [...document.querySelectorAll('a[href]')]
.filter(a => a.hasAttribute('download') || /\b(mp3|audio|download)\b/i.test(`${a.textContent} ${a.getAttribute('href')}`))
.map(a => abs(a.getAttribute('href'))).filter(Boolean);
return {
audioUrls: [...new Set(audioUrls)],
downloadUrls: [...new Set(downloadUrls)]
};
}Replace {script} with a safely encoded JavaScript string literal before evaluation. The page's Alpine generate() method handles the guest session and generation request; do not invent or call an undocumented API endpoint. If direct Alpine access is unavailable, populate the textarea with bubbling input and change events, click the visible enabled voice-specific button whose text contains Generate with, wait up to 60 seconds, and run the same extraction logic.
Possible Friction Points
- Cloudflare protection may appear before the voice page; solve it before relying on page controls.
- Voice pages use the direct language-and-slug URL pattern
/voices/{language}/{voice-slug}; do not guess an opaque voice identifier when the caller has not supplied or selected the slug. - The script is entered in a
textarea; dispatching bubblinginputandchangeevents is important when setting its value programmatically. - The page exposes its generator through the Alpine component attached to the textarea: assign
data.textand calldata.generate()to avoid the extra generation-button round-trip. - Guest generation may initialize or use a browser
localStorageguest-session token. Preserve the current page storage and do not replace it with a fabricated token. - The generation control is voice-specific. If the Alpine shortcut is unavailable, find the visible, enabled
Generate with <voice>button instead of relying on a positional selector. - Audio controls and download links appear only after generation. Wait for
data.audioUrlor an audio source before evaluating; otherwise the URL arrays may be empty. - The
audioUrlproperty and DOM audio/download selectors are implementation details and should be treated as potentially fragile; retain the fallback extraction and button path.
Example Result
{
"audioUrls": [
"https://example.com/audio.mp3"
],
"downloadUrls": [
"https://example.com/download.mp3"
]
}