assemblyai
Advanced tools
Comparing version 1.0.1 to 2.0.0-beta
{ | ||
"name": "assemblyai", | ||
"version": "1.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"version": "2.0.0-beta", | ||
"description": "The AssemblyAI Node.js 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.", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts", | ||
"typings": "dist/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/AssemblyAI/assemblyai-node-sdk.git" | ||
"url": "git+https://github.com/AssemblyAI/assemblyai-typescript-sdk.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/AssemblyAI/assemblyai-node-sdk/issues" | ||
"publishConfig": { | ||
"tag": "beta", | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"homepage": "https://github.com/AssemblyAI/assemblyai-node-sdk#readme", | ||
"dependencies": { | ||
"request": "^2.88.0" | ||
"scripts": { | ||
"build": "pnpm clean && pnpm rollup -c", | ||
"clean": "rimraf dist", | ||
"lint": "tslint -p tsconfig.json", | ||
"test": "pnpm lint && pnpm test:unit", | ||
"test:unit": "jest --config jest.config.rollup.ts", | ||
"prettier": "prettier --write 'src/**/*.ts'" | ||
}, | ||
"keywords": [ | ||
"AssemblyAI", | ||
"Speech-to-text" | ||
], | ||
"author": "AssemblyAI (https://www.assemblyai.com)", | ||
"license": "MIT", | ||
"homepage": "https://www.assemblyai.com/docs", | ||
"files": [ | ||
"dist", | ||
"src", | ||
"types" | ||
], | ||
"devDependencies": { | ||
"eslint": "^5.4.0", | ||
"eslint-config-standard": "^11.0.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-promise": "^4.0.0", | ||
"eslint-plugin-standard": "^3.1.0" | ||
"@types/jest": "^29.5.2", | ||
"@types/node": "^20.5.7", | ||
"@types/ws": "^8.5.5", | ||
"eslint": "^8.43.0", | ||
"i": "^0.3.7", | ||
"jest": "^29.5.0", | ||
"jest-cli": "^29.5.0", | ||
"jest-junit": "^16.0.0", | ||
"jest-mock-extended": "^3.0.4", | ||
"mock-socket": "^9.2.1", | ||
"npm": "^9.7.1", | ||
"prettier": "^2.8.8", | ||
"rimraf": "^5.0.1", | ||
"rollup": "^3.25.1", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.5.3", | ||
"tslint": "^6.1.3", | ||
"typescript": "^5.1.3", | ||
"jest-websocket-mock": "^2.4.1" | ||
}, | ||
"dependencies": { | ||
"axios": "^1.4.0", | ||
"ws": "^8.13.0" | ||
} | ||
} |
177
README.md
@@ -1,116 +0,125 @@ | ||
## Installing the module: | ||
# AssemblyAI Node.js SDK | ||
`npm i assemblyai` | ||
The AssemblyAI Node.js 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. | ||
## Authenticating with the API | ||
## Installation | ||
### Using Environment Variables | ||
Use [npm](https://www.npmjs.com/) to install AssemblyAI: | ||
If you have the `ASSEMBLYAI_API_KEY` environment variable set, then the application | ||
will attempt to read it and use this value to authenticate with the API. | ||
```bash | ||
npm install assemblyai | ||
``` | ||
### Setting the value manually | ||
# Usage | ||
Here is what the code would look like if you were to set the API token manually. | ||
Import the AssemblyAI package and create an AssemblyAI object with your API token: | ||
```javascript | ||
const assemblyai = require('assemblyai') | ||
assemblyai.setAPIKey("ENTER YOUR KEY HERE") | ||
import AssemblyAI from 'assemblyai' | ||
const assembly = new AssemblyAI({ | ||
token: process.env.ASSEMBLYAI_API_KEY, | ||
}) | ||
``` | ||
## Usage | ||
You can now use the `assembly` object to interact with the AssemblyAI API. | ||
### Initialization | ||
## Create a Transcript | ||
The initialization of the module of course has to be at the beginning of your project. | ||
When you create a transcript, you can either pass in a URL to an audio file, or upload a file directly. | ||
```javascript | ||
const assemblyai = require('assemblyai') | ||
assemblyai.setAPIKey("ENTER YOUR KEY HERE") | ||
// Using a remote URL | ||
const created = await assembly.transcripts.create({ | ||
audio_url: 'https://storage.googleapis.com/aai-web-samples/espn-bears.m4a', | ||
}) | ||
``` | ||
### Upload an audio file for transcription | ||
```javascript | ||
// Uploading a file | ||
const created = await assembly.transcripts.create({ | ||
audio_url: './news.mp4', | ||
}) | ||
``` | ||
## Retrieve a Transcript | ||
This will return the transcript object in its current state. If the transcript is still processing, the `status` field will be `queued` or `processing`. Once the transcript is complete, the `status` field will be `completed`. | ||
```javascript | ||
async function upload () { | ||
try { | ||
const transcript = new assemblyai.Upload('/path/to/audiofile.wav') | ||
const response = await transcript.create() | ||
const data = response.get() | ||
// do something with the JSON response | ||
console.log(data); | ||
} catch (e) { | ||
// Do some error handling here | ||
} | ||
} | ||
const transcript = await assembly.transcripts.retrieve(created.id) | ||
``` | ||
### Transcribe audio from a URL | ||
## Poll a Transcript | ||
The only required parameter is the `audio_src_url` parameter. For more information about transcribing audio, please see the full API documentation [here](https://docs.assemblyai.com/api/#posttranscript). | ||
This will poll the transcript until it is complete. Once the transcript is complete, the `status` field will be `completed`. | ||
```javascript | ||
async function transcribe () { | ||
try { | ||
const transcript = new assemblyai.Transcript() | ||
const response = await transcript.create({ | ||
audio_src_url: "https://example.com/example.wav", | ||
model_id: 123, | ||
options: { | ||
format_text: true || false | ||
} | ||
}) | ||
const { id } = response.get() | ||
const data = await transcript.poll(id) | ||
// do something with the response data. | ||
// `data` is a wrapper of the API's JSON | ||
// response. `data.get()` returns the JSON | ||
// response of the API | ||
var responseJson = data.get(); | ||
console.log(responseJson); | ||
} catch (e) { | ||
// Do some error handling here | ||
} | ||
} | ||
const transcript = await assembly.transcripts.poll({ | ||
transcript_id: created.id, | ||
}) | ||
``` | ||
### Create a custom model | ||
## List Transcripts | ||
Boost accuracy for keywords/phrases, and add custom terms to the vocabulary with a custom model. For more information, please see the full API documentation [here](https://docs.assemblyai.com/guides/custom_models_101/). | ||
This will return a list of all transcripts that you have created. | ||
```javascript | ||
async function model() { | ||
try { | ||
const instance = new assemblyai.Model() | ||
const response = await instance.create({ | ||
phrases: ['foo', 'bar'] | ||
}) | ||
const { id } = response.get() | ||
const data = await instance.poll(id) | ||
// do something with the response data. | ||
// `data` is a wrapper of the API's JSON | ||
// response. `data.get()` returns the JSON | ||
// response of the API | ||
var responseJson = data.get(); | ||
console.log(responseJson); | ||
} catch (e) { | ||
// Do some error handling | ||
} | ||
} | ||
const page = await assembly.transcripts.list() | ||
``` | ||
### The Response Object | ||
When using the `Response` object, you will find a couple of methods: | ||
## Delete a Transcript | ||
- `get()` | ||
- `toString()` | ||
- `stringify()` | ||
```javascript | ||
const res = await assembly.transcripts.delete(transcript.id) | ||
``` | ||
The method that you will most likely want to use will be `get()` which returns the full JSON object from the API, one level down. | ||
## LeMUR | ||
The SDK supports the latest LeMUR models. You can specify which model you would like to use when creating a transcript. | ||
```javascript | ||
// Ask a question about the transcript | ||
const { response } = await assembly.lemur.create({ | ||
type: 'question', | ||
model: 'basic', | ||
transcript_id: '0d295578-8c75-421a-885a-2c487f188927', | ||
questions: [ | ||
{ | ||
question: 'What are they discussing?', | ||
answer_format: 'text', | ||
}, | ||
], | ||
}) | ||
``` | ||
```javascript | ||
// Summarize the transcript | ||
const { response } = await assembly.lemur.create({ | ||
type: 'summary', | ||
model: 'basic', | ||
transcript_id: '0d295578-8c75-421a-885a-2c487f188927', | ||
context: { | ||
speakers: ['Alex', 'Bob'], | ||
}, | ||
}) | ||
``` | ||
```javascript | ||
// AI Coach | ||
const { response } = await assembly.lemur.create({ | ||
type: 'coach', | ||
model: 'basic', | ||
transcript_id: '0d295578-8c75-421a-885a-2c487f188927', | ||
}) | ||
``` | ||
# Tests | ||
To run the test suite, first install the dependencies, then run `npm test`: | ||
```bash | ||
npm install | ||
npm test | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
86094
72
2325
126
2
21
2
1
+ Addedaxios@^1.4.0
+ Addedws@^8.13.0
+ Addedaxios@1.7.9(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedes-set-tostringtag@2.1.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedws@8.18.0(transitive)
- Removedrequest@^2.88.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)