Skip to content

Commit 2757241

Browse files
authored
feat: Add health check test client (#66)
1 parent 1966009 commit 2757241

3 files changed

Lines changed: 492 additions & 0 deletions

File tree

test/stream-test-readme.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Health Check Client
2+
3+
A test client for verifying the transcription proxy is working. Streams an Ogg/Opus audio file and checks that transcriptions are returned.
4+
5+
## Usage
6+
7+
```bash
8+
node test/stream-test.js --url <base-url> --file <ogg-file> [options]
9+
```
10+
11+
## Options
12+
13+
| Option | Description |
14+
|--------|-------------|
15+
| `--url, -u` | Base WebSocket URL (required) |
16+
| `--file, -f` | Ogg/Opus audio file (required) |
17+
| `--tag, -t` | Participant tag (default: `health-check-<timestamp>`) |
18+
| `--cf-id` | Cloudflare Access Client ID |
19+
| `--cf-secret` | Cloudflare Access Client Secret |
20+
| `--loop` | Loop audio continuously |
21+
| `--timeout <sec>` | Wait time after streaming (default: 10) |
22+
| `--verbose, -v` | Enable progress logging |
23+
| `--interims` | Include interim transcriptions |
24+
25+
## Environment Variables
26+
27+
```bash
28+
CF_ACCESS_CLIENT_ID # Cloudflare Access Client ID
29+
CF_ACCESS_CLIENT_SECRET # Cloudflare Access Client Secret
30+
```
31+
32+
## Exit Codes
33+
34+
- `0` - Success (received at least one transcription)
35+
- `1` - Failure (no transcriptions, error, or timeout)
36+
37+
## Examples
38+
39+
### Health check (quiet, JSON output)
40+
41+
```bash
42+
node test/stream-test.js \
43+
--url wss://your-transcriber.example.com/transcribe \
44+
--file test/test.ogg
45+
```
46+
47+
### With Cloudflare Access
48+
49+
```bash
50+
node test/stream-test.js \
51+
--url wss://your-transcriber.example.com/transcribe \
52+
--file test/test.ogg \
53+
--cf-id "$CF_ACCESS_CLIENT_ID" \
54+
--cf-secret "$CF_ACCESS_CLIENT_SECRET"
55+
```
56+
57+
### Verbose output
58+
59+
```bash
60+
node test/stream-test.js \
61+
--url wss://your-transcriber.example.com/transcribe \
62+
--file test/test.ogg \
63+
--verbose
64+
```
65+
66+
### Local development
67+
68+
```bash
69+
node test/stream-test.js \
70+
--url ws://localhost:8080/transcribe \
71+
--file test/test.ogg \
72+
--verbose --loop
73+
```
74+
75+
## Output
76+
77+
JSON summary to stdout:
78+
79+
```json
80+
{
81+
"success": true,
82+
"transcriptions": [
83+
{
84+
"text": "hello world",
85+
"interim": false,
86+
"participant": "health-check-abc123",
87+
"timestamp": 1234567890,
88+
"language": "en"
89+
}
90+
],
91+
"metrics": {
92+
"durationMs": 15234,
93+
"connectLatencyMs": 145,
94+
"firstTranscriptionLatencyMs": 2341,
95+
"estimatedAudioDurationSec": 5.2,
96+
"chunksSent": 260,
97+
"bytesSent": 52000,
98+
"interimCount": 3,
99+
"finalCount": 1,
100+
"errors": []
101+
}
102+
}
103+
```
104+
105+
## Test Audio File
106+
107+
The `test.ogg` file is the "Speech, various bitrates" sample from the [Opus Codec examples page](https://opus-codec.org/examples/). It demonstrates Opus encoding at various bitrates from 8 kb/s to 64 kb/s.
108+
109+
**Source:** https://opus-codec.org/examples/
110+
**License:** The opus-codec.org website is licensed under [CC-BY 3.0](https://creativecommons.org/licenses/by/3.0/). The speech samples are provided for demonstration purposes; no explicit license is documented for the audio content itself.
111+
112+
## Creating Custom Test Audio
113+
114+
Convert any audio file to Ogg/Opus:
115+
116+
```bash
117+
ffmpeg -i input.mp3 -c:a libopus -b:a 24k -ar 48000 -ac 1 test/test.ogg
118+
```

0 commit comments

Comments
 (0)