跳至主要内容

com.amivoice.hrp.Hrp 类

Hrp.construct()​

返回 Hrp 类实例的构建方法。

void setListener(HrpListener listener)​

设置用于接收 Hrp 类事件的监听器对象。

listener:监听器对象

void setServerURL(String serverURL)​

指定语音识别服务器 URL(https://acp-api.amivoice.com/v1/recognize)。

serverURL:语音识别服务器 URL

void setConnectTimeout(int connectTimeout)​

指定连接语音识别服务器时使用的超时值。

connectTimeout:超时值(毫秒)

void setReceiveTimeout(int receiveTimeout)​

指定接收语音识别服务器响应时使用的超时值。

receiveTimeout:超时值(毫秒)

void setGrammarFileNames(String grammarFileNames)​

指定连接引擎名称。只能指定一个连接引擎名称。

grammarFileNames:连接引擎名称

void setProfileId(String profileId)​

指定用于识别使用注册词的用户的 profileId。请务必在开头加上冒号。profileId 应由半角英文字母、数字以及"-"(半角连字符)、"_"(半角下划线)组成的字符串。但是,以"__"(两个半角下划线)开头的字符串被语音识别引擎预留,请不要使用以"__"(两个半角下划线)开头的字符串。

profileId:profileId

void setProfileWords(String profileWords)​

语音识别服务器将使用此处指定的 profileWords 相关信息进行识别处理。

void setSegmenterProperties(String segmenterProperties)​

指定与语音段检测的灵敏度和说话人区分相关的参数。

有关参数的详细信息,请参阅 segmenterProperties。

void setKeepFillerToken(String keepFillerToken)​

指定是否自动删除填充词(无用词)。

KeepFillerToken:1 或 0(自动删除填充词时为 0,不删除时为 1,默认为 0)

void setResultUpdatedInterval(String resultUpdatedInterval)​

指定发送识别中事件的间隔。

resultUpdatedInterval:事件发出间隔(毫秒)

void setMaxDecodingTime(String maxDecodingTime)​

指定最大识别处理时间。详细信息请参阅 maxDecodingTime。

maxDecodingTime:最大识别处理时间(毫秒)

void setMaxResponseTime(String maxResponseTime)​

指定最大响应时间。详细信息请参阅 maxResponseTime。

maxResponseTime:最大响应时间(毫秒)

void setMaxDecodingRate(String maxDecodingRate)​

指定最大 RT。详情请参阅 maxDecodingRate。

maxDecodingRate:最大 RT

void setTargetResponseTime(String targetResponseTime)​

指定目标响应时间。详细信息请参阅 targetResponseTime。

targetResponseTime:目标响应时间(毫秒)

void setTargetDecodingRate(String targetDecodingRate)​

指定目标 RT。详细信息请参阅 targetDecodingRate。

targetDecodingRate:目标 RT

void setRecognitionTimeout(String recognitionTimeout)​

指定识别完成超时时间。详细信息请参阅 recognitionTimeout。

recognitionTimeout:识别完成超时时间(毫秒)

void setExtension(String extension)​

指定使用量统计标签。详细信息请参阅使用量统计标签。

extension:使用量统计标签

void setCodec(String codec)​

指定要发送的音频数据格式。指定的值请参考开发指南中的语音格式。此指定是必须的。

codec:格式名称

void setResultType(String resultType)​

识别结果接收类型。HTTP 接口中指定的值为 "JSON"。

resultType:"JSON"

void setServiceAuthorization(String serviceAuthorization)​

指定 API key。

serviceAuthorization: API key

boolean connect()​

连接到语音识别服务器。

boolean disconnect()​

从语音识别服务器断开连接。

boolean isConnected()​

返回是否正在连接语音识别服务器。

boolean feedDataResume()​

开始向语音识别服务器发送音频数据。

boolean feedData(byte[] data, int dataOffset, int dataBytes)​

向语音识别服务器发送音频数据。 在调用 feedDataResume() 方法之后,直到调用 feedDataPause() 方法之前,可以多次调用 feedData() 方法。

data:要提供的音频数据字节数组。 dataOffset:要提供的音频数据的起始偏移量。 dataBytes:要提供的音频数据的字节数。

boolean feedDataPause()​

完成向语音识别服务器发送音频数据。 调用此方法后,处理将被阻塞,直到接收完未接收的识别结果。

String getLastMessage()​

获取发送到 TRACE() 的消息字符串。

void sleep(int timeout)​

休眠指定的时间。

timeout: 等待时间(毫秒)

void setProxyServerName(String proxyServerName)​

如果使用代理服务器,设置代理服务器。

proxyServerName: 代理设置( <username>:<password>@<proxyhost>:<port> )