@charivo/stt 0.9.0 → 0.9.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.
- package/dist/remote/index.js +14 -6
- package/dist/remote/index.mjs +16 -7
- package/package.json +3 -3
package/dist/remote/index.js
CHANGED
|
@@ -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
|
|
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
|
|
149
|
+
return transcription;
|
|
142
150
|
}
|
|
143
151
|
/**
|
|
144
152
|
* Check if currently recording
|
package/dist/remote/index.mjs
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "STT manager and browser adapters for Charivo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"transcription"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"@charivo/core": "^0.34.0",
|
|
49
|
+
"openai": "^4.47.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsup": "^8.5.0",
|