Skip to main content

Universal STT/TTS Shell Wrapper

Project description

🎙️ stts - Universal Voice Shell

Repo zostało podzielone na dwa niezależne projekty:

  • python/ - wersja Python
  • nodejs/ - wersja Node.js (ESM)

Każdy folder ma własne:

  • README.md
  • Makefile
  • Dockerfile
  • testy Docker (bez mikrofonu)

Szybki start

użycie STT i TTS w komendzie shell:

#tylko STT
./stts git commit -m "{STT}"
# razem z TTS 
./stts git commit -m "{STT}" | ./stts --tts-stdin
# z TTS espeak angielski
./stts git commit -m "{STT}" | ./stts --tts-stdin --tts-provider espeak --tts-voice en
# z konfiguracją TTS lepszej jakosci
./stts git commit -m "{STT}" | ./stts --tts-provider piper --tts-voice en_US-amy-medium --tts-stdin
# z konfiguracją TTS polski lepszej jakosci
./stts git commit -m "{STT}" | ./stts --tts-provider piper --tts-voice pl_PL-gosia-medium --tts-stdin

Uruchamianie komend shell nawet z błedami fonetycznymi za pomocą nlp2cmd:

./stts nlp2cmd -r "{STT}"  | ./stts --tts-stdin

output


Uwaga: ./stts wykonuje komendę z buforowaniem – output pojawi się naraz po zakończeniu. Jeśli potrzebujesz strumieniowanie (np. git), użyj --dry-run | bash lub git commit -m "$(./stts --stt-once)".

./stts git commit -m "{STT}" | ./stts --tts-stdin
[12:23:19] 🎤 Mów (max 5s, VAD)...  VAD stop (4.4s / 4.6s)
🔎 audio: 4.4s, rms=-44.5dBFS
[12:23:24] 🔄 Rozpoznawanie...  "Aktualizuj dokumentację." (5.7s)
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

[stts] TTS: provider=piper voice=pl_PL-gosia-medium

Konfiguracja

# Python
cd python
cp .env.example .env
./stts --setup
./stts

# Node.js
cd nodejs
cp .env.example .env
./stts.mjs --setup
./stts.mjs

Szybki setup (bez interakcji, Python):

./stts --init whisper_cpp:tiny

.env (ustawienia / linki / domyślne wartości)

W repo jest /.env.example (oraz osobne python/.env.example, nodejs/.env.example). Skrypty automatycznie wczytują .env.

Najważniejsze zmienne:

  • STTS_CONFIG_DIR - katalog na modele/cache (również dla Docker volume)
  • STTS_TIMEOUT - czas nagrywania STT (sekundy), domyślnie 5
  • STTS_NLP2CMD_ENABLED=1 - włącza NL → komenda przez nlp2cmd
  • STTS_NLP2CMD_ARGS=-r - tryb jak w przykładach: nlp2cmd -r "Pokaż użytkowników"
  • STTS_NLP2CMD_CONFIRM=1 - pytaj o potwierdzenie przed wykonaniem
  • STTS_PIPER_AUTO_INSTALL=1 - auto-instalacja piper binarki (Python)
  • STTS_PIPER_AUTO_DOWNLOAD=1 - auto-download modelu głosu piper (Python)
  • STTS_PIPER_RELEASE_TAG=2023.11.14-2 - wersja piper do pobrania
  • STTS_PIPER_VOICE_VERSION=v1.0.0 - wersja głosów piper do pobrania

NLP2CMD (Natural Language → komendy)

W wersji Python i Node możesz:

  • wpisać: nlp Pokaż użytkowników
  • albo użyć STT: ENTER → powiedz tekst → skrypt odpali nlp2cmd i zapyta o potwierdzenie

Instalacja nlp2cmd:

cd python && make pip-nlp2cmd

TTS: szybki setup + autodiagnostyka (Python)

Jeśli "TTS nie działa" (cisza), najczęstsze przyczyny:

  • brak binarki providera (espeak / piper)
  • dla piper: brak modelu *.onnx i *.onnx.json
  • brak odtwarzacza audio (paplay / aplay / play) dla piper

Test TTS (bez STT)

./stts --tts-test "Test syntezatora mowy"

Setup: espeak (Linux)

make tts-setup-espeak

Setup: piper (Linux, auto-download)

make tts-setup-piper

Piper: automatyczny install + auto-download w runtime

Wersja Python potrafi automatycznie:

  • pobrać binarkę piper do ~/.config/stts-python/bin/
  • pobrać model i config głosu do ~/.config/stts-python/models/piper/

Ręcznie (CLI):

./stts --install-piper
./stts --download-piper-voice pl_PL-gosia-medium
./stts --tts-provider piper --tts-voice pl_PL-gosia-medium
./stts --tts-test "Cześć, to działa."

Testy w Docker (bez dostępu do audio)

