@simonpeacocks/peacockery-voice-client 0.1.4 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type PeacockeryVoiceClientOptions } from "./auth.js";
2
2
  import type { paths } from "./schema.js";
3
3
  export { type PeacockeryVoiceClientOptions, type PeacockeryVoiceDpopBindingProofInput, type PeacockeryVoiceDpopBindingProofProvider, type PeacockeryVoiceDpopProofInput, type PeacockeryVoiceDpopProofProvider, type PeacockeryVoiceEnvironment, peacockeryVoiceBaseUrls, } from "./auth.js";
4
- export { createPeacockeryVoiceRealtimeRequest, type PeacockeryVoiceRealtimeAudioReceivedEvent, type PeacockeryVoiceRealtimeEvent, type PeacockeryVoiceRealtimeOptions, type PeacockeryVoiceRealtimePongEvent, type PeacockeryVoiceRealtimeRequest, type PeacockeryVoiceRealtimeSessionStartedEvent, type PeacockeryVoiceRealtimeTranscriptEvent, parsePeacockeryVoiceRealtimeEvent, } from "./realtime.js";
4
+ export { createPeacockeryVoiceRealtimeRequest, type PeacockeryVoiceRealtimeAudioReceivedEvent, type PeacockeryVoiceRealtimeEvent, type PeacockeryVoiceRealtimeOptions, type PeacockeryVoiceRealtimePongEvent, type PeacockeryVoiceRealtimeRequest, type PeacockeryVoiceRealtimeSessionStartedEvent, type PeacockeryVoiceRealtimeTranscriptEvent, type PeacockeryVoiceRealtimeTurnEvent, parsePeacockeryVoiceRealtimeEvent, } from "./realtime.js";
5
5
  export type { components, operations, paths } from "./schema.js";
6
6
  export declare const createPeacockeryVoiceClient: (options: PeacockeryVoiceClientOptions) => import("openapi-fetch").Client<paths, `${string}/${string}`>;
7
7
  export type PeacockeryVoiceClient = ReturnType<typeof createPeacockeryVoiceClient>;
@@ -1,19 +1,43 @@
1
1
  import { type PeacockeryVoiceClientOptions } from "./auth.js";
2
2
  import type { components } from "./schema.js";
3
3
  type RealtimeTerminalEvent = components["schemas"]["RealtimeSessionResult"];
4
- type TranscriptionArtifact = components["schemas"]["TranscriptionArtifact"];
5
- type TranscriptSegment = TranscriptionArtifact["content"]["segments"]["items"][number];
6
- type TranscriptSpeakerTurn = TranscriptionArtifact["content"]["speaker_turns"]["items"][number];
7
- type TranscriptWord = TranscriptionArtifact["content"]["words"]["items"][number];
4
+ interface TranscriptSegment {
5
+ endSeconds: number | null;
6
+ scores?: {
7
+ confidence?: number;
8
+ logProbability?: number;
9
+ probability?: number;
10
+ score?: number;
11
+ speakerConfidence?: number;
12
+ };
13
+ speaker?: string | number;
14
+ startSeconds: number | null;
15
+ text: string;
16
+ }
17
+ type TranscriptSpeakerTurn = Omit<TranscriptSegment, "scores">;
18
+ type TranscriptWord = TranscriptSegment & {
19
+ startSeconds: number;
20
+ endSeconds: number;
21
+ };
8
22
  export interface PeacockeryVoiceRealtimeOptions extends PeacockeryVoiceClientOptions {
9
23
  channels?: number;
24
+ contextBias?: string[];
25
+ diarize?: boolean;
10
26
  encoding?: string;
11
27
  endpointing?: string;
12
28
  interimResults?: boolean;
13
29
  language?: string;
14
30
  model: string;
15
31
  sampleRate?: number;
32
+ speakerReferences?: Record<string, string>;
16
33
  targetStreamingDelayMs?: number;
34
+ turnDetection?: {
35
+ start_threshold?: number;
36
+ eager_end_threshold?: number;
37
+ end_threshold?: number;
38
+ min_silence_ms?: number;
39
+ end_timeout_ms?: number;
40
+ };
17
41
  utteranceEndMs?: number;
18
42
  vadEvents?: boolean;
19
43
  }
