wispr-flow-sdk-unofficial 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +375 -0
- package/dist/core/auth.d.ts +422 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/client.d.ts +99 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/constants.d.ts +53 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4730 -0
- package/dist/types/index.d.ts +862 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +43 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sahil Chouksey
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Unofficial Wispr Flow SDK
|
|
2
|
+
|
|
3
|
+
Unofficial TypeScript SDK for the Wispr Flow voice-to-text API.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
+-------------------+ +--------------------+ +------------------+
|
|
7
|
+
| Your Application |---->| Unofficial SDK |---->| Wispr Flow API |
|
|
8
|
+
+-------------------+ +--------------------+ +------------------+
|
|
9
|
+
|
|
|
10
|
+
v
|
|
11
|
+
+-------------+
|
|
12
|
+
| Supabase |
|
|
13
|
+
| Auth |
|
|
14
|
+
+-------------+
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Disclaimer
|
|
20
|
+
|
|
21
|
+
- **Unofficial**: This is an unofficial library. It is not affiliated with, endorsed by, or connected to Wispr Inc. or Wispr Flow.
|
|
22
|
+
- **No Warranty**: This is open source software distributed under the MIT License. No warranty or technical support is provided. Use at your own risk.
|
|
23
|
+
- **Reverse Engineered**: This library uses a reverse-engineered API that is not officially documented. The API may change at any time without notice.
|
|
24
|
+
- **Terms of Service**: Users are responsible for reviewing and complying with Wispr Flow's Terms of Service.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- Full authentication support via Supabase (email/password)
|
|
31
|
+
- Automatic token refresh for long-running applications
|
|
32
|
+
- Voice-to-text transcription with the Wispr Flow pipeline
|
|
33
|
+
- TypeScript with full type safety (Zod schemas)
|
|
34
|
+
- Multiple language support
|
|
35
|
+
- Context-aware transcription (app context, dictionary, OCR)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Using bun
|
|
43
|
+
bun add unofficial-wispr-flow-sdk
|
|
44
|
+
|
|
45
|
+
# Using npm
|
|
46
|
+
npm install unofficial-wispr-flow-sdk
|
|
47
|
+
|
|
48
|
+
# Using pnpm
|
|
49
|
+
pnpm add unofficial-wispr-flow-sdk
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Environment Setup
|
|
55
|
+
|
|
56
|
+
This SDK requires environment variables for API configuration. Create a `.env` file:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Required - User credentials
|
|
60
|
+
WISPR_EMAIL=your-email@example.com
|
|
61
|
+
WISPR_PASSWORD=your-password
|
|
62
|
+
|
|
63
|
+
# Required - API configuration (obtain these values separately)
|
|
64
|
+
SUPABASE_URL=
|
|
65
|
+
SUPABASE_ANON_KEY=
|
|
66
|
+
BASETEN_URL=
|
|
67
|
+
BASETEN_API_KEY=
|
|
68
|
+
|
|
69
|
+
# Optional
|
|
70
|
+
WISPR_API_URL=https://api.wisprflow.ai
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { WisprAuth, WisprClient } from 'unofficial-wispr-flow-sdk';
|
|
79
|
+
|
|
80
|
+
// 1. Authenticate
|
|
81
|
+
const auth = new WisprAuth();
|
|
82
|
+
const session = await auth.signIn({
|
|
83
|
+
email: process.env.WISPR_EMAIL,
|
|
84
|
+
password: process.env.WISPR_PASSWORD,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// 2. Create client with auto-refresh
|
|
88
|
+
const client = new WisprClient({ auth });
|
|
89
|
+
|
|
90
|
+
// 3. Warmup the service (reduces latency)
|
|
91
|
+
await client.warmup();
|
|
92
|
+
|
|
93
|
+
// 4. Transcribe audio (base64 encoded WAV, 16kHz mono)
|
|
94
|
+
const result = await client.transcribe({
|
|
95
|
+
audioData: base64AudioData,
|
|
96
|
+
languages: ['en'],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Use llm_text (formatted) or asr_text (raw)
|
|
100
|
+
console.log(result.llm_text || result.asr_text);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Authentication
|
|
106
|
+
|
|
107
|
+
The SDK supports authentication via Supabase. You can sign in with email/password:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { WisprAuth } from 'unofficial-wispr-flow-sdk';
|
|
111
|
+
|
|
112
|
+
const auth = new WisprAuth();
|
|
113
|
+
|
|
114
|
+
// Check if user exists
|
|
115
|
+
const status = await auth.checkUserStatus('user@example.com');
|
|
116
|
+
console.log(status); // { exists: true, provider: 'email', verified: true }
|
|
117
|
+
|
|
118
|
+
// Sign in
|
|
119
|
+
const session = await auth.signIn({
|
|
120
|
+
email: 'user@example.com',
|
|
121
|
+
password: 'password123',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
console.log(session.accessToken); // JWT token
|
|
125
|
+
console.log(session.userUuid); // User UUID
|
|
126
|
+
console.log(session.expiresAt); // Token expiry timestamp
|
|
127
|
+
|
|
128
|
+
// Refresh token manually (or use auto-refresh with WisprClient)
|
|
129
|
+
const newSession = await auth.refreshSession();
|
|
130
|
+
|
|
131
|
+
// Sign out
|
|
132
|
+
await auth.signOut();
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Client Options
|
|
138
|
+
|
|
139
|
+
### Manual Token Management
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const client = new WisprClient({
|
|
143
|
+
accessToken: 'your-jwt-token',
|
|
144
|
+
userUuid: 'your-user-uuid',
|
|
145
|
+
timeout: 30000, // Request timeout in ms (default: 30000)
|
|
146
|
+
debug: true, // Enable debug logging
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Automatic Token Refresh
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const auth = new WisprAuth();
|
|
154
|
+
await auth.signIn({ email, password });
|
|
155
|
+
|
|
156
|
+
const client = new WisprClient({
|
|
157
|
+
auth, // Pass auth instance for auto-refresh
|
|
158
|
+
tokenRefreshBuffer: 300, // Refresh 5 minutes before expiry (default: 60)
|
|
159
|
+
debug: true,
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Transcription
|
|
166
|
+
|
|
167
|
+
### Basic Transcription
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const result = await client.transcribe({
|
|
171
|
+
audioData: base64AudioData, // Base64 encoded WAV (16kHz, mono, PCM)
|
|
172
|
+
languages: ['en'], // ISO 639-1 language codes
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
console.log(result.llm_text); // Formatted text (use this)
|
|
176
|
+
console.log(result.asr_text); // Raw ASR output (fallback)
|
|
177
|
+
console.log(result.detected_language); // Detected language
|
|
178
|
+
console.log(result.total_time); // Processing time in seconds
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### With Context
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const result = await client.transcribe({
|
|
185
|
+
audioData: base64AudioData,
|
|
186
|
+
languages: ['en'],
|
|
187
|
+
context: {
|
|
188
|
+
app: {
|
|
189
|
+
name: 'My App',
|
|
190
|
+
bundle_id: 'com.example.myapp',
|
|
191
|
+
type: 'other',
|
|
192
|
+
},
|
|
193
|
+
dictionary_context: ['technical', 'terms', 'here'],
|
|
194
|
+
user_first_name: 'John',
|
|
195
|
+
user_last_name: 'Doe',
|
|
196
|
+
},
|
|
197
|
+
prevAsrText: 'Previous transcription for context',
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Response Structure
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
interface TranscriptionResponse {
|
|
205
|
+
status: 'success' | 'empty' | 'error' | 'formatted';
|
|
206
|
+
llm_text: string | null; // Formatted text (recommended)
|
|
207
|
+
asr_text: string | null; // Raw ASR output
|
|
208
|
+
pipeline_text: string | null; // Legacy field (usually null)
|
|
209
|
+
asr_time: number | null; // ASR processing time
|
|
210
|
+
llm_time: number | null; // LLM processing time
|
|
211
|
+
total_time: number; // Total processing time
|
|
212
|
+
detected_language: string | null;
|
|
213
|
+
error_message: string | null;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Audio Requirements
|
|
220
|
+
|
|
221
|
+
The Wispr Flow API expects audio in the following format:
|
|
222
|
+
|
|
223
|
+
| Property | Value |
|
|
224
|
+
|-------------|-----------------|
|
|
225
|
+
| Format | WAV (PCM) |
|
|
226
|
+
| Sample Rate | 16000 Hz |
|
|
227
|
+
| Channels | Mono (1) |
|
|
228
|
+
| Bit Depth | 16-bit |
|
|
229
|
+
| Encoding | Base64 |
|
|
230
|
+
|
|
231
|
+
### Converting Audio with FFmpeg
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
ffmpeg -i input.mp3 -ar 16000 -ac 1 -acodec pcm_s16le output.wav
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Converting in Code
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { toBase64 } from 'unofficial-wispr-flow-sdk';
|
|
241
|
+
import { readFile } from 'fs/promises';
|
|
242
|
+
|
|
243
|
+
const audioBuffer = await readFile('audio.wav');
|
|
244
|
+
const base64Audio = toBase64(audioBuffer);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Error Handling
|
|
250
|
+
|
|
251
|
+
The SDK provides specific error classes for different failure modes:
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
import {
|
|
255
|
+
WisprAuthError,
|
|
256
|
+
WisprApiError,
|
|
257
|
+
WisprValidationError,
|
|
258
|
+
WisprTimeoutError,
|
|
259
|
+
} from 'unofficial-wispr-flow-sdk';
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
await client.transcribe({ audioData });
|
|
263
|
+
} catch (error) {
|
|
264
|
+
if (error instanceof WisprAuthError) {
|
|
265
|
+
// Authentication failed - token expired or invalid
|
|
266
|
+
console.error('Auth error:', error.message);
|
|
267
|
+
} else if (error instanceof WisprApiError) {
|
|
268
|
+
// API request failed
|
|
269
|
+
console.error('API error:', error.message, error.statusCode);
|
|
270
|
+
} else if (error instanceof WisprTimeoutError) {
|
|
271
|
+
// Request timed out
|
|
272
|
+
console.error('Timeout:', error.message);
|
|
273
|
+
} else if (error instanceof WisprValidationError) {
|
|
274
|
+
// Invalid input
|
|
275
|
+
console.error('Validation error:', error.message);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Examples
|
|
283
|
+
|
|
284
|
+
See the [examples](./examples) directory for complete usage examples:
|
|
285
|
+
|
|
286
|
+
| Example | Description |
|
|
287
|
+
|---------|-------------|
|
|
288
|
+
| [01-basic-auth.ts](./examples/01-basic-auth.ts) | Basic authentication flow |
|
|
289
|
+
| [02-auto-refresh.ts](./examples/02-auto-refresh.ts) | Automatic token refresh |
|
|
290
|
+
| [03-transcribe-file.ts](./examples/03-transcribe-file.ts) | Transcribe audio files |
|
|
291
|
+
| [04-error-handling.ts](./examples/04-error-handling.ts) | Error handling patterns |
|
|
292
|
+
| [05-microphone-browser](./examples/05-microphone-browser/) | Browser microphone recording |
|
|
293
|
+
|
|
294
|
+
### Running Examples
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Set up environment variables in .env file first
|
|
298
|
+
cp .env.example .env
|
|
299
|
+
# Edit .env with your credentials
|
|
300
|
+
|
|
301
|
+
# Run examples
|
|
302
|
+
bun run examples/01-basic-auth.ts
|
|
303
|
+
bun run examples/03-transcribe-file.ts path/to/audio.wav
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## API Reference
|
|
309
|
+
|
|
310
|
+
### WisprAuth
|
|
311
|
+
|
|
312
|
+
| Method | Description |
|
|
313
|
+
|--------|-------------|
|
|
314
|
+
| `signIn(credentials)` | Sign in with email/password |
|
|
315
|
+
| `signInWithSupabase(credentials)` | Sign in via Supabase directly |
|
|
316
|
+
| `signInWithWisprApi(credentials)` | Sign in via Wispr API |
|
|
317
|
+
| `refreshSession()` | Refresh the access token |
|
|
318
|
+
| `signOut()` | Sign out and clear session |
|
|
319
|
+
| `getSession()` | Get current session |
|
|
320
|
+
| `isSessionExpired(buffer?)` | Check if session is expired |
|
|
321
|
+
| `getValidAccessToken()` | Get valid token, refreshing if needed |
|
|
322
|
+
| `checkUserStatus(email)` | Check if user exists |
|
|
323
|
+
|
|
324
|
+
### WisprClient
|
|
325
|
+
|
|
326
|
+
| Method | Description |
|
|
327
|
+
|--------|-------------|
|
|
328
|
+
| `warmup()` | Warmup transcription service |
|
|
329
|
+
| `transcribe(request)` | Transcribe audio to text |
|
|
330
|
+
| `getConfig()` | Get client configuration |
|
|
331
|
+
| `updateAccessToken(token)` | Update access token |
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Development
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
# Install dependencies
|
|
339
|
+
bun install
|
|
340
|
+
|
|
341
|
+
# Set up environment
|
|
342
|
+
cp .env.example .env
|
|
343
|
+
# Edit .env with your values
|
|
344
|
+
|
|
345
|
+
# Run type check
|
|
346
|
+
bun run typecheck
|
|
347
|
+
|
|
348
|
+
# Build
|
|
349
|
+
bun run build
|
|
350
|
+
|
|
351
|
+
# Run examples
|
|
352
|
+
bun run examples/01-basic-auth.ts
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Contributing
|
|
358
|
+
|
|
359
|
+
Contributions are welcome. Please open an issue first to discuss what you would like to change.
|
|
360
|
+
|
|
361
|
+
1. Fork the repository
|
|
362
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
363
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
364
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
365
|
+
5. Open a Pull Request
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## License
|
|
370
|
+
|
|
371
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
**Note**: This SDK is unofficial and not affiliated with Wispr Inc.
|