# @fanolabs/fano-grpc-client

> Fano gRPC client

Latest version **1.1.2** (published 2020-10-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @fanolabs/fano-grpc-client
pnpm add @fanolabs/fano-grpc-client
yarn add @fanolabs/fano-grpc-client
bun add @fanolabs/fano-grpc-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2020-10-09 |
| First published | 2020-09-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 74.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | riskel |
| Maintainers | henryzheng |
| Keywords | Fano, gRPC |

## Links

- npm: https://www.npmjs.com/package/@fanolabs/fano-grpc-client
- Repository: https://git.fanoai.cn/SDKs/fano-grpc-client
- npm.io page: https://npm.io/package/@fanolabs/fano-grpc-client

## Dependencies (5)

- [grpc](https://npm.io/package/grpc.md) ^1.11.0
- [uuid](https://npm.io/package/uuid.md) ^8.3.0
- [pb-util](https://npm.io/package/pb-util.md) ^0.1.3
- [buffer-to-stream](https://npm.io/package/buffer-to-stream.md) ^1.0.0
- [@grpc/proto-loader](https://npm.io/package/@grpc/proto-loader.md) ^0.1.0

## Recent versions

- 1.1.2 (latest) — 2020-10-09
- 1.1.1 — 2020-09-27
- 1.1.0 — 2020-09-27
- 1.0.9 — 2020-09-27
- 1.0.8 — 2020-09-18
- 1.0.7 — 2020-09-18
- 1.0.6 — 2020-09-18
- 1.0.5 — 2020-09-18
- 1.0.4 — 2020-09-18
- 1.0.3 — 2020-09-18
- 1.0.2 — 2020-09-18
- 1.0.1 — 2020-09-15
- 1.0.0 — 2020-09-15

## README

@fanolabs/fano-grpc-client
==========

[![npm version][npm-image]][npm-url]

FanoLabs gRPC module for Node.js

<!-- TOC -->

- [Installation](#installation)
- [Common Usage](#Common Usage)
- [License](#license)
- [API](#api)
    - [send(bufferData, metadata, inputRate = 8000, inputBits = 16)](#send(bufferData, metadata, inputRate = 8000, inputBits = 16))
    - [handleMessage(data)](#handleMessage(data))
    - [close()](#close())


<!-- /TOC -->

## Installation

Current stable release (`1.0.0`)

```sh
$ npm install @fanolabs/fano-grpc-client --save
```

## Common Usage
We suggest you load the module via `require`, pending the stabalizing of es modules in node:
```js
const { init, vadGRPCEngine, asrGRPCEngine } = require('@fanolabs/fano-grpc-client');
init(poolSize, sslParams = { caCertPath, pkPath, certificateChainPath });
const vadClient = new vadGRPCEngine(
    'fano-ms-online-speech-vad:50000?tipping_point=0.3&trail_silence=500',
    callId
);
vadClient.connet((err, res) => {
    if(!!err) {
        errorHandle(err);
        return;
    }
    const result = client.handleMessage(res);
    dataHandle(result)
});

const asrClient = new asrGRPCEngine(
    'fano-ms-online-speech-asr:50000',
    callId
);
asrClient.connet((err, res) => {
    if(!!err) {
        errorHandle(err);
        return;
    }
    const result = client.handleMessage(res);
    dataHandle(result)
})

```

## API

### send(bufferData, metadata, inputRate = 8000, inputBits = 16)

- `bufferData` 音频文件buffer(分片)。
- `metadata` metadata 可以包含sos、eos、call id等。
- `inputRate` 音频文件采样率。
- `inputBits` 音频文件字节数。

### handleMessage(data)
- `data` response data
- Returns: 

    `Note`: vad response
    ```js
    {
        "activity_code": 2,
        "ongoing_speech": true,
        "metadata": {
            "sos": false,
            "eos": true,
            "callId": "ee00b670f97711eabe553f98332fa274"
        }
    }
    ```

    `Note`: asr response
    ```js
    {
        "trans": "有 問 題 呀",
        "is_final": true,
        "metadata": {
            "sos": false,
            "eos": true,
            "callId": "4596a300f96311eab2bb89c93f468cad"
        }
    }
    ```

### close()

## License

MIT

[npm-image]: https://flat.badgen.net/npm/v/babel-core
[npm-url]: https://www.npmjs.com/package/@fanolabs/fano-grpc-client

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