# rev_ai

> Unofficial Rev AI Node.js client

Latest version **0.5.1** (published 2018-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install rev_ai
pnpm add rev_ai
yarn add rev_ai
bun add rev_ai
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2018-11-12 |
| First published | 2018-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 52.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Phong Vu |
| Maintainers | pacovu |
| Keywords | speech recogition, transcription, text to speech |

## Links

- npm: https://www.npmjs.com/package/rev_ai
- Repository: https://github.com/PacoVu/rev_ai
- Homepage: https://github.com/PacoVu/rev_ai#readme
- Issues: https://github.com/PacoVu/rev_ai/issues
- npm.io page: https://npm.io/package/rev_ai

## Recent versions

- 0.5.1 (latest) — 2018-11-12

## README

## Node JS client library for REV AI
Provides functions to access Rev AI APIs [http://rev.ai](http://rev.ai).

## What is Rev AI?
* Speech to Text service


### Installation
To install, run the following command:
```
npm install rev_ai --save
```
If you want to install the latest module directly from Github, use the following command:
```
npm install git+https://github.com/PacoVu/rev_ai
```

### Include it
```js
var revai = require('rev_ai')
var client = new revai.REVAIClient(rev-ai-apikey, version, proxy)
```
You can find your API key [here](https://www.rev.ai/settings) after logging in your account.

`version` Optional parameter (defaults to `'v1beta'`).

`proxy` Optional parameter. Set a proxy if you're behind a firewall. Here is an example of initiating the client if you're using proxy:
```js
var revai = require('rev_ai')
var client = new revai.REVAIClient(rev-ai-apikey, 'v1beta', 'http://user:pass@proxy.server.com:3128')
```
### Call Rev AI endpoints
```js
// Get account info
client.account(function(err,resp,body){
  console.log(body.balance_seconds/60)
})

// Transcribe an audio file from local storage
var params = {
  media: "sample1.mp3",
  metadata: "This is a sample file from local storage"
}
client.transcribe(params, function(err,resp,body){
  console.log(body)
})

// Transcribe an audio file from url
var params = {
  media_url: "http://www.somewhere.com/audio.mp3",
  metadata: "This is a sample file from a remote url"
}
client.transcribe(params, function(err,resp,body){
  console.log(body)
})

// Get transcription jobs
client.getJobs(params, function(err,res,body){
  for (var job of body){
    console.log(job.status)
    console.log(job.id)
    console.log(job.completed_on)
  }
})

// Get a transcription job by job ID
var jobId=12261294
client.getJobById(jobId, function(err,res,body){
  console.log(body)
  if (body.status == "transcribed"){
    // call getTranscription to get the transcription
    // client.getTranscription(body.id, callback)
  }
})

// Get getTranscription
var callback = function(err,resp,body){
  var json = JSON.parse(body)
  var transcript = ""
  for (var item of json.monologues){
    for (var element of item.elements){
      transcript += element.value
    }
  }
  console.log("TRANSCRIPT: " + transcript)
}
client.getTranscription(body.id, callback)
```

### Use POST request
```js
// Transcribe an audio file from local storage
var params = {
  media: "sample1.mp3",
  metadata: "This is a sample file from local storage"
}
client.post('jobs', params, function(err,resp,body){
  console.log(body)
})

// Transcribe an audio file from url
var params = {
  media_url: "http://www.somewhere.com/audio.mp3",
  metadata: "This is a sample file from a remote url"
}
client.post('jobs', params, function(err,resp,body){
  console.log(body)
})
```

### Use GET request
```js
// Get account info
client.get("account", {}, function(err,resp,body){
  console.log(body)
})

// Get a transcription job by job ID
var jobId=12261294
var query = 'jobs/' + jobId
client.get(query, {}, function(err,resp,body){
  console.log(body.status)
  console.log(body.id)
  console.log(body.completed_on)
})

// Get transcription jobs
var params = {
  limit: 2
}
client.get(params, function(err,res,body){
  for (var job of body){
    console.log(job.status)
    console.log(job.id)
    console.log(job.completed_on)
  }
})

// Get get transcription
var jobId=12261294
var query = 'jobs/' + jobId +"/transcript"
client.get(query, "", function(err,resp,body){
  if (!err){
    var json = JSON.parse(body)
    var transcript = ""
    for (var item of json.monologues){
      for (var element of item.elements){
        transcript += element.value
      }
    }
    console.log("TRANSCRIPT: " + transcript)
  }
})
```

---
_Source: https://npm.io/package/rev_ai · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
