Skip to content

Commit e8017f1

Browse files
authored
add asr interface (#334)
add asr interface
1 parent df16681 commit e8017f1

16 files changed

+1043
-0
lines changed

sample/blindWatermark.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
$blindWatermarkTemplate->setImage("http://examplebucket-125000000.cos.ap-beijing.myqcloud.com/shuiyin.jpeg");
1818
$blindWatermarkTemplate->setType(2);
1919
$blindWatermarkTemplate->setLevel(3);
20+
21+
// -------------------- 1. 下载时处理 -------------------- //
2022
$result = $cosClient->getObject(array(
2123
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
2224
'Key' => 'exampleobject',
@@ -25,6 +27,32 @@
2527
));
2628
// 请求成功
2729
print_r($result);
30+
// -------------------- 1. 下载时处理 -------------------- //
31+
32+
// -------------------- 2. 上传时处理 -------------------- //
33+
$local_path = "/data/exampleobject";
34+
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
35+
$picOperationsTemplate->setIsPicInfo(1);
36+
$picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");
37+
$result = $cosClient->putObject(array(
38+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
39+
'Key' => 'exampleobject',
40+
'Body' => fopen($local_path, 'rb'),
41+
'PicOperations' => $picOperationsTemplate->queryString(),
42+
));
43+
// 请求成功
44+
print_r($result);
45+
// -------------------- 2. 上传时处理 -------------------- //
46+
47+
// -------------------- 3. 云上数据处理 -------------------- //
48+
$result = $cosClient->ImageProcess(array(
49+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
50+
'Key' => 'exampleobject',
51+
'PicOperations' => $picOperationsTemplate->queryString(),
52+
));
53+
// 请求成功
54+
print_r($result);
55+
// -------------------- 3. 云上数据处理 -------------------- //
2856
} catch (\Exception $e) {
2957
// 请求失败
3058
echo($e);

sample/closeAsrService.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', // 万象接口必须用https
12+
'credentials' => array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// 关闭智能语音服务 https://cloud.tencent.com/document/product/460/95755
17+
$result = $cosClient->closeAsrService(array(
18+
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
));
20+
print_r($result);
21+
} catch (\Exception $e) {
22+
// 请求失败
23+
echo($e);
24+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', //协议头部,默认为http
12+
'credentials'=> array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// 创建音频降噪模板 https://cloud.tencent.com/document/product/460/94315
17+
$result = $cosClient->createMediaNoiseReductionTemplate(array(
18+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
'Tag' => 'NoiseReduction',
20+
'Name' => 'NoiseReduction-Template',
21+
'NoiseReduction' => array(
22+
'Format' => 'wav',
23+
'Samplerate' => '16000',
24+
),
25+
));
26+
// 请求成功
27+
print_r($result);
28+
} catch (\Exception $e) {
29+
// 请求失败
30+
echo($e);
31+
}

sample/createMediaVoiceSeparateJobs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
3030
'Object' => 'VoiceSeparate01.mp3',
3131
'AuObject' => 'VoiceSeparate02.mp3',
32+
'BassObject' => 'VoiceSeparate03.mp3',
33+
'DrumObject' => 'VoiceSeparate04.mp3',
3234
),
3335
// 'UserData' => 'xxx', // 透传用户信息
3436
// 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
@@ -52,6 +54,8 @@
5254
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
5355
'Object' => 'VoiceSeparate01.mp3',
5456
'AuObject' => 'VoiceSeparate02.mp3',
57+
'BassObject' => 'VoiceSeparate03.mp3',
58+
'DrumObject' => 'VoiceSeparate04.mp3',
5559
),
5660
'VoiceSeparate' => array(
5761
'AudioMode' => 'AudioAndBackground',
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', //协议头部,默认为http
12+
'credentials'=> array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// 提交听歌识曲任务 https://cloud.tencent.com/document/product/460/84795
17+
$result = $cosClient->createVoiceSoundHoundJobs(array(
18+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
'Tag' => 'SoundHound',
20+
'Input' => array(
21+
'Object' => 'test.mp3',
22+
),
23+
'Operation' => array(
24+
'UserData' => 'xxx', // 透传用户信息
25+
'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
26+
),
27+
// 'CallBack' => '',
28+
// 'CallBackFormat' => '',
29+
// 'CallBackType' => '',
30+
// 'CallBackMqConfig' => array(
31+
// 'MqRegion' => '',
32+
// 'MqMode' => '',
33+
// 'MqName' => '',
34+
// ),
35+
));
36+
// 请求成功
37+
print_r($result);
38+
} catch (\Exception $e) {
39+
// 请求失败
40+
echo($e);
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', //协议头部,默认为http
12+
'credentials'=> array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// 提交音乐评分任务 https://cloud.tencent.com/document/product/460/96095
17+
$result = $cosClient->createVoiceVocalScoreJobs(array(
18+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
'Tag' => 'VocalScore',
20+
'Input' => array(
21+
'Object' => 'test.mp3',
22+
),
23+
'Operation' => array(
24+
"VocalScore" => array(
25+
'StandardObject' => 'test.mp3',
26+
),
27+
// 'UserData' => 'xxx', // 透传用户信息
28+
// 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
29+
),
30+
// 'CallBack' => '',
31+
// 'CallBackFormat' => '',
32+
// 'CallBackType' => '',
33+
// 'CallBackMqConfig' => array(
34+
// 'MqRegion' => '',
35+
// 'MqMode' => '',
36+
// 'MqName' => '',
37+
// ),
38+
));
39+
// 请求成功
40+
print_r($result);
41+
} catch (\Exception $e) {
42+
// 请求失败
43+
echo($e);
44+
}

