phonic 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -56,7 +56,6 @@ const { data, error } = await phonic.tts.websocket();
56
56
  if (error === null) {
57
57
  const { phonicWebSocket } = data;
58
58
  const stream = phonicWebSocket.send({
59
- type: "generate",
60
59
  script: "How can I help you today?", // 600 characters max
61
60
  output_format: "mulaw_8000", // or "pcm_44100"
62
61
  });
@@ -83,7 +82,6 @@ phonicWebSocket.onMessage((data) => {
83
82
  });
84
83
 
85
84
  phonicWebSocket.send({
86
- type: "generate",
87
85
  script: "How can I help you today?",
88
86
  output_format: "mulaw_8000",
89
87
  });
package/dist/index.d.mts CHANGED
@@ -1,8 +1,7 @@
1
1
  import WebSocket from 'ws';
2
2
 
3
- type PhonicConfigBaseUrl = `http://${string}` | `https://${string}`;
4
3
  type PhonicConfig = {
5
- baseUrl?: PhonicConfigBaseUrl;
4
+ baseUrl?: string;
6
5
  };
7
6
  type FetchOptions = {
8
7
  method: "GET";
@@ -20,7 +19,6 @@ type DataOrError<T> = Promise<{
20
19
  }>;
21
20
 
22
21
  type PhonicWebSocketMessage = {
23
- type: "generate";
24
22
  script: string;
25
23
  output_format: "pcm_44100" | "mulaw_8000";
26
24
  };
@@ -30,6 +28,10 @@ type PhonicWebSocketResponseMessage = {
30
28
  message: string;
31
29
  code?: string;
32
30
  };
31
+ paramErrors?: {
32
+ script?: string;
33
+ output_format?: string;
34
+ };
33
35
  };
34
36
  type OnMessageCallback = (data: PhonicWebSocketResponseMessage | Buffer) => void;
35
37
 
@@ -41,7 +43,7 @@ declare class PhonicWebSocket {
41
43
  private streamController;
42
44
  constructor(ws: WebSocket);
43
45
  onMessage(callback: OnMessageCallback): void;
44
- send(message: PhonicWebSocketMessage): ReadableStream<any>;
46
+ send(message: PhonicWebSocketMessage): ReadableStream<PhonicWebSocketResponseMessage | Buffer>;
45
47
  close(): void;
46
48
  }
47
49
 
@@ -88,4 +90,4 @@ declare class Phonic {
88
90
  }>;
89
91
  }
90
92
 
91
- export { Phonic };
93
+ export { Phonic, PhonicWebSocket };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import WebSocket from 'ws';
2
2
 
3
- type PhonicConfigBaseUrl = `http://${string}` | `https://${string}`;
4
3
  type PhonicConfig = {
5
- baseUrl?: PhonicConfigBaseUrl;
4
+ baseUrl?: string;
6
5
  };
7
6
  type FetchOptions = {
8
7
  method: "GET";
@@ -20,7 +19,6 @@ type DataOrError<T> = Promise<{
20
19
  }>;
21
20
 
22
21
  type PhonicWebSocketMessage = {
23
- type: "generate";
24
22
  script: string;
25
23
  output_format: "pcm_44100" | "mulaw_8000";
26
24
  };
@@ -30,6 +28,10 @@ type PhonicWebSocketResponseMessage = {
30
28
  message: string;
31
29
  code?: string;
32
30
  };
31
+ paramErrors?: {
32
+ script?: string;
33
+ output_format?: string;
34
+ };
33
35
  };
34
36
  type OnMessageCallback = (data: PhonicWebSocketResponseMessage | Buffer) => void;
35
37
 
@@ -41,7 +43,7 @@ declare class PhonicWebSocket {
41
43
  private streamController;
42
44
  constructor(ws: WebSocket);
43
45
  onMessage(callback: OnMessageCallback): void;
44
- send(message: PhonicWebSocketMessage): ReadableStream<any>;
46
+ send(message: PhonicWebSocketMessage): ReadableStream<PhonicWebSocketResponseMessage | Buffer>;
45
47
  close(): void;
46
48
  }
47
49
 
@@ -88,4 +90,4 @@ declare class Phonic {
88
90
  }>;
89
91
  }
90
92
 
91
- export { Phonic };
93
+ export { Phonic, PhonicWebSocket };
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ __export(src_exports, {
35
35
  module.exports = __toCommonJS(src_exports);
36
36
 
37
37
  // package.json
38
- var version = "0.1.0";
38
+ var version = "0.1.2";
39
39
 
40
40
  // src/tts/index.ts
41
41
  var import_ws = __toESM(require("ws"));
@@ -95,7 +95,7 @@ var TextToSpeech = class {
95
95
  async websocket() {
96
96
  return new Promise((resolve) => {
97
97
  const wsBaseUrl = this.phonic.baseUrl.replace(/^http/, "ws");
98
- const ws = new import_ws.default(`${wsBaseUrl}/v1/generate/audio/ws`, {
98
+ const ws = new import_ws.default(`${wsBaseUrl}/v1/tts/ws`, {
99
99
  headers: {
100
100
  Authorization: `Bearer ${this.phonic.apiKey}`
101
101
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.1.0";
2
+ var version = "0.1.2";
3
3
 
4
4
  // src/tts/index.ts
5
5
  import WebSocket from "ws";
@@ -59,7 +59,7 @@ var TextToSpeech = class {
59
59
  async websocket() {
60
60
  return new Promise((resolve) => {
61
61
  const wsBaseUrl = this.phonic.baseUrl.replace(/^http/, "ws");
62
- const ws = new WebSocket(`${wsBaseUrl}/v1/generate/audio/ws`, {
62
+ const ws = new WebSocket(`${wsBaseUrl}/v1/tts/ws`, {
63
63
  headers: {
64
64
  Authorization: `Bearer ${this.phonic.apiKey}`
65
65
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Phonic Node.js SDK",
5
5
  "scripts": {
6
6
  "build": "tsup",
7
7
  "check": "biome check --write",
8
8
  "ci": "bun tsc && biome ci && bun test",
9
+ "version": "changeset version && bun check",
9
10
  "release": "bun run build && changeset publish"
10
11
  },
11
12
  "main": "./dist/index.js",
@@ -36,7 +37,7 @@
36
37
  },
37
38
  "devDependencies": {
38
39
  "@biomejs/biome": "1.9.4",
39
- "@changesets/cli": "2.27.9",
40
+ "@changesets/cli": "2.27.10",
40
41
  "@types/bun": "1.1.13",
41
42
  "tsup": "8.3.5",
42
43
  "typescript": "5.6.3",