Skip to content

theskyinflames/text2voice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

text2voice

A web app that converts .txt files to speech. Upload a text file, get an MP3 back.

screenshot

Architecture

Browser  ──POST /convert (multipart)──►  Go HTTP server  ──►  OpenAI TTS API
         ◄──── MP3 download ───────────                   ◄──── audio/mpeg
  • main.go — single-file Go HTTP server. Two routes:
    • GET / — serves static/index.html
    • POST /convert — accepts a .txt file (max 15 KB), splits the text into chunks of up to 4096 characters, calls the OpenAI TTS endpoint once per chunk, and returns the concatenated MP3 as a file download.
  • static/index.html — self-contained frontend (no build step). Handles drag-and-drop or click-to-upload, animates a fake progress bar while the API call runs, then presents a download link.

The server uses only the Go standard library (net/http, encoding/json, bytes). No external Go dependencies.

Tools & services

Component Detail
Language Go 1.26
TTS engine OpenAI TTS — model tts-1, voice alloy
Output format MP3 (audio/mpeg)
Input limit 15 KB file size cap; text is split into 4096-character chunks and each is sent to the TTS API separately

Requirements

Running

# Set your OpenAI API key
export OPENAI_API_KEY=sk-...

# Build and run
go build -o text2voice .
./text2voice

Or without building:

OPENAI_API_KEY=sk-... go run .

The server listens on http://localhost:8080.

About

This a web page that allows you upload a txt file, and it generates an mp3 file with the speech. Internally, it uses the OpenAI TTS API

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors