The live streaming ASR garbled text detection service uses Automatic Speech Recognition (ASR) to convert speech to text. The service then detects garbled text that can result from multiple people speaking at the same time.
This service is provided by the NLP Self-learning Platform. You can call the API directly to use this service.
Service activation and resource plan purchase
Before you use the service, confirm that it is activated. After you activate the service, you must purchase a resource plan.
Activate service: Activation page
Purchase resource plan: Purchase page
Service invocation and debugging
For more information about model invocation, see Model Invocation.
For more information about SDK examples, see SDK Examples.
Debug
Configure access credentials using environment variables
Notes:
An AccessKey pair for an Alibaba Cloud account grants full access to all APIs. This poses a high security threat. We recommend that you create and use a Resource Access Management (RAM) user for API access or daily operations and maintenance (O&M). To create a RAM user, log on to the RAM console.
Do not hard-code your AccessKey ID and AccessKey secret in your code to prevent security threats. Instead, configure environment variables to store and access your AccessKey pair.
Configure for Linux and macOS
export NLP_AK_ENV=<access_key_id> export NLP_SK_ENV=<access_key_secret>Replace <access_key_id> with your AccessKey ID and <access_key_secret> with your AccessKey secret. For more information, see Step 2: Obtain an AccessKey pair for an account.
Configure for Windows
Create a file for environment variables. Add the
NLP_AK_ENVandNLP_SK_ENVvariables and set them to your AccessKey ID and AccessKey secret.Restart Windows.
Java code example
/**
* An AccessKey pair for an Alibaba Cloud account has all API access permissions, which poses a high security threat. We strongly recommend that you create and use a RAM user for API access or daily O&M. To create a RAM user, log on to the RAM console.
* This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
* We strongly recommend that you do not hard-code the AccessKey ID and AccessKey secret in your code to prevent security threats.
*/
String accessKeyId = System.getenv("NLP_AK_ENV");
String accessKeySecret = System.getenv("NLP_SK_ENV");
DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou",accessKeyId,accessKeySecret);
IAcsClient client = new DefaultAcsClient(defaultProfile);
Map<String, Object> map = new HashMap<>();
map.put("input", "Give yourself an acceleration acceleration acceleration acceleration");
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("E-Game-Language-Model");
request.setPredictContent(JSON.toJSONString(map));
RunPreTrainServiceResponse response = client.getAcsResponse(request);
System.out.println(response.getPredictResult());Python code example
# Install dependencies
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-nlp-automl# -*- coding: utf8 -*-
import json
import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
# An AccessKey pair for an Alibaba Cloud account has all API access permissions, which poses a high security threat. We strongly recommend that you create and use a RAM user for API access or daily O&M. To create a RAM user, log on to the RAM console.
# This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
# We strongly recommend that you do not hard-code the AccessKey ID and AccessKey secret in your code to prevent security threats.
access_key_id = os.environ['NLP_AK_ENV']
access_key_secret = os.environ['NLP_SK_ENV']
# Initialize AcsClient instance
client = AcsClient(
access_key_id,
access_key_secret,
"cn-hangzhou"
);
content ={"input": "Give yourself an acceleration acceleration acceleration acceleration"}
# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('E-Game-Language-Model')
request.set_PredictContent(json.dumps(content))
# Print response
response = client.do_action_with_exception(request)
resp_obj = json.loads(response)
predict_result = json.loads(resp_obj['PredictResult'])
print(predict_result['result'])PredictContent example
{
"input": "Give yourself an acceleration acceleration acceleration acceleration"
}PredictResult example
{
"label": [
{
"preplexity ": 48.247,
"is_readable": True
}
]
}Input parameters
Parameter | Description |
input | The text converted from speech by ASR. The length cannot exceed 600 characters. |
Response parameters
Parameter | Description |
is_readable | A boolean value. `true` indicates that the ASR result is highly readable and can be displayed directly. `false` indicates that the ASR result has poor readability and should not be displayed directly. |
preplexity | The perplexity of the language model. This value is for reference only. |