Skip to content

tts

by rob

Convert text to speech (supports Google Cloud, Piper, OpenAI-compatible backends)

# tts - Text to Speech

Convert text to speech using Google Cloud Text-to-Speech API.

## Usage

```bash
echo "Hello world" | tts --file output.mp3
cat document.txt | tts --file narration.mp3
```

## Arguments

| Flag | Default | Description |
|------|---------|-------------|
| `--file` | output.mp3 | Output MP3 file path |
| `--voice` | en-US-Neural2-J | Voice name |
| `--lang` | en-US | Language code |
| `--speed` | 1.0 | Speaking rate (0.25 to 4.0) |
| `--pitch` | 0.0 | Pitch adjustment (-20.0 to 20.0) |
| `--ssml` | false | Treat input as SSML markup |

## Voices

Common voices:
- `en-US-Neural2-J` - US English male (default)
- `en-US-Neural2-F` - US English female
- `en-GB-Neural2-B` - British English male
- `es-ES-Neural2-A` - Spanish

Full list: `https://cloud.google.com/text-to-speech/docs/voices`

## Requirements

- Google Cloud account with Text-to-Speech API enabled
- `gcloud` CLI authenticated: `gcloud auth application-default login`

## Examples

```bash
# Basic usage
echo "Hello world" | tts --file hello.mp3

# Different voice and language
echo "Bonjour" | tts --voice fr-FR-Neural2-A --lang fr-FR --file french.mp3

# Faster speech
cat article.txt | tts --speed 1.3 --file fast.mp3

# SSML for natural pauses
echo '<speak>Hello.<break time="500ms"/>World.</speak>' | tts --ssml true --file natural.mp3

# Chain with other tools
cat article.txt | summarize | tts --file summary.mp3
```

## Cost

Free tier: 1 million characters/month (Neural2 voices)

No reviews yet.

Issues

No issues reported for this tool.