@juspay/neurolink 13.7.0 → 13.8.1

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +3 -6
  2. package/dist/browser/neurolink.min.js +480 -460
  3. package/dist/cli/commands/serve.js +11 -1
  4. package/dist/cli/commands/transcribe.js +39 -3
  5. package/dist/constants/langfuse.d.ts +2 -0
  6. package/dist/constants/langfuse.js +2 -0
  7. package/dist/factories/sttDescriptors.js +7 -0
  8. package/dist/index.d.ts +3 -2
  9. package/dist/index.js +4 -2
  10. package/dist/mcp/externalServerManager.js +4 -1
  11. package/dist/mcp/mcpClientFactory.d.ts +6 -0
  12. package/dist/mcp/mcpClientFactory.js +44 -0
  13. package/dist/neurolink.js +42 -3
  14. package/dist/observability/exporters/langfuseExporter.d.ts +4 -0
  15. package/dist/observability/exporters/langfuseExporter.js +29 -8
  16. package/dist/observability/otlpEncoding.js +2 -2
  17. package/dist/server/abstract/baseServerAdapter.js +2 -0
  18. package/dist/server/adapters/expressAdapter.js +1 -1
  19. package/dist/server/adapters/fastifyAdapter.js +4 -1
  20. package/dist/server/adapters/honoAdapter.js +1 -1
  21. package/dist/server/adapters/koaAdapter.js +1 -1
  22. package/dist/server/routes/transcribeRoutes.d.ts +0 -8
  23. package/dist/server/routes/transcribeRoutes.js +130 -3
  24. package/dist/server/utils/validation.d.ts +409 -15
  25. package/dist/server/utils/validation.js +106 -4
  26. package/dist/server/websocket/frameQueue.d.ts +16 -0
  27. package/dist/server/websocket/frameQueue.js +55 -0
  28. package/dist/server/websocket/realtimeTranscription.d.ts +48 -0
  29. package/dist/server/websocket/realtimeTranscription.js +603 -0
  30. package/dist/server/websocket/transcribeWebSocket.d.ts +17 -1
  31. package/dist/server/websocket/transcribeWebSocket.js +263 -64
  32. package/dist/services/server/ai/observability/langfuseSetup.js +6 -1
  33. package/dist/types/cli.d.ts +6 -0
  34. package/dist/types/exporter.d.ts +3 -1
  35. package/dist/types/server.d.ts +304 -2
  36. package/dist/types/stt.d.ts +38 -3
  37. package/dist/types/transcribe.d.ts +401 -5
  38. package/dist/voice/audioLevel.d.ts +14 -0
  39. package/dist/voice/audioLevel.js +60 -0
  40. package/dist/voice/codeMix.d.ts +40 -0
  41. package/dist/voice/codeMix.js +282 -0
  42. package/dist/voice/correction/align.d.ts +12 -0
  43. package/dist/voice/correction/align.js +48 -0
  44. package/dist/voice/correction/guards.d.ts +39 -0
  45. package/dist/voice/correction/guards.js +122 -0
  46. package/dist/voice/correction/index.d.ts +25 -3
  47. package/dist/voice/correction/index.js +132 -4
  48. package/dist/voice/correction/rewrite.d.ts +64 -3
  49. package/dist/voice/correction/rewrite.js +295 -25
  50. package/dist/voice/eval/sttEvalLangfuse.d.ts +14 -0
  51. package/dist/voice/eval/sttEvalLangfuse.js +182 -0
  52. package/dist/voice/eval/sttEvalStore.d.ts +27 -0
  53. package/dist/voice/eval/sttEvalStore.js +397 -0
  54. package/dist/voice/index.js +3 -0
  55. package/dist/voice/languages.d.ts +34 -0
  56. package/dist/voice/languages.js +290 -0
  57. package/dist/voice/modelAssets.d.ts +28 -0
  58. package/dist/voice/modelAssets.js +113 -0
  59. package/dist/voice/output/render.d.ts +32 -0
  60. package/dist/voice/output/render.js +368 -0
  61. package/dist/voice/providers/OpenAISTT.d.ts +11 -1
  62. package/dist/voice/providers/OpenAISTT.js +57 -6
  63. package/dist/voice/session/transcriptionSession.d.ts +55 -0
  64. package/dist/voice/session/transcriptionSession.js +225 -0
  65. package/dist/voice/streaming/chunkedStreamAdapter.d.ts +7 -0
  66. package/dist/voice/streaming/chunkedStreamAdapter.js +711 -28
  67. package/dist/voice/streaming/endpointer.d.ts +50 -17
  68. package/dist/voice/streaming/endpointer.js +115 -19
  69. package/dist/voice/transcribe.d.ts +18 -1
  70. package/dist/voice/transcribe.js +459 -18
  71. package/dist/voice/transcribeStream.d.ts +18 -1
  72. package/dist/voice/transcribeStream.js +413 -16
  73. package/dist/voice/vad/assets.d.ts +36 -0
  74. package/dist/voice/vad/assets.js +142 -0
  75. package/dist/voice/vad/frameScorer.d.ts +28 -0
  76. package/dist/voice/vad/frameScorer.js +90 -0
  77. package/dist/voice/vad/sileroVad.d.ts +43 -0
  78. package/dist/voice/vad/sileroVad.js +178 -0
  79. package/dist/voice/whistle/assets.d.ts +3 -4
  80. package/dist/voice/whistle/assets.js +11 -95
  81. package/docs-site/static/search-index.json +21 -6
  82. package/models/silero-vad/README.md +19 -0
  83. package/models/silero-vad/silero_vad.onnx +0 -0
  84. package/package.json +3 -1
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Push-driven async iterable shared by the transcription sockets: socket
3
+ * frames are pushed in, `transcribeStream()` pulls them out.
4
+ *
5
+ * @module server/websocket/frameQueue
6
+ */
7
+ /** Push-driven async iterable: socket frames in, `transcribeStream()` pulls. */
8
+ export declare class FrameQueue implements AsyncIterable<Buffer> {
9
+ private readonly frames;
10
+ private waiting;
11
+ private ended;
12
+ queuedBytes: number;
13
+ push(frame: Buffer): void;
14
+ end(): void;
15
+ [Symbol.asyncIterator](): AsyncIterator<Buffer>;
16
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Push-driven async iterable shared by the transcription sockets: socket
3
+ * frames are pushed in, `transcribeStream()` pulls them out.
4
+ *
5
+ * @module server/websocket/frameQueue
6
+ */
7
+ /** Push-driven async iterable: socket frames in, `transcribeStream()` pulls. */
8
+ export class FrameQueue {
9
+ frames = [];
10
+ waiting;
11
+ ended = false;
12
+ queuedBytes = 0;
13
+ push(frame) {
14
+ if (this.ended) {
15
+ return;
16
+ }
17
+ if (this.waiting) {
18
+ const resolve = this.waiting;
19
+ this.waiting = undefined;
20
+ resolve({ value: frame, done: false });
21
+ return;
22
+ }
23
+ this.frames.push(frame);
24
+ this.queuedBytes += frame.length;
25
+ }
26
+ end() {
27
+ this.ended = true;
28
+ if (this.waiting) {
29
+ const resolve = this.waiting;
30
+ this.waiting = undefined;
31
+ resolve({ value: undefined, done: true });
32
+ }
33
+ }
34
+ [Symbol.asyncIterator]() {
35
+ return {
36
+ next: () => {
37
+ const frame = this.frames.shift();
38
+ if (frame) {
39
+ this.queuedBytes -= frame.length;
40
+ return Promise.resolve({ value: frame, done: false });
41
+ }
42
+ if (this.ended) {
43
+ return Promise.resolve({ value: undefined, done: true });
44
+ }
45
+ return new Promise((resolve) => {
46
+ this.waiting = resolve;
47
+ });
48
+ },
49
+ return: () => {
50
+ this.end();
51
+ return Promise.resolve({ value: undefined, done: true });
52
+ },
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * OpenAI Realtime transcription protocol over `transcribeStream()`.
3
+ *
4
+ * A client connects to `/v1/realtime?intent=transcription` and speaks OpenAI's
5
+ * Realtime transcription protocol, so the stock LiveKit
6
+ * `openai.STT(base_url=…, use_realtime=True)` plugin, Pipecat or the OpenAI
7
+ * SDK stream to NeuroLink with no adapter:
8
+ *
9
+ * - config: `session.update` (`session.type: "transcription"`, audio under
10
+ * `session.audio.input`) or the beta `transcription_session.update`;
11
+ * - audio: `input_audio_buffer.append` with base64 PCM16 at the declared rate
12
+ * (24 kHz for both dialects' default);
13
+ * - `input_audio_buffer.commit` closes the open utterance; so does an audio
14
+ * gap, since a client that stops sending (a muted mic) sends nothing else.
15
+ *
16
+ * Each utterance is one conversation item. Its events go out in this order:
17
+ * - `input_audio_buffer.speech_started`;
18
+ * - `…input_audio_transcription.delta` per newly agreed words. A client
19
+ * appends deltas, so only the prefix two passes agreed on is sent; words
20
+ * still in flux never reach it;
21
+ * - `input_audio_buffer.speech_stopped`, `input_audio_buffer.committed`;
22
+ * - `…input_audio_transcription.completed` with the corrected text (or the
23
+ * raw final; see `ServerSTTRealtimeProfile.completed`).
24
+ *
25
+ * Items complete strictly in order: a client keeps one running text, so a
26
+ * later utterance's deltas wait until the earlier one has completed.
27
+ * NeuroLink's own detail goes out as extra event types a stock client ignores:
28
+ * `neurolink.final`, `neurolink.corrected` and `neurolink.output`.
29
+ *
30
+ * Everything NeuroLink-specific (engine, fallback, dictionary, correction,
31
+ * output languages) comes from the profile the client's `model` names; a
32
+ * realtime client cannot send it.
33
+ *
34
+ * @module server/websocket/realtimeTranscription
35
+ */
36
+ import type { IncomingMessage } from "node:http";
37
+ import type { NeuroLink } from "../../neurolink.js";
38
+ import type { ServerRealtimeSocket, ServerSTTRealtimeProfile } from "../../types/index.js";
39
+ /**
40
+ * Operator profiles: `NEUROLINK_STT_REALTIME_PROFILES` (JSON), overlaid by
41
+ * the attach option. An invalid env value is logged and ignored.
42
+ */
43
+ export declare function resolveRealtimeProfiles(fromOptions?: Readonly<Record<string, ServerSTTRealtimeProfile>>, env?: NodeJS.ProcessEnv): Readonly<Record<string, ServerSTTRealtimeProfile>>;
44
+ /**
45
+ * Serve one realtime transcription connection. The upgrade has already
46
+ * passed the origin and token checks.
47
+ */
48
+ export declare function serveRealtimeTranscription(client: ServerRealtimeSocket, req: IncomingMessage, neurolink: NeuroLink, profiles: Readonly<Record<string, ServerSTTRealtimeProfile>>): void;