全部产品

直播ASR乱码识别

更新时间:2020-09-29 14:49:55

直播ASR乱码识别服务适用于直播场景,通过ASR语音转文字,识别由于多人同时说话导致的文字可读性不佳的问题。使用示例如下。

Java代码示例

  1. DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou","your-access-id-key","your-access-id-secret");
  2. IAcsClient client = new DefaultAcsClient(defaultProfile);
  3. Map<String, Object> map = new HashMap<>();
  4. map.put("input", "给自己一个加速加速加速加速");
  5. RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
  6. request.setServiceName("E-Game-Language-Model");
  7. request.setPredictContent(JSON.toJSONString(map));
  8. RunPreTrainServiceResponse response = client.getAcsResponse(request);
  9. System.out.println(response.getPredictResult());

Python代码示例

  1. # 安装依赖
  2. pip install aliyun-python-sdk-core
  3. pip install aliyun-python-sdk-nlp-automl
  1. # -*- coding: utf8 -*-
  2. import json
  3. from aliyunsdkcore.client import AcsClient
  4. from aliyunsdkcore.acs_exception.exceptions import ClientException
  5. from aliyunsdkcore.acs_exception.exceptions import ServerException
  6. from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
  7. # Initialize AcsClient instance
  8. client = AcsClient(
  9. "<your-access-key-id>",
  10. "<your-access-key-secret>",
  11. "cn-hangzhou"
  12. );
  13. content ={"input": "给自己一个加速加速加速加速"}
  14. # Initialize a request and set parameters
  15. request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
  16. request.set_ServiceName('E-Game-Language-Model')
  17. request.set_PredictContent(json.dumps(content))
  18. # Print response
  19. response = client.do_action_with_exception(request)
  20. resp_obj = json.loads(response)
  21. predict_result = json.loads(resp_obj['PredictResult'])
  22. print(predict_result['result'])

PredictContent内容示例

  1. {
  2. "input": "给自己一个加速加速加速加速"
  3. }

PredictResult内容示例

  1. {
  2. "label": [
  3. {
  4. "preplexity ": 48.247,
  5. "is_readable": True
  6. }
  7. ]
  8. }

入参说明

参数 说明
input ASR语音转文本的结果,长度不超过600

出参说明

参数 说明
is_readable bool类型,true表示ASR结果可读性好,可以直接展示;falase表示ASR结果可读性不好,不建议直接展示
preplexity 语言模型困惑度,供参考