Prompt
How do I use an API to turn articles into spoken audio?
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
You typically do this in two API steps:
- Get the article text
- Send the text to a text-to-speech (TTS) API to generate audio
Common workflow
1) Extract the article content
If the article is on a web page, you first need the readable text, not the whole HTML. You can:
- scrape the page and extract main text
- use an article extraction library/service
- get the article from your CMS or database if you already store it
2) Send text to a TTS API
Use a speech API such as:
- OpenAI TTS
- Amazon Polly
- Google Cloud Text-to-Speech
- Azure Speech
- ElevenLabs
These APIs usually let you choose:
- voice
- language
- format like MP3, WAV, OGG
- sometimes speed, pitch, or style
3) Save or stream the audio
The API returns audio data or a downloadable file. You can:
- save it as
article.mp3 - play it in your app
- stream it to the user
Example: basic Python flow
import requests
article_text = """
This is the article text you want spoken aloud.
"""
# Example: send to a TTS API
response = requests.post(
"https://api.example.com/tts",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"text": article_text,
"voice": "neutral",
"format": "mp3"
}
)
with open("article.mp3", "wb") as f:
f.write(response.content)
If the article is long
Most TTS APIs have a text length limit per request. For long articles:
- split the article into chunks by paragraph or section
- convert each chunk separately
- concatenate the audio files afterward
Things to watch out for
- Copyright/licensing: make sure you have rights to convert the article to audio
- Text cleanup: remove nav text, ads, captions, and boilerplate
- Pronunciation: format dates, abbreviations, and acronyms for better speech
- Chunking: keep chunks natural, like paragraphs
- Cost: TTS is usually billed by characters or minutes
Best practice architecture
- User submits article URL or pastes text
- Backend extracts and cleans article text
- Backend sends chunks to TTS API
- Backend merges audio files
- User downloads or listens in-app
If you want, I can give you:
- a working example in Python, JavaScript, or Node.js
- a version using OpenAI / Amazon Polly / ElevenLabs
- a full app flow for URL → spoken MP3