更新
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\service\chat\PrivateChatService;
|
||||
use app\common\service\chat\WhisperAsrService;
|
||||
|
||||
class ChatController extends BaseApiController
|
||||
{
|
||||
@@ -49,4 +50,17 @@ class ChatController extends BaseApiController
|
||||
}
|
||||
return $this->data($result['data']);
|
||||
}
|
||||
|
||||
public function voiceToText()
|
||||
{
|
||||
if ($this->userId <= 0) {
|
||||
return $this->fail('请先登录');
|
||||
}
|
||||
|
||||
$result = WhisperAsrService::transcribeUploadedFile($this->request->file('file'));
|
||||
if (empty($result['success'])) {
|
||||
return $this->fail($result['error'] ?? '语音识别失败');
|
||||
}
|
||||
return $this->data($result['data']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user