@fanolabs/fano-grpc-client

1.1.2 • Public • Published

@fanolabs/fano-grpc-client

npm version

FanoLabs gRPC module for Node.js

Installation

Current stable release (1.0.0)

$ 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:

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

    {
        "activity_code": 2,
        "ongoing_speech": true,
        "metadata": {
            "sos": false,
            "eos": true,
            "callId": "ee00b670f97711eabe553f98332fa274"
        }
    }

    Note: asr response

    {
        "trans": "有 問 題 呀",
        "is_final": true,
        "metadata": {
            "sos": false,
            "eos": true,
            "callId": "4596a300f96311eab2bb89c93f468cad"
        }
    }

close()

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @fanolabs/fano-grpc-client

Weekly Downloads

0

Version

1.1.2

License

ISC

Unpacked Size

76.3 kB

Total Files

17

Last publish

Collaborators

  • henryzheng