New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

assemblyai

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assemblyai - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0-beta

dist/index.d.ts

76

package.json
{
"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"
}
}

@@ -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
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc