fix: 语音转文字接口完善
This commit is contained in:
parent
9f950db862
commit
9897dd9551
|
|
@ -3,6 +3,7 @@ package com.bjtds.brichat.controller;
|
||||||
|
|
||||||
import com.bjtds.brichat.entity.chat.ChatMessageSendReq;
|
import com.bjtds.brichat.entity.chat.ChatMessageSendReq;
|
||||||
import com.bjtds.brichat.service.ChatService;
|
import com.bjtds.brichat.service.ChatService;
|
||||||
|
import com.bjtds.brichat.util.ResultUtils;
|
||||||
import io.github.guoshiqiufeng.dify.chat.dto.request.ChatMessageSendRequest;
|
import io.github.guoshiqiufeng.dify.chat.dto.request.ChatMessageSendRequest;
|
||||||
import io.github.guoshiqiufeng.dify.chat.dto.response.ChatMessageSendCompletionResponse;
|
import io.github.guoshiqiufeng.dify.chat.dto.response.ChatMessageSendCompletionResponse;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -74,7 +75,7 @@ public class ChatController {
|
||||||
* @return 转换后的文字
|
* @return 转换后的文字
|
||||||
*/
|
*/
|
||||||
@PostMapping("/voiceToText")
|
@PostMapping("/voiceToText")
|
||||||
public String voiceToText(@RequestParam("file") MultipartFile file){
|
public ResultUtils voiceToText(@RequestParam("file") MultipartFile file){
|
||||||
try {
|
try {
|
||||||
log.info("开始语音转文字,文件名: {}, 文件大小: {} bytes",
|
log.info("开始语音转文字,文件名: {}, 文件大小: {} bytes",
|
||||||
file.getOriginalFilename(), file.getSize());
|
file.getOriginalFilename(), file.getSize());
|
||||||
|
|
@ -111,7 +112,7 @@ public class ChatController {
|
||||||
Map<String, Object> responseBody = response.getBody();
|
Map<String, Object> responseBody = response.getBody();
|
||||||
String text = (String) responseBody.get("text");
|
String text = (String) responseBody.get("text");
|
||||||
log.info("语音转文字成功,结果: {}", text);
|
log.info("语音转文字成功,结果: {}", text);
|
||||||
return text;
|
return ResultUtils.success(text);
|
||||||
} else {
|
} else {
|
||||||
log.error("语音转文字失败,响应状态: {}, 响应体: {}",
|
log.error("语音转文字失败,响应状态: {}, 响应体: {}",
|
||||||
response.getStatusCode(), response.getBody());
|
response.getStatusCode(), response.getBody());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue