Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add asr interface #334

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions sample/blindWatermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
$blindWatermarkTemplate->setImage("http://examplebucket-125000000.cos.ap-beijing.myqcloud.com/shuiyin.jpeg");
$blindWatermarkTemplate->setType(2);
$blindWatermarkTemplate->setLevel(3);

// -------------------- 1. 下载时处理 -------------------- //
$result = $cosClient->getObject(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => 'exampleobject',
Expand All @@ -25,6 +27,32 @@
));
// 请求成功
print_r($result);
// -------------------- 1. 下载时处理 -------------------- //

// -------------------- 2. 上传时处理 -------------------- //
$local_path = "/data/exampleobject";
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
$picOperationsTemplate->setIsPicInfo(1);
$picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");
$result = $cosClient->putObject(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => 'exampleobject',
'Body' => fopen($local_path, 'rb'),
'PicOperations' => $picOperationsTemplate->queryString(),
));
// 请求成功
print_r($result);
// -------------------- 2. 上传时处理 -------------------- //

// -------------------- 3. 云上数据处理 -------------------- //
$result = $cosClient->ImageProcess(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => 'exampleobject',
'PicOperations' => $picOperationsTemplate->queryString(),
));
// 请求成功
print_r($result);
// -------------------- 3. 云上数据处理 -------------------- //
} catch (\Exception $e) {
// 请求失败
echo($e);
Expand Down
24 changes: 24 additions & 0 deletions sample/closeAsrService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', // 万象接口必须用https
'credentials' => array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 关闭智能语音服务 https://cloud.tencent.com/document/product/460/95755
$result = $cosClient->closeAsrService(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
));
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
31 changes: 31 additions & 0 deletions sample/createMediaNoiseReductionTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 创建音频降噪模板 https://cloud.tencent.com/document/product/460/94315
$result = $cosClient->createMediaNoiseReductionTemplate(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Tag' => 'NoiseReduction',
'Name' => 'NoiseReduction-Template',
'NoiseReduction' => array(
'Format' => 'wav',
'Samplerate' => '16000',
),
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
4 changes: 4 additions & 0 deletions sample/createMediaVoiceSeparateJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Object' => 'VoiceSeparate01.mp3',
'AuObject' => 'VoiceSeparate02.mp3',
'BassObject' => 'VoiceSeparate03.mp3',
'DrumObject' => 'VoiceSeparate04.mp3',
),
// 'UserData' => 'xxx', // 透传用户信息
// 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
Expand All @@ -52,6 +54,8 @@
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Object' => 'VoiceSeparate01.mp3',
'AuObject' => 'VoiceSeparate02.mp3',
'BassObject' => 'VoiceSeparate03.mp3',
'DrumObject' => 'VoiceSeparate04.mp3',
),
'VoiceSeparate' => array(
'AudioMode' => 'AudioAndBackground',
Expand Down
41 changes: 41 additions & 0 deletions sample/createVoiceSoundHoundJobs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 提交听歌识曲任务 https://cloud.tencent.com/document/product/460/84795
$result = $cosClient->createVoiceSoundHoundJobs(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Tag' => 'SoundHound',
'Input' => array(
'Object' => 'test.mp3',
),
'Operation' => array(
'UserData' => 'xxx', // 透传用户信息
'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
),
// 'CallBack' => '',
// 'CallBackFormat' => '',
// 'CallBackType' => '',
// 'CallBackMqConfig' => array(
// 'MqRegion' => '',
// 'MqMode' => '',
// 'MqName' => '',
// ),
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
44 changes: 44 additions & 0 deletions sample/createVoiceVocalScoreJobs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 提交音乐评分任务 https://cloud.tencent.com/document/product/460/96095
$result = $cosClient->createVoiceVocalScoreJobs(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Tag' => 'VocalScore',
'Input' => array(
'Object' => 'test.mp3',
),
'Operation' => array(
"VocalScore" => array(
'StandardObject' => 'test.mp3',
),
// 'UserData' => 'xxx', // 透传用户信息
// 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
),
// 'CallBack' => '',
// 'CallBackFormat' => '',
// 'CallBackType' => '',
// 'CallBackMqConfig' => array(
// 'MqRegion' => '',
// 'MqMode' => '',
// 'MqName' => '',
// ),
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
30 changes: 30 additions & 0 deletions sample/getAsrBucketList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', // 万象接口必须用https
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey)));

try {
// 查询智能语音服务 https://cloud.tencent.com/document/product/460/46232
$result = $cosClient->getAsrBucketList(array(
// 'Regions' => '', // 可选 地域信息,例如 ap-shanghai、ap-beijing,若查询多个地域以“,”分隔字符串
// 'BucketNames' => '', // 可选 存储桶名称,以“,”分隔,支持多个存储桶,精确搜索
// 'BucketName' => '', // 可选 存储桶名称前缀,前缀搜索
// 'PageNumber' => 1, // 可选 第几页
// 'PageSize' => 20, // 可选 每页个数
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
28 changes: 28 additions & 0 deletions sample/getAsrQueueList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', // 万象接口必须为https
'credentials' => array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 查询智能语音队列 https://cloud.tencent.com/document/product/460/46234
$result = $cosClient->getAsrQueueList(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
// 'QueueIds' => 'xxx', // 队列 ID,以“,”符号分割字符串
// 'State' => 'Active', // Active 表示队列内的作业会被媒体处理服务调度执行, Paused 表示队列暂停,作业不再会被媒体处理调度执行,队列内的所有作业状态维持在暂停状态,已经执行中的任务不受影响
// 'PageNumber' => '1', // 第几页
// 'PageSize' => '10', // 每页个数
));
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
13 changes: 13 additions & 0 deletions sample/getBlindWatermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
$picOperationsTemplate->setIsPicInfo(1);
$picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");

// -------------------- 1. 上传时处理 -------------------- //
$result = $cosClient->putObject(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => 'exampleobject',
Expand All @@ -29,6 +31,17 @@
));
// 请求成功
print_r($result);
// -------------------- 1. 上传时处理 -------------------- //

// -------------------- 2. 云上数据处理 -------------------- //
$result = $cosClient->ImageProcess(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => 'exampleobject',
'PicOperations' => $picOperations->queryString(),
));
// 请求成功
print_r($result);
// -------------------- 2. 云上数据处理 -------------------- //
} catch (\Exception $e) {
// 请求失败
echo($e);
Expand Down
24 changes: 24 additions & 0 deletions sample/openAsrService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', // 万象接口必须用https
'credentials' => array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 开通智能语音服务 https://cloud.tencent.com/document/product/460/95754
$result = $cosClient->openAsrService(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
));
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
38 changes: 38 additions & 0 deletions sample/updateAsrQueue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', // 万象接口必须为https
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 更新智能语音队列 https://cloud.tencent.com/document/product/460/46235
$result = $cosClient->updateAsrQueue(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => '', // queueId
'Name' => 'queue-smart-audio',
'State' => 'Active',
'NotifyConfig' => array(
'State' => 'Off',
// 'Event' => '',
// 'ResultFormat' => '',
// 'Type' => '',
// 'Url' => '',
// 'MqMode' => '',
// 'MqRegion' => '',
// 'MqName' => '',
),
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
32 changes: 32 additions & 0 deletions sample/updateMediaNoiseReductionTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 更新音频降噪模板 https://cloud.tencent.com/document/product/460/94394
$result = $cosClient->updateMediaNoiseReductionTemplate(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => '', // TemplateId
'Tag' => 'NoiseReduction',
'Name' => 'NoiseReduction-Template',
'NoiseReduction' => array(
'Format' => 'wav',
'Samplerate' => '16000',
),
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
Loading