Skip to content

初始化

方法名

init

用法

  • 用法如下:
    js
    module.init({
      params: {
        appId: KeyUtils.APPID,
        apiKey: KeyUtils.APIKEY,
        secretKey: KeyUtils.SECRETKEY
      },
      complete: (res) => {
        if (res.code == 0) {
          this.addLog("初始化成功")
    
          //注册监听
          this.registerListener();
        } else {
          this.addLog(res.message)
        }
      }
    })
    js
    module.init({
      params: {
        appId: KeyUtils.APPID,
        apiKey: KeyUtils.APIKEY,
        secretKey: KeyUtils.SECRETKEY
      },
      complete: (res : LevenResult) => {
        if (res.code == 0) {
          addLog("初始化成功")
    
          //注册监听
          registerListener();
        } else {
          addLog(res.message)
        }
      }
    } as LevenOptions)
  • 参数说明
    参数名参数类型是否必填默认值参数描述
    paramsObject接口请求参数
    params.appIdString百度申请的appId
    params.apiKeyString百度申请的apiKey
    params.secretKeyString百度申请的secretKey
    params.iamKeyString百度申请的永久或临时秘钥
    params.typeStringasr识别类型,可选值:
    asr:语音识别
    wp:语音唤醒
    successFunction执行成功的函数
    failFunction执行失败的函数
    completeFunction执行完成的函数,不管成功还是失败都会执行

回调

  • 示例
    json
    {
      "data": {},
      "message": "",
      "code": 0
    }
  • 回调说明:
    参数名参数类型参数描述
    messageString消息提示
    dataObject数据对象
    codeInteger返回类型,0.成功,其他:失败