@ailabs-yating/asr-client-sdk-javascript
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Yating ASR SDK - JavaScript

npm version

AILabs Yating ASR Javascript SDK - 幫助使用者在前端介接自動語音辨識

可參考文件

注意: 此SDK只適用於前端

使用方法

import { AILabsYatingASR } from "@ailabs-yating/asr-client-sdk-javascript"
import { getToken } from "./util"

const asr = new AILabsYatingASR(getToken)

asr.on("sentence", (event) => {
  console.log(`sentence: ${JSON.stringify(event)}`)
})

asr.on("sentenceFinal", (event) => {
  console.log(`final sentence: ${JSON.stringify(event)}`)
})

asr.setupAudioDevices()
  .then(devices => {
    return asr.connect(devices[0].deviceId)
  })
  .then(() => {
    console.log("asr connected!")
  })
  • getToken: 取得token的function, 因為asr服務需要換取token, 所以這邊可由使用者決定要如何取得token, function回傳Promise<string>即可
  • asr.setupAudioDevices()會回傳麥克風裝置列表, 開發者可取得device id至asr.connect()選擇所要使用的裝置
  • asr.connect()會要求麥克風權限, 並將收到的音訊傳至ASR
    • 若不傳入device id, 則會使用偵測到的第一個裝置
    • 若要選擇裝置, 請先呼叫asr.setupAudioDevices()取得裝置id

Readme

Keywords

none

Package Sidebar

Install

npm i @ailabs-yating/asr-client-sdk-javascript

Weekly Downloads

112

Version

1.0.4

License

ISC

Unpacked Size

26.5 kB

Total Files

7

Last publish

Collaborators

  • gmin_chen