assemblyai 4.4.2 → 4.4.3

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/CHANGELOG.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## [4.4.2]
3
+ ## [4.4.3] - 2024-05-09
4
+
5
+ - Add react-native exports that resolve to the browser version of the library.
6
+
7
+ ## [4.4.2] - 2024-05-03
4
8
 
5
9
  ### Changed
6
10
 
7
11
  - Caching is disabled for all HTTP request made by the SDK
12
+ - Accept data-URIs in `client.files.upload(dataUri)`, `client.transcripts.submit(audio: dataUri)`, `client.transcripts.transcribe(audio: dataUri)`.
8
13
  - Change how the WebSocket libraries are imported for better compatibility across frameworks and runtimes.
9
14
  The library no longer relies on a internal `#ws` import, and instead compiles the imports into the dist bundles.
10
15
  Browser builds will use the native `WebSocket`, other builds will use the `ws` package.
package/README.md CHANGED
@@ -53,6 +53,30 @@ const client = new AssemblyAI({
53
53
 
54
54
  You can now use the `client` object to interact with the AssemblyAI API.
55
55
 
56
+ ### Using a CDN
57
+
58
+ You can use automatic CDNs like [UNPKG](https://unpkg.com/) to load the library from a script tag.
59
+
60
+ - Replace `:version` with the desired version or `latest`.
61
+ - Remove `.min` to load the non-minified version.
62
+
63
+ ```html
64
+ <script src="https://www.unpkg.com/assemblyai@:version/dist/assemblyai.umd.min.js"></script>
65
+ ```
66
+
67
+ The script creates a global `assemblyai` variable containing all the services.
68
+ Here's how you create a `RealtimeTranscriber` object.
69
+
70
+ ```js
71
+ const { RealtimeTranscriber } = assemblyai;
72
+ const transcriber = new RealtimeTranscriber({
73
+ token: "[GENERATE TEMPORARY AUTH TOKEN IN YOUR API]",
74
+ ...
75
+ });
76
+ ```
77
+
78
+ For type support in your IDE, see [Reference types from JavaScript](./docs/reference-types-from-js.md).
79
+
56
80
  ## Speech-To-Text
57
81
 
58
82
  ### Transcribe audio and video files
@@ -227,18 +251,26 @@ const rt = client.realtime.transcriber({
227
251
  });
228
252
  ```
229
253
 
230
- You can also generate a temporary auth token for real-time.
231
-
232
- ```typescript
233
- const token = await client.realtime.createTemporaryToken({ expires_in = 60 });
234
- const rt = client.realtime.transcriber({
235
- token: token,
236
- });
237
- ```
238
-
239
254
  > [!WARNING]
240
255
  > Storing your API key in client-facing applications exposes your API key.
241
256
  > Generate a temporary auth token on the server and pass it to your client.
257
+ > _Server code_:
258
+ >
259
+ > ```typescript
260
+ > const token = await client.realtime.createTemporaryToken({ expires_in = 60 });
261
+ > // TODO: return token to client
262
+ > ```
263
+ >
264
+ > _Client code_:
265
+ >
266
+ > ```typescript
267
+ > import { RealtimeTranscriber } from "assemblyai";
268
+ > // TODO: implement getToken to retrieve token from server
269
+ > const token = await getToken();
270
+ > const rt = new RealtimeTranscriber({
271
+ > token,
272
+ > });
273
+ > ```
242
274
 
243
275
  You can configure the following events.
244
276
 
@@ -344,3 +376,7 @@ const response = await client.lemur.purgeRequestData(lemurResponse.request_id);
344
376
  ```
345
377
 
346
378
  </details>
379
+
380
+ ## Contributing
381
+
382
+ If you want to contribute to the JavaScript SDK, follow the guidelines in [CONTRIBUTING.md](./CONTRIBUTING.md).
@@ -0,0 +1,27 @@
1
+ # Reference types from JavaScript
2
+
3
+ Types are automatically configured in most IDEs when you import the `assemblyai` module using `require` or `import`.
4
+ However, if you're using the _assemblyai.umd.js_ or _assemblyai.umd.min.js_ script,
5
+ you need to manually reference the types.
6
+
7
+ 1. Install the `assemblyai` module locally.
8
+ 2. Create an _assemblyai.d.ts_ file with the following content.
9
+ ```typescript
10
+ import AssemblyAIModule from "assemblyai";
11
+ declare global {
12
+ const assemblyai: typeof AssemblyAIModule;
13
+ }
14
+ ```
15
+ This will import the TypeScript types from the `assemblyai` module,
16
+ and configure them as the global `assemblyai` variable.
17
+ 3. Reference the _assemblyai.d.ts_ file at the top of your script file.
18
+
19
+ ```js
20
+ /// <reference path="assemblyai.d.ts" />
21
+ const { RealtimeTranscriber } = assemblyai;
22
+ ...
23
+ ```
24
+
25
+ Your IDE will load the types specified in the `<reference />` tag.
26
+
27
+ > [!INFO] > `/// <reference />` tags only work in script files, not script-blocks, and should be at the top of the file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
4
4
  "description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "workerd": "./dist/index.mjs",
20
20
  "browser": "./dist/browser.mjs",
21
+ "react-native": "./dist/browser.mjs",
21
22
  "node": {
22
23
  "types": "./dist/index.d.ts",
23
24
  "import": "./dist/node.mjs",
@@ -47,6 +48,8 @@
47
48
  }
48
49
  },
49
50
  "type": "commonjs",
51
+ "react-native": "./dist/browser.mjs",
52
+ "browser": "./dist/browser.mjs",
50
53
  "main": "./dist/index.cjs",
51
54
  "require": "./dist/index.cjs",
52
55
  "module": "./dist/index.mjs",
@@ -68,7 +71,7 @@
68
71
  "test": "pnpm run test:unit && pnpm run test:integration",
69
72
  "test:unit": "jest --config jest.unit.config.js --testTimeout 1000",
70
73
  "test:integration": "jest --config jest.integration.config.js --testTimeout 360000",
71
- "format": "prettier '**/*' --write",
74
+ "format": "prettier {*,**/*} --write --no-error-on-unmatched-pattern",
72
75
  "generate:types": "tsx ./scripts/generate-types.ts && prettier 'src/types/*.generated.ts' --write",
73
76
  "generate:reference": "typedoc",
74
77
  "copybara:dry-run": "./copybara.sh dry_run --init-history",
@@ -97,16 +100,16 @@
97
100
  "docs"
98
101
  ],
99
102
  "devDependencies": {
100
- "@babel/preset-env": "^7.24.0",
101
- "@babel/preset-typescript": "^7.23.3",
103
+ "@babel/preset-env": "^7.24.5",
104
+ "@babel/preset-typescript": "^7.24.1",
102
105
  "@rollup/plugin-node-resolve": "^15.2.3",
103
106
  "@rollup/plugin-terser": "^0.4.4",
104
107
  "@rollup/plugin-typescript": "^11.1.6",
105
108
  "@types/jest": "^29.5.12",
106
- "@types/node": "^18.11.9",
109
+ "@types/node": "^18.19.32",
107
110
  "@types/websocket": "^1.0.10",
108
111
  "@types/ws": "^8.5.10",
109
- "@typescript-eslint/eslint-plugin": "^7.2.0",
112
+ "@typescript-eslint/eslint-plugin": "^7.8.0",
110
113
  "dotenv": "^16.4.5",
111
114
  "eslint": "^8.57.0",
112
115
  "eslint-plugin-tsdoc": "^0.2.17",
@@ -120,14 +123,14 @@
120
123
  "prettier": "^3.2.5",
121
124
  "publint": "^0.2.7",
122
125
  "rimraf": "^5.0.5",
123
- "rollup": "^4.13.0",
126
+ "rollup": "^4.17.2",
124
127
  "ts-jest": "^29.1.2",
125
128
  "tslib": "^2.5.3",
126
- "typescript": "^5.4.2",
127
- "typedoc": "^0.25.12",
128
- "typedoc-plugin-extras": "^3.0.0"
129
+ "typedoc": "^0.25.13",
130
+ "typedoc-plugin-extras": "^3.0.0",
131
+ "typescript": "^5.4.5"
129
132
  },
130
133
  "dependencies": {
131
- "ws": "^8.16.0"
134
+ "ws": "^8.17.0"
132
135
  }
133
136
  }