createVoiceSpeechRecognitionJobs.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. require dirname(__FILE__, 2) . '/vendor/autoload.php';
  3. $secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
  4. $secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
  5. $region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
  6. $cosClient = new Qcloud\Cos\Client(
  7. array(
  8. 'region' => $region,
  9. 'scheme' => 'https', // 万象接口必须使用https
  10. 'credentials'=> array(
  11. 'secretId' => $secretId,
  12. 'secretKey' => $secretKey)));
  13. try {
  14. // 提交一个语音识别任务 https://cloud.tencent.com/document/product/460/84798
  15. // 1. 使用模版
  16. $result = $cosClient->createVoiceSpeechRecognitionJobs(array(
  17. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  18. 'Tag' => 'SpeechRecognition',
  19. 'Input' => array(
  20. 'Object' => 'test.mp3',
  21. // 'Url' => '',
  22. ),
  23. 'Operation' => array(
  24. 'TemplateId' => '',
  25. // 'UserData' => '',
  26. // 'JobLevel' => '',
  27. 'Output' => array(
  28. 'Region' => $region,
  29. 'Bucket' => 'examplebucket-125000000',
  30. 'Object' => 'xxx.txt',
  31. ),
  32. ),
  33. // 'CallBack' => '',
  34. // 'CallBackFormat' => '',
  35. // 'CallBackType' => '',
  36. // 'CallBackMqConfig' => array(
  37. // 'MqRegion' => '',
  38. // 'MqMode' => '',
  39. // 'MqName' => '',
  40. // ),
  41. ));
  42. // 请求成功
  43. print_r($result);
  44. // 2. 自定义参数
  45. $result = $cosClient->createVoiceSpeechRecognitionJobs(array(
  46. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  47. 'Tag' => 'SpeechRecognition',
  48. 'Input' => array(
  49. 'Object' => 'test.mp3',
  50. // 'Url' => '',
  51. ),
  52. 'Operation' => array(
  53. // 'UserData' => '',
  54. // 'JobLevel' => '',
  55. 'SpeechRecognition' => array(
  56. 'EngineModelType' => '16k_zh',
  57. 'ChannelNum' => 1,
  58. 'ResTextFormat' => 1,
  59. 'FilterDirty' => 0,
  60. 'FilterModal' => 1,
  61. 'ConvertNumMode' => 0,
  62. 'SpeakerDiarization' => 1,
  63. 'SpeakerNumber' => 0,
  64. 'FilterPunc' => 0,
  65. // 'OutputFileType' => 'txt',
  66. // 'FlashAsr' => 'true',
  67. // 'Format' => 'mp3',
  68. // 'FirstChannelOnly' => 1,
  69. // 'WordInfo' => 1,
  70. // 'SentenceMaxLength' => 6,
  71. ),
  72. 'Output' => array(
  73. 'Region' => $region,
  74. 'Bucket' => 'examplebucket-125000000',
  75. 'Object' => 'xxx.txt',
  76. ),
  77. ),
  78. // 'CallBack' => '',
  79. // 'CallBackFormat' => '',
  80. // 'CallBackType' => '',
  81. // 'CallBackMqConfig' => array(
  82. // 'MqRegion' => '',
  83. // 'MqMode' => '',
  84. // 'MqName' => '',
  85. // ),
  86. ));
  87. // 请求成功
  88. print_r($result);
  89. } catch (\Exception $e) {
  90. // 请求失败
  91. echo($e);
  92. }