@@ -51,7 +75,12 @@ export interface PeacockeryVoiceRealtimePongEvent {
51
75
  session_id: string;
52
76
  type: "pong";
53
77
  }
54
- export type PeacockeryVoiceRealtimeEvent = PeacockeryVoiceRealtimeAudioReceivedEvent | PeacockeryVoiceRealtimePongEvent | PeacockeryVoiceRealtimeSessionStartedEvent | PeacockeryVoiceRealtimeTranscriptEvent | RealtimeTerminalEvent;
78
+ export interface PeacockeryVoiceRealtimeTurnEvent extends RealtimeEventBase {
79
+ end_reason?: "threshold" | "timeout";
80
+ time_seconds: number;
81
+ type: "turn.start" | "turn.eager_end" | "turn.resume" | "turn.end";
82
+ }
83
+ export type PeacockeryVoiceRealtimeEvent = PeacockeryVoiceRealtimeTurnEvent | PeacockeryVoiceRealtimeAudioReceivedEvent | PeacockeryVoiceRealtimePongEvent | PeacockeryVoiceRealtimeSessionStartedEvent | PeacockeryVoiceRealtimeTranscriptEvent | RealtimeTerminalEvent;
55
84
  export declare const createPeacockeryVoiceRealtimeRequest: (options: PeacockeryVoiceRealtimeOptions) => Promise<PeacockeryVoiceRealtimeRequest>;
56
85
  export declare const parsePeacockeryVoiceRealtimeEvent: (value: string | unknown) => PeacockeryVoiceRealtimeEvent;
57
86
  export {};
package/dist/realtime.js CHANGED
@@ -4,13 +4,20 @@ const realtimeHttpUrl = (options) => {
4
4
  const url = new URL("/v1/realtime", options.baseUrl ?? peacockeryVoiceBaseUrls[environment]);
5
5
  const query = {
6
6
  channels: options.channels,
7
+ diarize: options.diarize,
7
8
  encoding: options.encoding,
8
9
  endpointing: options.endpointing,
9
10
  interim_results: options.interimResults,
10
11
  language: options.language,
11
12
  model: options.model,
12
13
  sample_rate: options.sampleRate,
14
+ speaker_references: options.speakerReferences
15
+ ? JSON.stringify(options.speakerReferences)
16
+ : undefined,
13
17
  target_streaming_delay_ms: options.targetStreamingDelayMs,
18
+ turn_detection: options.turnDetection
19
+ ? JSON.stringify(options.turnDetection)
20
+ : undefined,
14
21
  utterance_end_ms: options.utteranceEndMs,
15
22
  vad_events: options.vadEvents,
16
23
  };
@@ -19,6 +26,9 @@ const realtimeHttpUrl = (options) => {
19
26
  url.searchParams.set(name, String(value));
20
27
  }
21
28
  }
29
+ for (const term of options.contextBias ?? []) {
30
+ url.searchParams.append("context_bias", term);
31
+ }
22
32
  return url;
23
33
  };
