# voicer

> voicer - voice recognition AGI server for Asterisk

Latest version **0.2.2** (published 2019-09-19) · MIT license · 0 weekly downloads

## Install

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

Provides the command `voicer`.

## 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.2.2 |
| Published | 2019-09-19 |
| First published | 2015-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 44.5 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 100 |
| Author | Dmitriev Sergey |
| Maintainers | antirek |

## Links

- npm: https://www.npmjs.com/package/voicer
- Repository: https://github.com/antirek/voicer
- Issues: https://github.com/antirek/voicer/issues
- npm.io page: https://npm.io/package/voicer

## Dependencies (14)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [config](https://npm.io/package/config.md) ^3.0.1
- [tracer](https://npm.io/package/tracer.md) ^1.0.0
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.4
- [winston](https://npm.io/package/winston.md) ^0.9.0
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^15.1.1
- [auto-bind](https://npm.io/package/auto-bind.md) ^2.1.0
- [commander](https://npm.io/package/commander.md) ^3.0.0
- [ding-dong](https://npm.io/package/ding-dong.md) 0.1.7
- [parse-json](https://npm.io/package/parse-json.md) ^2.0.0
- [file-exists](https://npm.io/package/file-exists.md) ^1.0.0
- [witai-speech](https://npm.io/package/witai-speech.md) 0.2.0
- [google-speech](https://npm.io/package/google-speech.md) 0.0.2
- [yandex-speech](https://npm.io/package/yandex-speech.md) 0.0.11

## Recent versions

- 0.2.2 (latest) — 2019-09-19
- 0.2.1 — 2019-08-29
- 0.2.0 — 2019-08-29
- 0.1.19 — 2016-01-02
- 0.1.18 — 2016-01-01
- 0.1.17 — 2016-01-01
- 0.1.16 — 2016-01-01
- 0.1.15 — 2016-01-01
- 0.1.14 — 2016-01-01
- 0.1.13 — 2016-01-01
- 0.1.12 — 2016-01-01
- 0.1.11 — 2016-01-01
- 0.1.10 — 2016-01-01
- 0.1.9 — 2016-01-01
- 0.1.8 — 2015-09-05
- … 8 more at https://npm.io/package/voicer/versions

## README

voicer
======

AGI voice recognizer for Asterisk [use Yandex, Google or Wit.ai ASR online services]

Call to special extension, say "Vasya" and Asterisk connect you with Vasya! Excellent!

[![Build Status](https://travis-ci.org/antirek/voicer.svg?branch=master)](https://travis-ci.org/antirek/voicer)



Workflow
========

Voicer work as AGI-server. Voicer accept request from asterisk via AGI app.
It run handler for each request. Handler command asterisk record file.

After this send file to recognition service, receive text, search by text in 
source of data for finding concordance, if source have this text it return 
channel for call, voicer set dialplan vars RECOGNITION_RESULT as SUCCESS and 
RECOGNITION_TARGET for finded result. 

After this voicer return control to dialplan. Build rules of dialplan using 
RECOGNITION_RESULT and RECOGNITION_TARGET.



Use 
===


## Install ##

> $ npm install voicer -g [--save]

## Run

use npm config for store config opts

> voicer


Configuration
=============

## Config.js ##


``````
{
    agi: {
        port: 3000
    },
    web: {
        port: 3100,
        auth: true,    // or false 
        username: 'vasya',
        password: 'password',
        realm: 'My company'
    },
    processing: {
        totalAttempts: 2,
        playGreeting: true,
        playBeepBeforeRecording: false   //use system beep
    },
    asterisk: {
        sounds: {
            onErrorBeforeFinish: 'invalid',
            onErrorBeforeRepeat: 'invalid',
            greeting: 'beep'
        },
        recognitionDialplanVars: {
            status: 'RECOGNITION_RESULT',
            target: 'RECOGNITION_TARGET'
        }
    },
    record: {
        directory: '/tmp',
        type: 'wav',
        duration: 2,
    },
    recognize: {
        directory: '/tmp',
        type: 'witai',    // ['yandex', 'google', 'witai']
        options: {
            developer_key: '6SQV3DEGQWIXW3R2EDFUMPQCVGOEIBCR'
        }
    },
    lookup: {
        type: 'file',
        options: {
            dataFile: 'data/peernames.json'
        }
    }
};

``````

## Asterisk ##

Write dialplan for call to AGI-server voicer like

`````
[default]
exten=1000,1,AGI(agi://localhost:3000)
exten=1000,n,GotoIf($[${RECOGNITION_RESULT}=SUCCESS]?:default,1000,4)
exten=1000,n,Dial(${RECOGNITION_TARGET})

`````

## Format peernames ##

`````
[
    ....

    {
        "name": "Vasya",
        "target": "SIP/Sf567890",
        "variants": ["vasya", "vasya petrov"]
    },
    
    ....

]

`````



## Some more ##

Also you can tune additional options in *config.js*. 

Try find optimal value for duration of record.


## Errors?! ##

Bugs?! Oh, contact with me. I want to eat them.


## Links ##

Yandex API key: https://developer.tech.yandex.ru/

Google API key: https://console.developers.google.com/

Wit.ai API key: http://wit.ai


Voice speed dial on Asterisk http://habrahabr.ru/post/248263/  (russian)


Development
===========


## Test ##

> npm test

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