# witspeech

> Constructs a network request for Wit.ai's speech API.

Latest version **0.0.1** (published 2018-01-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2018-01-09 |
| First published | 2018-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ron Dekker |
| Maintainers | redkenrok |
| Keywords | wit, wit, speech, recognition, natural, language, processing |

## Links

- npm: https://www.npmjs.com/package/witspeech
- Repository: https://github.com/RedKenrok/node-witspeech
- Homepage: https://github.com/RedKenrok/node-witspeech#readme
- Issues: https://github.com/RedKenrok/node-witspeech/issues
- npm.io page: https://npm.io/package/witspeech

## Recent versions

- 0.0.1 (latest) — 2018-01-09

## README

# Wit speech
Makes network request to [Wit.ai](https://wit.ai)'s speech API. For more information about the API see the [official documentation](https://wit.ai/docs/http/20170307#post--speech-link).

## Installation
```
npm install --save witspeech
```

## Usage

### Constructor
```javascript
// Import module.
const WitSpeech = require('witspeech');
// Create an instance.
const witSpeech = new WitSpeech('WIT_TOKEN', '20171207');
```

> Replace WIT_TOKEN with your token retrieved from the [wit.ai](https://wit.ai) website.

### Methods
```javascript
// The type of content that you will stream.
let contentType = 'audio/wav';
// Additional and optional web request parameters.
let queryParameters = {};
// Callback function with the response.
let callback = function(error, response) {
  if (error) {
    console.error('ERROR', error);
    return;
  }
  console.log(JSON.parse(response));
};

// Retrieves the web request to pipe information to.
witSpeech.request(
  contentType,
  queryParameters,
  callback
);
```

> To see what content types you can send over see [the official documentation](https://wit.ai/docs/http/20170307#post--speech-link).

### Example

#### From file

```javascript
// Import node module.
const fs = require('fs');

// Initialize module, see constructor section for more information.
const WitSpeech = require('witspeech');
const witSpeech = new WitSpeech('WIT_TOKEN', '20171207');

// Create request, see methods section for more information.
let request = witSpeech.request('audio/wav', {}, function(error, response) {
  if (error) {
    console.error('ERROR', error);
    return;
  }
  console.log(JSON.parse(response));
});

// Create read file stream.
let stream = fs.createReadStream('audio.wav');
// Pipe the stream to the request.
stream.pipe(request);
```

#### From microphone

```javascript
// Initialize module, see constructor section for more information.
const WitSpeech = require('witspeech');
const witSpeech = new WitSpeech('WIT_TOKEN', '20171207');

// Import audio recorder
const AudioRecorder = require('node-audiorecorder');
const audioRecorder = new AudioRecorder();

// Create request, see methods section for more information.
let request = witSpeech.request('audio/wav', {}, function(error, response) {
  if (error) {
    console.error('ERROR', error);
    return;
  }
  console.log(JSON.parse(response));
});

// Start audio recorder.
audioRecorder.start();
// Get microphone stream.
let stream = audioRecorder.stream();
// Pipe the stream to the request.
stream.pipe(request);
```

> For the audio recorder see the [package](https://npmjs.org/package/node-audiorecorder) or [repository](https://github.com/RedKenrok/Node-AudioRecorder) for it.

> For another example see the [Electron-VoiceInterfacePrototype](https://github.com/RedKenrok/Electron-VoiceInterfacePrototype)'s input.js.

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