24
34
  const headersRecord = (headers) => {
@@ -79,6 +89,12 @@ export const createPeacockeryVoiceRealtimeRequest = async (options) => {
79
89
  return { headers: headersRecord(headers), url: url.href };
80
90
  };
81
91
  const isRecord = (value) => typeof value === "object" && value !== null;
92
+ const isTurnEvent = (value) => typeof value.time_seconds === "number" &&
93
+ Number.isFinite(value.time_seconds) &&
94
+ value.time_seconds >= 0 &&
95
+ (value.end_reason === undefined ||
96
+ value.end_reason === "threshold" ||
97
+ value.end_reason === "timeout");
82
98
  const isRealtimeEvent = (value) => {
83
99
  if (!isRecord(value) || typeof value.type !== "string") {
84
100
  return false;
@@ -99,6 +115,9 @@ const isRealtimeEvent = (value) => {
99
115
  if (!hasProtocolBase) {
100
116
  return false;
101
117
  }
118
+ if (["turn.start", "turn.eager_end", "turn.resume", "turn.end"].includes(value.type)) {
119
+ return isTurnEvent(value);
120
+ }
102
121
  if (value.type === "session.started") {
103
122
  return ((typeof value.language === "string" || value.language === null) &&
104
123
  typeof value.model === "string");
package/dist/schema.d.ts CHANGED
@@ -1288,6 +1288,93 @@ export interface paths {
1288
1288
  patch?: never;
1289
1289
  trace?: never;
1290
1290
  };
1291
+ "/v1/diarizations": {
1292
+ parameters: {
1293
+ query?: never;
1294
+ header?: never;
1295
+ path?: never;
1296
+ cookie?: never;
1297
+ };
1298
+ get?: never;
1299
+ put?: never;
1300
+ /** Create a standalone speaker-track job */
1301
+ post: {
1302
+ parameters: {
1303
+ query?: never;
1304
+ header?: {
1305
+ "idempotency-key"?: string;
1306
+ };
1307
+ path?: never;
1308
+ cookie?: never;
1309
+ };
1310
+ requestBody: {
1311
+ content: {
1312
+ "application/json": components["schemas"]["DiarizationRequest"];
1313
+ };
1314
+ };
1315
+ responses: {
1316
+ /** @description Existing idempotent job */
1317
+ 200: {
1318
+ headers: {
1319
+ [name: string]: unknown;
1320
+ };
1321
+ content: {
1322
+ "application/json": components["schemas"]["JobView"];
1323
+ };
1324
+ };
1325
+ /** @description Queued diarization */
1326
+ 202: {
1327
+ headers: {
1328
+ [name: string]: unknown;
1329
+ };
1330
+ content: {
1331
+ "application/json": components["schemas"]["JobView"];
1332
+ };
1333
+ };
1334
+ /** @description Invalid request */
1335
+ 400: {
1336
+ headers: {
1337
+ [name: string]: unknown;
1338
+ };
1339
+ content: {
1340
+ "application/json": components["schemas"]["ErrorResponse"];
1341
+ };
1342
+ };
1343
+ /** @description Unauthorized */
1344
+ 401: {
1345
+ headers: {
1346
+ [name: string]: unknown;
1347
+ };
1348
+ content: {
1349
+ "application/json": components["schemas"]["ErrorResponse"];
1350
+ };
1351
+ };
1352
+ /** @description Owned input or linked transcript unavailable */
1353
+ 404: {
1354
+ headers: {
1355
+ [name: string]: unknown;
1356
+ };
1357
+ content: {
1358
+ "application/json": components["schemas"]["ErrorResponse"];
1359
+ };
1360
+ };
1361
+ /** @description Idempotency conflict */
1362
+ 409: {
1363
+ headers: {
1364
+ [name: string]: unknown;
1365
+ };
1366
+ content: {
1367
+ "application/json": components["schemas"]["ErrorResponse"];
1368
+ };
1369
+ };
1370
+ };
1371
+ };
1372
+ delete?: never;
1373
+ options?: never;
1374
+ head?: never;
1375
+ patch?: never;
1376
+ trace?: never;
1377
+ };
1291
1378
  "/v1/jobs/{job_id}": {
1292
1379
  parameters: {
1293
1380
  query?: never;
@@ -1402,6 +1489,7 @@ export interface paths {
1402
1489
  query?: {
1403
1490
  audio_format?: string;
1404
1491
  channels?: number;
1492
+ context_bias?: string;
1405
1493
  detect_entities?: "true" | "false";
1406
1494
  diarize?: "true" | "false";
1407
1495
  diarize_model?: "latest" | "v1";
@@ -1425,8 +1513,12 @@ export interface paths {
1425
1513
  sample_rate?: number;
1426
1514
  search?: string;
1427
1515
  smart_format?: "true" | "false";
1516
+ /** @description JSON object mapping speaker names to completed upload input_key values */
1517
+ speaker_references?: string;
1428
1518
  tag?: string;
1429
1519
  target_streaming_delay_ms?: number;
1520
+ /** @description JSON turn-detection configuration; {} uses provider defaults */
1521
+ turn_detection?: string;
1430
1522
  utterance_end_ms?: number;
1431
1523
  vad_events?: "true" | "false";
1432
1524
  version?: string;
@@ -1544,6 +1636,64 @@ export interface paths {
1544
1636
  patch?: never;
1545
1637
  trace?: never;
1546
1638
  };
1639
+ "/v1/realtime/sessions/{session_id}/diarizations": {
1640
+ parameters: {
1641
+ query?: never;
1642
+ header?: never;
1643
+ path?: never;
1644
+ cookie?: never;
1645
+ };
1646
+ /** List speaker-track jobs linked to an owned realtime session */
1647
+ get: {
1648
+ parameters: {
1649
+ query?: never;
1650
+ header?: never;
1651
+ path: {
1652
+ session_id: string;
1653
+ };
1654
+ cookie?: never;
1655
+ };
1656
+ requestBody?: never;
1657
+ responses: {
1658
+ /** @description Linked jobs with separate speaker artifacts */
1659
+ 200: {
1660
+ headers: {
1661
+ [name: string]: unknown;
1662
+ };
1663
+ content: {
1664
+ "application/json": {
1665
+ jobs: components["schemas"]["JobView"][];
1666
+ };
1667
+ };
1668
+ };
1669
+ /** @description Unauthorized */
1670
+ 401: {
1671
+ headers: {
1672
+ [name: string]: unknown;
1673
+ };
1674
+ content: {
1675
+ "application/json": components["schemas"]["ErrorResponse"];
1676
+ };
1677
+ };
1678
+ /** @description Session unavailable */
1679
+ 404: {
1680
+ headers: {
1681
+ [name: string]: unknown;
1682
+ };
1683
+ content: {
1684
+ "application/json": components["schemas"]["ErrorResponse"];
1685
+ };
1686
+ };
1687
+ };
1688
+ };
1689
+ put?: never;
1690
+ post?: never;
1691
+ delete?: never;
1692
+ options?: never;
1693
+ head?: never;
1694
+ patch?: never;
1695
+ trace?: never;
1696
+ };
1547
1697
  "/v1/text": {
1548
1698
  parameters: {
1549
1699
  query?: never;
@@ -2075,10 +2225,10 @@ export interface components {
2075
2225
  error_details: components["schemas"]["ProviderFailureDiagnostic"];
2076
2226
  job_id: string;
2077
2227
  /** @enum {string} */
2078
- kind: "transcription";
2228
+ kind: "transcription" | "diarization";
2079
2229
  progress: number;
2080
2230
  queued_at: string | null;
2081
- result: components["schemas"]["TranscriptionArtifact"] | null;
2231
+ result: components["schemas"]["TranscriptionArtifact"] | components["schemas"]["DiarizationArtifact"] | null;
2082
2232
  started_at: string | null;
2083
2233
  /** @enum {string} */
2084
2234
  status: "pending" | "queued" | "running" | "succeeded" | "failed";
@@ -2114,7 +2264,7 @@ export interface components {
2114
2264
  /** @enum {string|null} */
2115
2265
  source: "derived" | "provider" | null;
2116
2266
  items: {
2117
- end_seconds: number;
2267
+ end_seconds: number | null;
2118
2268
  scores: {
2119
2269
  confidence: number | null;
2120
2270
  log_probability: number | null;
@@ -2123,7 +2273,7 @@ export interface components {
2123
2273
  speaker_confidence: number | null;
2124
2274
  } | null;
2125
2275
  speaker: string | number | null;
2126
- start_seconds: number;
2276
+ start_seconds: number | null;
2127
2277
  text: string;
2128
2278
  }[];
2129
2279
  };
@@ -2133,9 +2283,9 @@ export interface components {
2133
2283
  /** @enum {string|null} */
2134
2284
  source: "derived" | "provider" | null;
2135
2285
  items: {
2136
- end_seconds: number;
2286
+ end_seconds: number | null;
2137
2287
  speaker: string | number | null;
2138
- start_seconds: number;
2288
+ start_seconds: number | null;
2139
2289
  text: string;
2140
2290
  scores: null;
2141
2291
  }[];
@@ -2242,6 +2392,58 @@ export interface components {
2242
2392
  message: string;
2243
2393
  }[];
2244
2394
  };
2395
+ DiarizationArtifact: {
2396
+ /** @enum {string} */
2397
+ artifact_type: "speaker_tracks";
2398
+ /** @enum {string} */
2399
+ attribution: "separate_timeline_requires_alignment";
2400
+ duration_seconds: number;
2401
+ input: {
2402
+ key: string;
2403
+ r2_etag: string;
2404
+ r2_version: string;
2405
+ sha256: string;
2406
+ size_bytes: number;
2407
+ };
2408
+ processing_seconds: number;
2409
+ provenance: {
2410
+ completed_at: string;
2411
+ device: string;
2412
+ job_id: string;
2413
+ /** @enum {string} */
2414
+ model: "nvidia/Nemotron-3-Diarization";
2415
+ model_revision: string;
2416
+ /** @enum {string} */
2417
+ provider: "gmk";
2418
+ provider_job_id: string;
2419
+ /** @enum {string} */
2420
+ revision_source: "deployment_manifest";
2421
+ runtime: string;
2422
+ /** @enum {string} */
2423
+ speaker_origin: "model_activity";
2424
+ };
2425
+ /** @enum {number} */
2426
+ schema_version: 1;
2427
+ segmentation: {
2428
+ /** @enum {number} */
2429
+ minimum_duration_seconds: 0;
2430
+ /** @enum {number} */
2431
+ offset: 0.5;
2432
+ /** @enum {number} */
2433
+ onset: 0.5;
2434
+ /** @enum {number} */
2435
+ padding_seconds: 0;
2436
+ /** @enum {string} */
2437
+ preset: "neutral-0.5";
2438
+ };
2439
+ /** @enum {string} */
2440
+ speaker_identity: "anonymous_recording_local";
2441
+ tracks: {
2442
+ end_seconds: number;
2443
+ speaker: string;
2444
+ start_seconds: number;
2445
+ }[];
2446
+ };
2245
2447
  TranscriptionRequest: {
2246
2448
  asr_model: string;
2247
2449
  diarize?: boolean;
@@ -2258,6 +2460,11 @@ export interface components {
2258
2460
  */
2259
2461
  sync?: boolean;
2260
2462
  };
2463
+ DiarizationRequest: {
2464
+ input_key: string;
2465
+ session_id?: string;
2466
+ transcription_job_id?: string;
2467
+ };
2261
2468
  TextResponse: {
2262
2469
  cache: components["schemas"]["TextCacheStatuses"];
2263
2470
  context: components["schemas"]["TextExecutionContext"];
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@simonpeacocks/peacockery-voice-client",
3
- "version": "0.1.4",
3
+ "version": "0.3.0",
4
4
  "description": "Generated TypeScript client for the Peacockery Voice API",
5
- "type": "module",
6
- "license": "MIT",
7
5
  "repository": {
8
6
  "type": "git",
9
7
  "url": "git+https://github.com/chikingsley/peacockery-voice.git",
10
8
  "directory": "clients/typescript"
11
9
  },
10
+ "license": "MIT",
11
+ "type": "module",
12
12
  "exports": {
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
@@ -18,10 +18,6 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "publishConfig": {
22
- "access": "public",
23
- "provenance": false
24
- },
25
21
  "scripts": {
26
22
  "build": "tsc",
27
23
  "check": "tsc --noEmit",
@@ -32,5 +28,9 @@
32
28
  },
33
29
  "devDependencies": {
34
30
  "typescript": "^7.0.2"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": false
35
35
  }
36
36
  }