@charivo/stt 0.9.0 → 0.10.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.
@@ -122,7 +122,7 @@ var RemoteSTTTranscriber = class {
122
122
  if (this.recordingOptions?.language) {
123
123
  formData.append("language", this.recordingOptions.language);
124
124
  }
125
- const response = await (0, import_core.fetchWithTimeout)(
125
+ const transcription = await (0, import_core.fetchWithTimeout)(
126
126
  this.apiEndpoint,
127
127
  {
128
128
  method: "POST",
@@ -131,14 +131,22 @@ var RemoteSTTTranscriber = class {
131
131
  {
132
132
  timeoutMessage: `STT request timed out after ${import_core.DEFAULT_FETCH_TIMEOUT_MS}ms`,
133
133
  failureMessage: "STT request failed"
134
+ },
135
+ // Consume the body while cancellation is still wired up, so a route that
136
+ // sends headers and then stalls -- on the error path too, where the
137
+ // message is read off the body -- still hits the deadline.
138
+ async (response) => {
139
+ if (!response.ok) {
140
+ throw new import_core.CharivoProviderError(
141
+ `STT API failed: ${await (0, import_core.readResponseErrorMessage)(response)}`
142
+ );
143
+ }
144
+ const data = await response.json();
145
+ return data.transcription;
134
146
  }
135
147
  );
136
- if (!response.ok) {
137
- throw new import_core.CharivoProviderError(`STT API failed: ${response.statusText}`);
138
- }
139
- const data = await response.json();
140
148
  this.recordingOptions = void 0;
141
- return data.transcription;
149
+ return transcription;
142
150
  }
143
151
  /**
144
152
  * Check if currently recording
@@ -6,7 +6,8 @@ import {
6
6
  import {
7
7
  CharivoProviderError,
8
8
  DEFAULT_FETCH_TIMEOUT_MS,
9
- fetchWithTimeout
9
+ fetchWithTimeout,
10
+ readResponseErrorMessage
10
11
  } from "@charivo/core";
11
12
  var RemoteSTTTranscriber = class {
12
13
  apiEndpoint;
@@ -33,7 +34,7 @@ var RemoteSTTTranscriber = class {
33
34
  if (this.recordingOptions?.language) {
34
35
  formData.append("language", this.recordingOptions.language);
35
36
  }
36
- const response = await fetchWithTimeout(
37
+ const transcription = await fetchWithTimeout(
37
38
  this.apiEndpoint,
38
39
  {
39
40
  method: "POST",
@@ -42,14 +43,22 @@ var RemoteSTTTranscriber = class {
42
43
  {
43
44
  timeoutMessage: `STT request timed out after ${DEFAULT_FETCH_TIMEOUT_MS}ms`,
44
45
  failureMessage: "STT request failed"
46
+ },
47
+ // Consume the body while cancellation is still wired up, so a route that
48
+ // sends headers and then stalls -- on the error path too, where the
49
+ // message is read off the body -- still hits the deadline.
50
+ async (response) => {
51
+ if (!response.ok) {
52
+ throw new CharivoProviderError(
53
+ `STT API failed: ${await readResponseErrorMessage(response)}`
54
+ );
55
+ }
56
+ const data = await response.json();
57
+ return data.transcription;
45
58
  }
46
59
  );
47
- if (!response.ok) {
48
- throw new CharivoProviderError(`STT API failed: ${response.statusText}`);
49
- }
50
- const data = await response.json();
51
60
  this.recordingOptions = void 0;
52
- return data.transcription;
61
+ return transcription;
53
62
  }
54
63
  /**
55
64
  * Check if currently recording
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charivo/stt",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "STT manager and browser adapters for Charivo",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,6 +26,11 @@
26
26
  "import": "./dist/gemini/index.mjs",
27
27
  "require": "./dist/gemini/index.js"
28
28
  },
29
+ "./gemini-live": {
30
+ "types": "./dist/gemini-live/index.d.ts",
31
+ "import": "./dist/gemini-live/index.mjs",
32
+ "require": "./dist/gemini-live/index.js"
33
+ },
29
34
  "./openai-realtime": {
30
35
  "types": "./dist/openai-realtime/index.d.ts",
31
36
  "import": "./dist/openai-realtime/index.mjs",
@@ -45,8 +50,8 @@
45
50
  "transcription"
46
51
  ],
47
52
  "dependencies": {
48
- "openai": "^4.47.1",
49
- "@charivo/core": "^0.33.0"
53
+ "@charivo/core": "^0.34.0",
54
+ "openai": "^4.47.1"
50
55
  },
51
56
  "devDependencies": {
52
57
  "tsup": "^8.5.0",