class Audio

Tencent AI 语音识别能力.

Traits

Audio

Methods

array
asr(string $speech, int $format = 1, int $rate = 8000)

语音识别 echo 版:提供在线识别语音的能力,对整段音频进行识别,识别完成后,将返回语音的文字内容.

array
asrs(string $speech_chunk, string $speech_id, int $seq = 0, int $format = 1, int $rate = 16000, bool $end = true)

语音识别 流式版 AILab:提供流式识别语音的能力,可以轻松实现边录音边识别.

array
wxasrs(string $speech_chunk, string $speech_id, int $seq = 0, int $format = 1, int $rate = 16000, int $bits = 16, bool $cont_res = true, bool $end = true)

语音识别 流式版 WeChatAI:提供流式识别语音的能力,可以轻松实现边录音边识别.

array
wxasrlong(string|null $speech, string $callback_url, int $format = 3, string $speech_url = null)

长语音识别:上传长音频,提供回调接口,异步获取识别结果.

array
detectKeyword(string|null $speech, string $callback_url, array $key_words, int $format = 2, string $speech_url = null)

关键词检索 : 上传长音频,提供回调接口,异步获取识别结果.

array
tts(string $text, int $speaker = 1, int $format = 3, int $volume = 0, int $speed = 100, int $aht = 0, int $apc = 58)

语音合成 AILab:将文字转换为语音,返回文字的语音数据.

array
tta(string $text, int $model_type = 0, int $speed = -2)

语音合成 优图:将文字转换为语音,返回文字的语音数据.

array
aaievilaudio($speech_id, $speech_url)

音频鉴黄接口.

Details

at line 30
array asr(string $speech, int $format = 1, int $rate = 8000)

语音识别 echo 版:提供在线识别语音的能力,对整段音频进行识别,识别完成后,将返回语音的文字内容.

Parameters

string $speech 待识别语音(时长上限 30s)语音数据的 Base64 编码,非空且长度上限 8MB
int $format 语音压缩格式编码,定义见下文描述 pcm-1 wav-2 amr-3 silk-4
int $rate 语音采样率编码,默认 16KHz,可选 8000 16000

Return Value

array

Exceptions

TencentAIException

See also

https://ai.qq.com/doc/aaiasr.shtml

at line 53
array asrs(string $speech_chunk, string $speech_id, int $seq = 0, int $format = 1, int $rate = 16000, bool $end = true)

语音识别 流式版 AILab:提供流式识别语音的能力,可以轻松实现边录音边识别.

Parameters

string $speech_chunk 语音数据
string $speech_id 语音唯一标识(同一应用内)
int $seq 语音分片所在语音流的偏移量,单位:字节。上一个分片的 seq + 上一个分片的 length
int $format 音频压缩格式编码 pcm-1 wav-2 amr-3 silk-4
int $rate 音频采样率编码,默认 16000。8000 16000
bool $end 是否结束分片标识 默认 true

Return Value

array

Exceptions

TencentAIException

at line 85
array wxasrs(string $speech_chunk, string $speech_id, int $seq = 0, int $format = 1, int $rate = 16000, int $bits = 16, bool $cont_res = true, bool $end = true)

语音识别 流式版 WeChatAI:提供流式识别语音的能力,可以轻松实现边录音边识别.

Parameters

string $speech_chunk 语音数据
string $speech_id 语音唯一标识(同一应用内)
int $seq 语音分片所在语音流的偏移量,单位:字节。上一个分片的 seq + 上一个分片的 length
int $format 音频压缩格式编码 pcm-1 wav-2 amr-3 silk-4 speex-5
int $rate 音频采样率编码,默认 16000
int $bits 音频采样位数,默认 16 位
bool $cont_res 是否获取中间识别结果 默认 true
bool $end 是否结束分片标识 默认 true

Return Value

array

Exceptions

TencentAIException

at line 119
array wxasrlong(string|null $speech, string $callback_url, int $format = 3, string $speech_url = null)

长语音识别:上传长音频,提供回调接口,异步获取识别结果.

Parameters

string|null $speech 语音数据的 Base64 编码,原始音频大小上限 5MB
string $callback_url 用户回调 url,需用户提供,用于平台向用户通知识别结果
int $format 语音压缩格式编码 pcm-1 wav-2 amr-3 silk-4
string $speech_url 待识别语音下载地址

Return Value

array

Exceptions

TencentAIException

See also

https://ai.qq.com/doc/wxasrlong.shtml

at line 139
array detectKeyword(string|null $speech, string $callback_url, array $key_words, int $format = 2, string $speech_url = null)

关键词检索 : 上传长音频,提供回调接口,异步获取识别结果.

Parameters

string|null $speech
string $callback_url
array $key_words
int $format
string $speech_url

Return Value

array

See also

https://ai.qq.com/doc/detectword.shtml

at line 169
array tts(string $text, int $speaker = 1, int $format = 3, int $volume = 0, int $speed = 100, int $aht = 0, int $apc = 58)

语音合成 AILab:将文字转换为语音,返回文字的语音数据.

Parameters

string $text UTF-8 编码,非空且长度上限 150 字节
int $speaker 语音发音人编码 男普-1 女静琪-5 女欢馨-6 女碧萱-7
int $format 合成语音格式 pcm-1 wav-2 mp3-3
int $volume 合成语音音量 [-10,10]
int $speed 合成语音语速,默认 100
int $aht 合成语音降低/升高半音个数,即改变音高,默认 0
int $apc 控制频谱翘曲的程度,改变说话人的音色,默认 58

Return Value

array

Exceptions

TencentAIException

See also

https://ai.qq.com/doc/aaitts.shtml

at line 191
array tta(string $text, int $model_type = 0, int $speed = -2)

语音合成 优图:将文字转换为语音,返回文字的语音数据.

Parameters

string $text utf8 格式,最大 300 字节
int $model_type 发音模型 女-0 女英-1 男-2 喜道公子-6
int $speed 语速,默认为 0 , 0.6x -2 , 0.8x -1 , 1.2x 1 , 1.5x 2

Return Value

array 返回 MP3 格式

Exceptions

TencentAIException

at line 208
array aaievilaudio($speech_id, $speech_url)

音频鉴黄接口.

识别用户提供链接的音频,判断是否为色情音频。

Parameters

$speech_id
$speech_url

Return Value

array

Exceptions

TencentAIException