https://github.com/perbu/tts-cli
Text-to-Speech using the OpenAI API
https://github.com/perbu/tts-cli
Last synced: 3 months ago
JSON representation
Text-to-Speech using the OpenAI API
- Host: GitHub
- URL: https://github.com/perbu/tts-cli
- Owner: perbu
- License: bsd-3-clause
- Created: 2024-06-22T09:14:36.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-29T06:28:54.000Z (about 2 years ago)
- Last Synced: 2025-12-29T05:52:42.810Z (7 months ago)
- Language: Go
- Size: 22.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tts-cli
This is a simple CLI wrapper around the OpenAI Text-to-Speech API. There where already a few of these, but they were
written in Python. Dependency management in Python is a nightmare, so I decided to write my own in Go.
I use this, in addition to `make` and `dropcaster` to generate a podcast out of a bunch of text-files so I can "read"
them while biking or walking.
## Installation
```bash
go install github.com/perbu/tts-cli@latest
```
## Usage
```bash
tts-cli [-debug]
```
This will read the input file, send it to the OpenAI API, and write the resulting audio to an mp3 file with the same
name as the input file, but with ".mp3" appended.
## Makefile for mp3 generation
```makefile
# Find all .txt files in the source directory
TXT_FILES := $(wildcard source/*.txt)
# Generate the list of target .aac files in the current directory
AUDIO_FILES := $(notdir $(TXT_FILES:.txt=.mp3))
# Default target
all: $(AUDIO_FILES)
# Rule to create .aac file from .txt file
%.mp3: source/%.txt
tts-cli -o $@ $<
# Clean target to remove all generated audio files
clean:
rm -f *.aac
.PHONY: all clean
```