Testy działają przez symulację wypowiedzi usera:

  1. Generujemy próbki audio do plików samples/*.wav
  2. Do każdej próbki zapisujemy transkrypt w samples/*.wav.txt
  3. W testach ustawiamy STTS_MOCK_STT=1 i uruchamiamy --stt-file ...
# wszystkie platformy
make test-docker

# albo osobno
make docker-test-python
make docker-test-nodejs

Testy Docker montują cache/config jako volume (żeby nie pobierać modeli za każdym razem). Domyślne katalogi cache:

  • CACHE_DIR_PYTHON=~/.config/stts-python
  • CACHE_DIR_NODEJS=~/.config/stts-nodejs

Możesz je nadpisać:

make test-docker CACHE_DIR_PYTHON=/tmp/stts-python-cache CACHE_DIR_NODEJS=/tmp/stts-nodejs-cache

Alternatywnie (wrapper shell):

bash scripts/test_docker_all.sh --cache-python /tmp/stts-python-cache --cache-nodejs /tmp/stts-nodejs-cache

✨ Funkcje

  • Auto-detekcja sprzętu - sprawdza RAM, GPU, CPU i rekomenduje odpowiedni model
  • Wybór STT - whisper.cpp, faster-whisper, vosk, Google Speech
  • Wybór TTS - espeak, piper (neural), system TTS
  • Auto-pobieranie - modele pobierane automatycznie
  • Cross-platform - Linux, macOS, Windows, Raspberry Pi
  • Zero konfiguracji - interaktywny setup przy pierwszym uruchomieniu

🚀 Instalacja

# 1. Pobierz
git clone https://github.com/wronai/stts
cd stts

# 2. Uruchom (wybierz wersję)
./stts           # Python 3.8+
./stts.mjs       # Node.js 18+

# 3. Opcjonalnie: zainstaluj globalnie
sudo ln -s $(pwd)/stts /usr/local/bin/stts
sudo ln -s $(pwd)/stts.mjs /usr/local/bin/stts-node

🔄 Python vs Node.js

Cecha Python (python/stts) Node.js (nodejs/stts.mjs)
Wymagania Python 3.8+ Node.js 18+
Windows ✅ Pełne ⚠️ Częściowe
Linux/macOS
Zależności 0 (stdlib) 0 (stdlib)

Zależności systemowe

# Linux (Ubuntu/Debian)
sudo apt install espeak alsa-utils sox

# macOS
brew install espeak sox

# Windows
# Python + espeak (lub użyj system TTS)

📊 Wymagania sprzętowe

STT (Speech-to-Text)

Provider Min RAM GPU Offline Jakość Szybkość
whisper.cpp 1 GB ⭐⭐⭐⭐ ⭐⭐⭐
faster-whisper 2 GB ✅ (opt) ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐
vosk 0.5 GB ⭐⭐⭐ ⭐⭐⭐⭐⭐
google 0.5 GB ⭐⭐⭐⭐ ⭐⭐⭐

Modele Whisper

Model RAM VRAM Rozmiar Jakość
tiny 1 GB - 75 MB ⭐⭐
base 1 GB - 150 MB ⭐⭐⭐
small 2 GB - 500 MB ⭐⭐⭐⭐
medium 4 GB 2 GB 1.5 GB ⭐⭐⭐⭐⭐
large 8 GB 4 GB 3 GB ⭐⭐⭐⭐⭐

TTS (Text-to-Speech)

Provider Min RAM Jakość Offline
espeak 0.1 GB ⭐⭐
piper 0.5 GB ⭐⭐⭐⭐⭐
system - ⭐⭐⭐

💻 Użycie

Voice Shell (interaktywny)

./stts

🔊 stts> make build       # wpisz komendę
🔊 stts>                  # ENTER = nagrywanie głosu
🔊 stts> exit             # wyjście

Command Wrapper

# Uruchom komendę z głosowym output
./stts make build
./stts python script.py
./stts kubectl get pods
./stts git status

# Ostatnia linijka output zostanie przeczytana na głos

STT placeholder (Python)

W trybie wrapper możesz użyć {STT} jako placeholdera, który zostanie zastąpiony transkryptem z mikrofonu:

STTS_NLP2CMD_ENABLED=1 ./stts nlp2cmd -r "{STT}"

Pipeline (jednorazowe STT → stdout, Python)

Tryb --stt-once wypisuje sam transkrypt na stdout (a logi na stderr), więc nadaje się do pipe:

./stts --stt-once | xargs -I{} nlp2cmd -r "{}"

Strumieniowanie komend z git: Jeśli chcesz zobaczyć output git na bieżąco (bez bufora), użyj:

# Opcja 1: --dry-run + bash
./stts --dry-run git commit -m "{STT}" | bash

# Opcja 2: podstawienie argumentu (brak bufora)
git commit -m "$(./stts --stt-once)"

Pipeline (TTS na końcu, Python)

Jeśli chcesz, żeby dowolny pipeline kończył się TTS (np. przeczytanie ostatniej niepustej linii), użyj:

... | ./stts --tts-stdin

Uwaga: {TTS} nie jest wbudowaną komendą – jeśli chcesz mieć skrót, ustaw alias w swoim shellu (np. alias TTS='stts --tts-stdin').

Uwaga: aliasy (np. TTS) działają w Twoim shellu (bash/zsh), ale nie działają wewnątrz promptu stts>.

Przykład: zbuduj komendę i przeczytaj ją na głos (bez wykonania):

./stts --dry-run git commit -m "{STT}" | ./stts --tts-stdin

Jeśli koniecznie chcesz użyć aliasu, uruchom w normalnym shellu (nie w stts>), ewentualnie przez:

bash -lc './stts --dry-run git commit -m "{STT}" | TTS'

Makefile Integration

# Dodaj do Makefile
%_voice:
	./stts make $*

# Użycie:
# make build_voice
# make test_voice

⚙️ Konfiguracja

# Interaktywny setup
./stts --setup

# Jednolinijkowy setup (Python)
./stts --init whisper_cpp:tiny

# TTS w jednej linijce (Python)
./stts --tts-provider espeak --tts-voice pl

# Konfiguracja zapisywana w:
~/.config/stts-python/config.json

Przykładowa konfiguracja

{
  "stt_provider": "whisper_cpp",
  "stt_model": "small",
  "tts_provider": "piper",
  "tts_voice": "pl",
  "language": "pl",
  "timeout": 5,
  "auto_tts": true
}

🔧 Providery

STT: whisper.cpp (rekomendowany)

# Auto-instalacja przy setup
# Lub ręcznie:
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp && make

STT: faster-whisper (GPU)

pip install faster-whisper

STT: vosk (lekki, RPi)

pip install vosk

TTS: piper (neural, rekomendowany)

# Przykład (Python):
./stts --tts-provider piper --tts-voice pl_PL-gosia-medium

# albo podaj ścieżkę do modelu .onnx:
./stts --tts-provider piper --tts-voice ~/.config/stts-python/models/piper/pl_PL-gosia-medium.onnx

# Modele trzymane są w:
~/.config/stts-python/models/piper/

Wymagania:

  • piper w PATH (binarka)
  • model *.onnx w ~/.config/stts-python/models/piper/
  • odtwarzacz audio: paplay lub aplay lub play

Szybki check:

command -v piper
ls ~/.config/stts-python/models/piper/*.onnx
command -v paplay || command -v aplay || command -v play

Automatyzacja (Python):

# Auto-install piper + auto-download głosu
./stts --install-piper
./stts --download-piper-voice pl_PL-gosia-medium

# Lub przez Makefile
make tts-setup-piper

TTS: espeak (fallback)

sudo apt install espeak

🍓 Raspberry Pi

Dla RPi rekomendowane:

  • STT: vosk (small-pl) lub whisper.cpp (tiny)
  • TTS: espeak lub piper
# RPi setup
sudo apt install espeak alsa-utils
./stts --setup
# Wybierz: vosk + espeak

🐛 Troubleshooting

Brak mikrofonu

# Sprawdź
arecord -l

# Zainstaluj
sudo apt install alsa-utils

Brak dźwięku TTS

# Diagnostyka (Python)
./stts --tts-test "Test TTS"

# Jeśli brak espeak/piper/player:
make tts-setup-espeak   # lub make tts-setup-piper

Model nie pobiera się

# Ręczne pobranie whisper
wget https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin
mv ggml-small.bin ~/.config/stts/models/whisper.cpp/

📁 Struktura

stts/
├── python/
│   ├── stts
│   ├── README.md
│   ├── Makefile
│   ├── Dockerfile
│   ├── samples/
│   ├── scripts/
│   └── tests/
└── nodejs/
    ├── stts.mjs
    ├── README.md
    ├── Makefile
    ├── Dockerfile
    ├── samples/
    ├── scripts/
    └── tests/

~/.config/
├── stts-python/   # config + models dla Python
└── stts-nodejs/   # config + models dla Node.js

📚 Dokumentacja

  • Python: python/README.md – szczegóły TTS, piper, VAD, audio, CLI
  • Node.js: nodejs/README.md – szczegóły ESM, Docker, CLI
  • .env: .env.example (root) + python/.env.example + nodejs/.env.example
  • Makefile: python/Makefile – targety tts-setup-espeak, tts-setup-piper

📜 Licencja

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stts-0.1.14.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stts-0.1.14-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file stts-0.1.14.tar.gz.

File metadata

  • Download URL: stts-0.1.14.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for stts-0.1.14.tar.gz
Algorithm Hash digest
SHA256 8270b5d943ab32270f4b2d3476217d3ddff5512b277f3cd03e620bc260b301a8
MD5 d29b0921271d9c531bd6ff00c9f9b1eb
BLAKE2b-256 bb07fd0b7210ba41fd9c88728bc5f9b6a6ee8646992b45dbd090f68a25654c5c

See more details on using hashes here.

File details

Details for the file stts-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: stts-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for stts-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 f045e54f39780eeb6ffc4cb9dc20814e08ad8391210a9101fde97e52608bc5d2
MD5 f961365ec762b5297d59aeffd8adc246
BLAKE2b-256 d8ba390a6445d8080dd5a53916962871ceecbba3ae90cf344f640c88a5a9da94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page