saveTextToPodcast
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v13View latest version
This HTTP Val converts text files to speech using OpenAI's TTS API and stores the results for podcast generation.
- Set the
OPENAI_API_KEYenvironment variable in your Val Town settings - The SQLite database table will be created automatically on first use
- Visit
/testfor a web interface to upload and convert text files - Or use the API endpoints directly (see below)
Web interface for testing file uploads and conversions.
Converts a text file to speech and stores it.
Parameters:
file(File): Text file to convertname(string): Name/title for the episode
Example using curl:
curl -X POST https://your-val-url.web.val.run/convert \ -F "file=@your-text-file.txt" \ -F "name=My First Episode"
Response:
{ "success": true, "message": "Text converted to speech successfully", "data": { "name": "My First Episode", "mp3_url": "https://your-val-url.web.val.run/audio/tts_1234567890.mp3", "text_length": 1250 } }
Serves MP3 audio files from storage.
Lists all converted episodes.
Response:
{ "success": true, "episodes": [ { "id": 1, "name": "My First Episode", "text": "This is the text content...", "mp3_url": "https://your-val-url.web.val.run/audio/tts_1234567890.mp3", "date_added": "2024-01-01 12:00:00" } ] }
Generates an RSS podcast feed from all episodes.
The tts_episodes table contains:
id(INTEGER PRIMARY KEY)name(TEXT) - Episode titletext(TEXT) - Original text contentmp3_url(TEXT) - URL to the MP3 filedate_added(DATETIME) - Timestamp when added
- ✅ Text file upload and conversion to MP3
- ✅ SQLite database storage
- ✅ MP3 file serving from blob storage
- ✅ RSS podcast feed generation
- ✅ Error handling and validation
- ✅ Automatic database initialization
- Uses OpenAI's
tts-1model with thealloyvoice - MP3 files are stored in Val Town's blob storage
- Database records include full text content for search/reference
- Podcast feed is automatically generated from database records
- All endpoints include proper error handling