Voice2Text.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Services\Vendor\Xunfei;
  3. /**
  4. * 讯飞基类
  5. */
  6. class Voice2Text
  7. {
  8. public const BASE_URI = 'https://raasr.xfyun.cn/api/';
  9. /**
  10. * 发送请求对象
  11. */
  12. private $httpClient;
  13. /**
  14. * 构造方法
  15. */
  16. public function __construct()
  17. {
  18. $this->httpClient = new HttpBase(self::BASE_URI);
  19. }
  20. /**
  21. * 预处理方法
  22. */
  23. public function prepare($extData)
  24. {
  25. return $this->httpClient->postForm('prepare', $extData);
  26. }
  27. /**
  28. * 上传方法
  29. */
  30. public function upload($extData)
  31. {
  32. return $this->httpClient->postMulti('upload', $extData);
  33. }
  34. /**
  35. * 合并方法
  36. */
  37. public function merge($taskId)
  38. {
  39. $extData = [
  40. 'task_id' => $taskId,
  41. ];
  42. return $this->httpClient->postForm('merge', $extData);
  43. }
  44. /**
  45. * 预处理方法
  46. */
  47. public function getProgress($taskId)
  48. {
  49. $extData = [
  50. 'task_id' => $taskId,
  51. ];
  52. return $this->httpClient->postForm('getProgress', $extData);
  53. }
  54. /**
  55. * 预处理方法
  56. */
  57. public function getResult($taskId)
  58. {
  59. $extData = [
  60. 'task_id' => $taskId,
  61. ];
  62. return $this->httpClient->postForm('getResult', $extData);
  63. }
  64. }