XunFei.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App\Services\Vendor\Xunfei;
  3. /**
  4. * 讯飞语音转化文字
  5. */
  6. class XunFei
  7. {
  8. /**
  9. * 预处理方法
  10. */
  11. public function prepare($filesize, $fileBasename)
  12. {
  13. $extData = [
  14. 'file_len' => $filesize,
  15. 'file_name' => 'name.' . $fileBasename,
  16. 'slice_num' => 1,
  17. ];
  18. $xunfei = new Voice2Text();
  19. return $xunfei->prepare($extData);
  20. }
  21. /**
  22. * 上传方法
  23. */
  24. public function upload($taskId, $fileContent)
  25. {
  26. $extData = [
  27. 'task_id' => $taskId,
  28. 'slice_id' => 'aaaaaaaaaa',
  29. 'content' => $fileContent,
  30. ];
  31. $xunfei = new Voice2Text();
  32. return $xunfei->upload($extData);
  33. }
  34. /**
  35. * 合并文件
  36. */
  37. public function merge($taskId)
  38. {
  39. $extData = [
  40. 'task_id' => $taskId,
  41. ];
  42. $xunfei = new Voice2Text();
  43. return $xunfei->merge($extData);
  44. }
  45. /**
  46. * 获取进度
  47. */
  48. public function getProgress($taskId)
  49. {
  50. $extData = [
  51. 'task_id' => $taskId,
  52. ];
  53. $xunfei = new Voice2Text();
  54. return $xunfei->getProgress($extData);
  55. }
  56. /**
  57. * 获取结果
  58. */
  59. public function getResult($taskId)
  60. {
  61. $extData = [
  62. 'task_id' => $taskId,
  63. ];
  64. $xunfei = new Voice2Text();
  65. return $xunfei->getResult($extData);
  66. }
  67. }