class Translate

TencentAI 翻译相关能力.

Traits

Translate
Audio

Constants

BASE_URL

AILAB_TEXT

TEXT

IMAGE

AUDIO

DETECT

Methods

array
aILabText(string $text, int $type = 0)

文本翻译(AI Lab).

array
text(string $text, string $source = 'auto', string $target = 'auto')

文本翻译(翻译君).

array
image(mixed $image, string $session_id, string $scene = 'word', string $source = 'auto', string $target = 'auto')

图片翻译.

array
audio(string $speech_chunk, string $session_id, int $format = 3, int $seq = 0, bool $end = true, string $source = 'auto', string $target = 'auto')

语音翻译.

array
detect(string $text, array $languages = null, bool $force = false)

语种识别.

Details

at line 43
array aILabText(string $text, int $type = 0)

文本翻译(AI Lab).

Parameters

string $text
int $type 翻译类型 0-16

Return Value

array

Exceptions

TencentAIException

See also

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

at line 61
array text(string $text, string $source = 'auto', string $target = 'auto')

文本翻译(翻译君).

Parameters

string $text
string $source 源语言缩写
string $target 目标语言缩写

Return Value

array

Exceptions

TencentAIException

at line 85
array image(mixed $image, string $session_id, string $scene = 'word', string $source = 'auto', string $target = 'auto')

图片翻译.

Parameters

mixed $image 支持 JPG PNG BMP 格式
string $session_id 一次请求ID
string $scene 识别类型 word-单词识别,doc-文档识别
string $source 源语言缩写
string $target 目标语言缩写

Return Value

array

Exceptions

TencentAIException

See also

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

at line 121
array audio(string $speech_chunk, string $session_id, int $format = 3, int $seq = 0, bool $end = true, string $source = 'auto', string $target = 'auto')

语音翻译.

Parameters

string $speech_chunk 待识别语音分片
string $session_id 语音唯一标识(同一应用内)
int $format amr-3 silk-4 pcm-6 mp3-8 aac-9
int $seq 语音分片所在语音流的偏移量(字节)
bool $end 是否结束分片 true
string $source 源语言缩写
string $target 目标语言缩写

Return Value

array

Exceptions

TencentAIException

See also

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

at line 154
array detect(string $text, array $languages = null, bool $force = false)

语种识别.

Parameters

string $text
array $languages zh en jp kr
bool $force 强制从待选择语言中选择

Return Value

array

Exceptions

TencentAIException

See also

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