0.0.5 • Published 9 months ago

ux-tencent_asr-sdk v0.0.5

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
9 months ago

ux-tencent_asr-sdk

使用 腾讯云云隐识别 服务的 Web SDK

使用

import TencentAsr from 'ux-tencent_asr-sdk';

// 创建实例
const ASR = new TencentAsr({
    signCallback: async (queryStr) => {
        // 获取签名的方法
        const res = await fetch(`http://a.com/sign?string=${queryStr}`);
        const data = await res.json();
        return data;
    },
    appid: APPID, // 腾讯云的 App Id (用户ID或项目ID)
    secretid: SECRETID, // 腾讯云的 Secret Id
});

// 添加事件回调:监听识别结果
ASR.onTextChange((text) => {
    ResultElement.innerHTML = text;
});

// 添加事件回调:监听识别状态
ASR.onStateChange((state) => {
    StateElement.innerHTML =
        state === 'idle'
            ? '未开始'
            : state === 'initializing'
            ? '建立连接中...'
            : state === 'recognizing'
            ? '识别中...'
            : state === 'fail'
            ? '识别错误'
            : '未知状态';
});

// 开始录制与识别
ASR.start();

// 结束录制与识别
ASR.stop();

// 开始 / 结束识别
ASR.toggle();

Demo 项目

demo 目录下是一个示例项目。

查询 demo 目录下的 README.md 文件,查看如何使用示例项目。

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago