语音管理
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
||||
import com.fuyuanshen.app.domain.dto.AppAudioFileDto;
|
||||
import com.fuyuanshen.app.domain.dto.AppFileDto;
|
||||
import com.fuyuanshen.app.domain.dto.TextToSpeechRequest;
|
||||
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
||||
import com.fuyuanshen.app.service.AudioProcessService;
|
||||
import com.fuyuanshen.app.service.VideoProcessService;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
@ -8,6 +13,7 @@ import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -56,6 +62,7 @@ public class AppVideoController extends BaseController {
|
||||
return R.ok(audioProcessService.generateStandardPcmData(text));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提取文本内容(只支持txt/docx)
|
||||
*/
|
||||
@ -65,4 +72,52 @@ public class AppVideoController extends BaseController {
|
||||
return R.ok("Success",audioProcessService.extract(file));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传音频文件进行处理
|
||||
* 支持MP3、WAV、PCM格式
|
||||
*/
|
||||
@PostMapping("/uploadAudioToOss")
|
||||
public R<String> uploadAudioToOss(@RequestParam("file") @ModelAttribute AppAudioFileDto bo) {
|
||||
try {
|
||||
String result = audioProcessService.uploadAudioToOss(bo);
|
||||
return R.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return R.fail("文件格式错误: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
|
||||
return R.fail("上传处理失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本转语音
|
||||
* 支持MP3、WAV、PCM格式
|
||||
*/
|
||||
@PostMapping("/ttsToOss")
|
||||
public R<String> textToSpeech(@RequestBody TextToSpeechRequest request) {
|
||||
try {
|
||||
if (request.getDeviceId() == null) {
|
||||
return R.fail("设备ID不能为空");
|
||||
}
|
||||
|
||||
String result = audioProcessService.textToSpeech(
|
||||
request.getDeviceId(),
|
||||
request.getText(),
|
||||
request.getFileSuffix()
|
||||
);
|
||||
return R.ok(result);
|
||||
} catch (Exception e) {
|
||||
return R.fail("文本转语音失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询语音文件列表
|
||||
*/
|
||||
@GetMapping("/queryAudioFileList")
|
||||
public R<List<AppFileVo>> queryAudioFileList(Long deviceId) {
|
||||
return R.ok(audioProcessService.queryAudioFileList(deviceId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user