@charivo/stt 0.7.5 → 0.7.7
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/remote/index.js +5 -25
- package/dist/remote/index.mjs +6 -26
- package/package.json +2 -2
package/dist/remote/index.js
CHANGED
|
@@ -97,7 +97,6 @@ var MediaRecorderHelper = class {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
// src/remote/index.ts
|
|
100
|
-
var REQUEST_TIMEOUT_MS = 3e4;
|
|
101
100
|
var RemoteSTTTranscriber = class {
|
|
102
101
|
apiEndpoint;
|
|
103
102
|
recorder;
|
|
@@ -123,13 +122,16 @@ var RemoteSTTTranscriber = class {
|
|
|
123
122
|
if (this.recordingOptions?.language) {
|
|
124
123
|
formData.append("language", this.recordingOptions.language);
|
|
125
124
|
}
|
|
126
|
-
const response = await fetchWithTimeout(
|
|
125
|
+
const response = await (0, import_core.fetchWithTimeout)(
|
|
127
126
|
this.apiEndpoint,
|
|
128
127
|
{
|
|
129
128
|
method: "POST",
|
|
130
129
|
body: formData
|
|
131
130
|
},
|
|
132
|
-
|
|
131
|
+
{
|
|
132
|
+
timeoutMessage: `STT request timed out after ${import_core.DEFAULT_FETCH_TIMEOUT_MS}ms`,
|
|
133
|
+
failureMessage: "STT request failed"
|
|
134
|
+
}
|
|
133
135
|
);
|
|
134
136
|
if (!response.ok) {
|
|
135
137
|
throw new import_core.CharivoProviderError(`STT API failed: ${response.statusText}`);
|
|
@@ -148,28 +150,6 @@ var RemoteSTTTranscriber = class {
|
|
|
148
150
|
function createRemoteSTTTranscriber(config) {
|
|
149
151
|
return new RemoteSTTTranscriber(config);
|
|
150
152
|
}
|
|
151
|
-
async function fetchWithTimeout(input, init, timeoutMessage) {
|
|
152
|
-
const controller = new AbortController();
|
|
153
|
-
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
154
|
-
try {
|
|
155
|
-
return await fetch(input, {
|
|
156
|
-
...init,
|
|
157
|
-
signal: controller.signal
|
|
158
|
-
});
|
|
159
|
-
} catch (error) {
|
|
160
|
-
if (isAbortError(error)) {
|
|
161
|
-
throw new import_core.CharivoTimeoutError(timeoutMessage, { cause: error });
|
|
162
|
-
}
|
|
163
|
-
throw new import_core.CharivoTransportError("STT request failed", {
|
|
164
|
-
cause: error instanceof Error ? error : void 0
|
|
165
|
-
});
|
|
166
|
-
} finally {
|
|
167
|
-
clearTimeout(timeoutId);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function isAbortError(error) {
|
|
171
|
-
return error instanceof DOMException && error.name === "AbortError" || error instanceof Error && error.name === "AbortError";
|
|
172
|
-
}
|
|
173
153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
174
154
|
0 && (module.exports = {
|
|
175
155
|
createRemoteSTTTranscriber
|
package/dist/remote/index.mjs
CHANGED
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
// src/remote/index.ts
|
|
6
6
|
import {
|
|
7
7
|
CharivoProviderError,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
DEFAULT_FETCH_TIMEOUT_MS,
|
|
9
|
+
fetchWithTimeout
|
|
10
10
|
} from "@charivo/core";
|
|
11
|
-
var REQUEST_TIMEOUT_MS = 3e4;
|
|
12
11
|
var RemoteSTTTranscriber = class {
|
|
13
12
|
apiEndpoint;
|
|
14
13
|
recorder;
|
|
@@ -40,7 +39,10 @@ var RemoteSTTTranscriber = class {
|
|
|
40
39
|
method: "POST",
|
|
41
40
|
body: formData
|
|
42
41
|
},
|
|
43
|
-
|
|
42
|
+
{
|
|
43
|
+
timeoutMessage: `STT request timed out after ${DEFAULT_FETCH_TIMEOUT_MS}ms`,
|
|
44
|
+
failureMessage: "STT request failed"
|
|
45
|
+
}
|
|
44
46
|
);
|
|
45
47
|
if (!response.ok) {
|
|
46
48
|
throw new CharivoProviderError(`STT API failed: ${response.statusText}`);
|
|
@@ -59,28 +61,6 @@ var RemoteSTTTranscriber = class {
|
|
|
59
61
|
function createRemoteSTTTranscriber(config) {
|
|
60
62
|
return new RemoteSTTTranscriber(config);
|
|
61
63
|
}
|
|
62
|
-
async function fetchWithTimeout(input, init, timeoutMessage) {
|
|
63
|
-
const controller = new AbortController();
|
|
64
|
-
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
65
|
-
try {
|
|
66
|
-
return await fetch(input, {
|
|
67
|
-
...init,
|
|
68
|
-
signal: controller.signal
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if (isAbortError(error)) {
|
|
72
|
-
throw new CharivoTimeoutError(timeoutMessage, { cause: error });
|
|
73
|
-
}
|
|
74
|
-
throw new CharivoTransportError("STT request failed", {
|
|
75
|
-
cause: error instanceof Error ? error : void 0
|
|
76
|
-
});
|
|
77
|
-
} finally {
|
|
78
|
-
clearTimeout(timeoutId);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function isAbortError(error) {
|
|
82
|
-
return error instanceof DOMException && error.name === "AbortError" || error instanceof Error && error.name === "AbortError";
|
|
83
|
-
}
|
|
84
64
|
export {
|
|
85
65
|
createRemoteSTTTranscriber
|
|
86
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charivo/stt",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "STT manager and browser adapters for Charivo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"openai": "^4.47.1",
|
|
44
|
-
"@charivo/core": "^0.
|
|
44
|
+
"@charivo/core": "^0.27.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"tsup": "^8.5.0",
|