Skip to content

Repository files navigation

Free TTS + STT (Next.js + Cloudflare)

A simple web app that lets you:

  • Text → Speech (TTS): turn text into audio using Google Labs (LLL) Text-to-Speech.
  • Speech → Text (STT): transcribe audio using Chutes Whisper.

This is a Next.js app that runs locally (Node.js) and can be deployed to Cloudflare Workers using OpenNext.

Requirements

  • Node.js 18+ (recommended)
  • pnpm (recommended) or npm

Setup

1) Install dependencies

pnpm install

2) Configure environment variables (STT)

Speech-to-text requires a Chutes API token.

Create a file called .env.local in the project root:

CHUTES_API_TOKEN=your_token_here

If you don’t set this, POST /api/stt will return: CHUTES_API_TOKEN not configured.

Run locally

pnpm dev

Open:

API routes

POST /api/tts

Server route that forwards to Google Labs TTS.

Request body:

{
  "text": "Hello world",
  "languageCode": "en-US",
  "voiceName": "..."
}

Response:

  • JSON containing the audio result (base64), as returned by Google Labs.

POST /api/stt

Server route that forwards to Chutes Whisper.

Request body:

{
  "audio_b64": "<base64 audio>"
}

Response:

  • plain text transcription

Docker (optional)

This repo includes a dev-focused Docker setup.

docker compose up --build

Open:

Note: you still need to provide CHUTES_API_TOKEN to the container (for example via an env file or compose environment settings).

Deploy to Cloudflare

This project uses OpenNext for Cloudflare.

Build + deploy:

pnpm deploy

Preview with Cloudflare tooling:

pnpm preview

Useful scripts

  • pnpm dev – run the app locally
  • pnpm build – build the app
  • pnpm deploy – build + deploy to Cloudflare
  • pnpm preview – build + preview on Cloudflare
  • pnpm cf-typegen – generate Cloudflare env types

About

A free text-to-speech and speech-to-text conversion

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages