Skip to content

Commit d7004da

Browse files
authored
feat(examples): simple oneshot STT/TTS gateway (#30)
* fix(whisper): flush buffered data * feat(examples): simple oneshot STT/TTS gateway * feat(examples): sample microphone oneshot transcription * chore: add missing licence
1 parent bcd262c commit d7004da

File tree

8 files changed

+674
-2
lines changed

8 files changed

+674
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- bidichk
6+
- errcheck
7+
- govet
8+
- ineffassign
9+
- makezero
10+
- misspell
11+
- revive
12+
- staticcheck
13+
- unconvert
14+
- unqueryvet
15+
- unused
16+
- whitespace
17+
settings:
18+
govet:
19+
disable:
20+
- fieldalignment
21+
enable-all: true
22+
unqueryvet:
23+
check-sql-builders: true
24+
issues:
25+
max-issues-per-linter: 0 # no maximum
26+
max-same-issues: 0 # no maximum

examples/speech-gateway/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!--
2+
SPDX-FileCopyrightText: © 2025 StreamKit Contributors
3+
4+
SPDX-License-Identifier: MPL-2.0
5+
-->
6+
7+
# Speech Gateway
8+
9+
Thin HTTP gateway that rewrites simple STT/TTS requests into the multipart oneshot format expected by a StreamKit backend.
10+
11+
## Prereqs
12+
13+
- StreamKit server running locally (default assumed: `http://127.0.0.1:4545`).
14+
- Go 1.24+.
15+
16+
## Run the gateway
17+
18+
```sh
19+
cd examples/streamkit-cli-gateway
20+
go run ./cmd/gateway --listen :8080 --skit-url http://127.0.0.1:4545
21+
```
22+
23+
Environment equivalents:
24+
25+
- `GATEWAY_LISTEN` (default `:8080`)
26+
- `SKIT_URL` (default `http://127.0.0.1:4545`)
27+
- `SKIT_TOKEN` (optional bearer sent to Skit)
28+
- `GATEWAY_MAX_CONCURRENCY` (default 10)
29+
- `GATEWAY_MAX_BODY_BYTES` (default 10MB)
30+
31+
## STT via curl (Ogg/Opus)
32+
33+
Transcribe a file:
34+
35+
```sh
36+
curl -H "Content-Type: audio/ogg" --data-binary @speech.ogg http://127.0.0.1:8080/stt
37+
```
38+
39+
Transcribe from microphone (requires ffmpeg):
40+
41+
```sh
42+
./stt.sh
43+
```
44+
45+
Press Ctrl-C when done speaking. The script captures audio, sends it to the gateway, and displays the transcription.
46+
47+
Response is NDJSON (one JSON object per line).
48+
49+
## TTS via curl (plain text)
50+
51+
```sh
52+
curl -H "Content-Type: text/plain" --data 'Hello from StreamKit' http://127.0.0.1:8080/tts | ffplay -nodisp -autoexit -
53+
```
54+
55+
Response is `audio/ogg` (Opus mono).

0 commit comments

Comments
 (0)