Skip to content

初始化 ​

方法名 ​

initAsr

用法 ​

  • 用法如下:
    js
    module.initAsr({
      params: {
        asrParam: {
          pid: "1843",
          deviceId: this.deviceId
        },
        external: {
          location: "San Francisco",
          appVersion: "1.0.0",
          deviceId: this.deviceId
        },
        ttsParam: {
          enableAec: "1"
        }
      },
      complete: (res) => {
        if (res.code == 0) {
          this.showLog("初始化成功")
        } else {
          this.showLog("初始化失败")
        }
      }
    })
    js
    module.initAsr({
      params: {
        asrParam: {
          pid: "1843",
          deviceId: deviceId.value
        },
        external: {
          location: "San Francisco",
          appVersion: "1.0.0",
          deviceId: deviceId.value
        },
        ttsParam: {
          enableAec: "1"
        }
      },
      complete: (res : LevenResult) => {
        if (res.code == 0) {
          showLog("初始化成功")
        } else {
          showLog("初始化失败")
        }
      }
    } as LevenOptions)
  • 参数说明
    参数名参数类型是否必填默认值参数描述
    paramsObject是无接口请求参数
    params.asrParamObject是无识别参数
    params.asrParam.pidString否无识别环境ID,1843
    params.asrParam.deviceIdString否无设备唯一id,通过getSpeechDeviceId获取
    params.externalObject是无其他透传参数
    params.external.locationString是无位置信息
    params.external.appVersionString是无版本号
    params.external.deviceIdString是无设备唯一id,通过getSpeechDeviceId获取
    params.ttsParamObject是无语音参数
    params.ttsParam.enableAecString是1-
    successFunction否无执行成功的函数
    failFunction否无执行失败的函数
    completeFunction否无执行完成的函数,不管成功还是失败都会执行

回调 ​

  • 示例
    json
    {
        "data": {
            "type": "onInit"
        },
        "message": "",
        "code": 0
    }
  • 回调说明:
    参数名参数类型参数描述
    messageString消息提示
    dataObject数据对象
    data.typeString接口返回数据类型
    onInit:初始化结果
    onSynthesizeResponse:语音合成事件
    以下参数仅在onSynthesizeResponse类型中返回
    data.snStringsn
    data.utteranceIdStringutteranceId
    data.synthesizeTypeString识别类型名称
    data.synthesizerDataObject识别数据
    data.synthesizerData.audioDatabyte[]语音数据
    data.synthesizerData.allAudioMsInteger所有语音识别的时间,单位:毫秒
    data.synthesizerData.audioPercentFloat识别百分比
    data.synthesizerData.audioProgressint识别进度
    data.synthesizerData.lipDataString-
    data.synthesizerData.engineTypeint引擎类型
    data.synthesizerData.audioSampleRateint音频采样率
    data.responseTypeint相应类型
    data.synthesizerErrorObject识别错误信息
    data.synthesizerError.codeInteger识别错误码
    data.synthesizerError.descriptionInteger识别错误描述
    data.instanceIdStringinstanceId
    data.extraInfoStringextraInfo
    codeInteger返回类型,0.成功,其他:失败