@rimelabs/sdk 0.1.0-alpha.1 → 0.1.0-alpha.12

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 (67) hide show
  1. package/CHANGELOG.md +96 -11
  2. package/LICENSE-PRISM +201 -0
  3. package/NOTICE-PRISM +9 -0
  4. package/README.md +175 -63
  5. package/dist/auth.d.ts +9 -3
  6. package/dist/auth.js +12 -4
  7. package/dist/cancellation.d.ts +6 -0
  8. package/dist/cancellation.js +54 -0
  9. package/dist/client.d.ts +23 -23
  10. package/dist/client.js +39 -92
  11. package/dist/grpc.d.ts +27 -0
  12. package/dist/{transport.js → grpc.js} +36 -106
  13. package/dist/index.d.ts +6 -2
  14. package/dist/index.js +5 -2
  15. package/dist/pcm.d.ts +21 -0
  16. package/dist/pcm.js +52 -0
  17. package/dist/realtime/async.d.ts +23 -0
  18. package/dist/realtime/async.js +87 -0
  19. package/dist/realtime/audio.d.ts +2 -0
  20. package/dist/realtime/audio.js +11 -0
  21. package/dist/realtime/client.d.ts +12 -0
  22. package/dist/realtime/client.js +156 -0
  23. package/dist/realtime/protocol.d.ts +80 -0
  24. package/dist/realtime/protocol.js +354 -0
  25. package/dist/realtime/session.d.ts +67 -0
  26. package/dist/realtime/session.js +731 -0
  27. package/dist/realtime/transport.d.ts +16 -0
  28. package/dist/realtime/transport.js +83 -0
  29. package/dist/realtime/types.d.ts +186 -0
  30. package/dist/realtime/types.js +10 -0
  31. package/dist/stt/audio.d.ts +15 -0
  32. package/dist/stt/audio.js +46 -0
  33. package/dist/stt/client.d.ts +13 -0
  34. package/dist/stt/client.js +73 -0
  35. package/dist/stt/policy.d.ts +11 -0
  36. package/dist/stt/policy.js +11 -0
  37. package/dist/stt/protocol.d.ts +13 -0
  38. package/dist/stt/protocol.js +61 -0
  39. package/dist/stt/queue.d.ts +16 -0
  40. package/dist/stt/queue.js +45 -0
  41. package/dist/stt/stream.d.ts +48 -0
  42. package/dist/stt/stream.js +224 -0
  43. package/dist/stt/transport.d.ts +13 -0
  44. package/dist/stt/transport.js +45 -0
  45. package/dist/stt/types.d.ts +34 -0
  46. package/dist/stt/types.js +1 -0
  47. package/dist/{audio.js → tts/audio.js} +3 -2
  48. package/dist/tts/client.d.ts +39 -0
  49. package/dist/tts/client.js +121 -0
  50. package/dist/{policy.d.ts → tts/policy.d.ts} +2 -2
  51. package/dist/tts/policy.js +41 -0
  52. package/dist/{sentences.js → tts/sentences.js} +2 -2
  53. package/dist/{stream.d.ts → tts/stream.d.ts} +1 -1
  54. package/dist/{stream.js → tts/stream.js} +5 -8
  55. package/dist/{transport.d.ts → tts/transport.d.ts} +3 -11
  56. package/dist/tts/transport.js +116 -0
  57. package/dist/validation.d.ts +5 -0
  58. package/dist/validation.js +28 -0
  59. package/docs/realtime.md +220 -0
  60. package/docs/stt.md +103 -0
  61. package/docs/tts.md +139 -0
  62. package/package.json +14 -6
  63. package/dist/policy.js +0 -73
  64. /package/dist/{audio.d.ts → tts/audio.d.ts} +0 -0
  65. /package/dist/{queue.d.ts → tts/queue.d.ts} +0 -0
  66. /package/dist/{queue.js → tts/queue.js} +0 -0
  67. /package/dist/{sentences.d.ts → tts/sentences.d.ts} +0 -0
package/dist/policy.js DELETED
@@ -1,73 +0,0 @@
1
- import { RimeInputError } from "./errors.js";
2
- export const policy = {
3
- target: "coda.api.rime.ai:443",
4
- audience: "coda.api.rime.ai",
5
- exchangeUrl: "https://themis.api.rime.ai/v1/token",
6
- sentenceBytes: 65536,
7
- sourceChars: 1024,
8
- outputBytes: 96000,
9
- outputChunkBytes: 9600,
10
- receiveBytes: 4194304,
11
- authTimeout: 10,
12
- connectionTimeout: 10,
13
- firstAudioTimeout: 30,
14
- progressTimeout: 60,
15
- discoveryTimeout: 10,
16
- cleanupTimeout: 2,
17
- };
18
- export function resolve(model, endpoint) {
19
- // Add model defaults here only when its transport contract is supported.
20
- if (model !== "coda")
21
- throw new RimeInputError("This SDK supports model='coda'");
22
- if (endpoint === undefined || endpoint === null)
23
- return { ...policy };
24
- const error = "endpoint must be a hostname with an optional port (1-65535), without a scheme or path";
25
- if (typeof endpoint !== "string" || /\s/.test(endpoint))
26
- throw new RimeInputError(error);
27
- const [host, port, extra] = endpoint.split(":");
28
- if (!host ||
29
- host.length > 253 ||
30
- extra !== undefined ||
31
- host
32
- .split(".")
33
- .some((label) => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(label)) ||
34
- (port !== undefined &&
35
- (!/^[0-9]{1,5}$/.test(port) || Number(port) < 1 || Number(port) > 65535)))
36
- throw new RimeInputError(error);
37
- return {
38
- ...policy,
39
- target: `${host.toLowerCase()}:${port === undefined ? 443 : Number(port)}`,
40
- audience: host.toLowerCase(),
41
- };
42
- }
43
- export function timeout(value, inherited = null) {
44
- if (value === undefined)
45
- return inherited;
46
- if (value !== null &&
47
- (typeof value !== "number" || !Number.isFinite(value) || value <= 0))
48
- throw new RimeInputError("timeout must be finite positive seconds or null");
49
- return value;
50
- }
51
- export function nonempty(value, name) {
52
- if (typeof value !== "string" || !value.trim())
53
- throw new RimeInputError(`${name} must be a non-empty string`);
54
- return value;
55
- }
56
- export function abortable(promise, signal) {
57
- if (signal.aborted)
58
- return Promise.reject(signal.reason);
59
- return new Promise((resolve, reject) => {
60
- const abort = () => {
61
- signal.removeEventListener("abort", abort);
62
- reject(signal.reason);
63
- };
64
- signal.addEventListener("abort", abort, { once: true });
65
- Promise.resolve(promise).then((value) => {
66
- signal.removeEventListener("abort", abort);
67
- resolve(value);
68
- }, (error) => {
69
- signal.removeEventListener("abort", abort);
70
- reject(error);
71
- });
72
- });
73
- }
File without changes
File without changes
File without changes
File without changes