sample/getAsrBucketList.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', // 万象接口必须用https
12+
'credentials'=> array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
16+
try {
17+
// 查询智能语音服务 https://cloud.tencent.com/document/product/460/46232
18+
$result = $cosClient->getAsrBucketList(array(
19+
// 'Regions' => '', // 可选 地域信息,例如 ap-shanghai、ap-beijing,若查询多个地域以“,”分隔字符串
20+
// 'BucketNames' => '', // 可选 存储桶名称,以“,”分隔,支持多个存储桶,精确搜索
21+
// 'BucketName' => '', // 可选 存储桶名称前缀,前缀搜索
22+
// 'PageNumber' => 1, // 可选 第几页
23+
// 'PageSize' => 20, // 可选 每页个数
24+
));
25+
// 请求成功
26+
print_r($result);
27+
} catch (\Exception $e) {
28+
// 请求失败
29+
echo($e);
30+
}

sample/getAsrQueueList.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', // 万象接口必须为https
12+
'credentials' => array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// 查询智能语音队列 https://cloud.tencent.com/document/product/460/46234
17+
$result = $cosClient->getAsrQueueList(array(
18+
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
// 'QueueIds' => 'xxx', // 队列 ID,以“,”符号分割字符串
20+
// 'State' => 'Active', // Active 表示队列内的作业会被媒体处理服务调度执行, Paused 表示队列暂停,作业不再会被媒体处理调度执行,队列内的所有作业状态维持在暂停状态,已经执行中的任务不受影响
21+
// 'PageNumber' => '1', // 第几页
22+
// 'PageSize' => '10', // 每页个数
23+
));
24+
print_r($result);
25+
} catch (\Exception $e) {
26+
// 请求失败
27+
echo($e);
28+
}

sample/getBlindWatermark.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
2222
$picOperationsTemplate->setIsPicInfo(1);
2323
$picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");
24+
25+
// -------------------- 1. 上传时处理 -------------------- //
2426
$result = $cosClient->putObject(array(
2527
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
2628
'Key' => 'exampleobject',
@@ -29,6 +31,17 @@
2931
));
3032
// 请求成功
3133
print_r($result);
34+
// -------------------- 1. 上传时处理 -------------------- //
35+
36+
// -------------------- 2. 云上数据处理 -------------------- //
37+
$result = $cosClient->ImageProcess(array(
38+
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
39+
'Key' => 'exampleobject',
40+
'PicOperations' => $picOperations->queryString(),
41+
));
42+
// 请求成功
43+
print_r($result);
44+
// -------------------- 2. 云上数据处理 -------------------- //
3245
} catch (\Exception $e) {
3346
// 请求失败
3447
echo($e);

sample/openAsrService.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
require dirname(__FILE__, 2) . '/vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'scheme' => 'https', // 万象接口必须用https
12+
'credentials' => array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// 开通智能语音服务 https://cloud.tencent.com/document/product/460/95754
17+
$result = $cosClient->openAsrService(array(
18+
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
));
20+
print_r($result);
21+
} catch (\Exception $e) {
22+
// 请求失败
23+
echo($e);
24+
}

0 commit comments

Comments
 (0)