大赛管理功能
This commit is contained in:
parent
d20fe5fd27
commit
352c44a280
@ -28,55 +28,59 @@ public class VoiceService {
|
||||
@Qualifier(value = "baiDuVoiceService2")
|
||||
private IVoiceService2 voiceService;
|
||||
|
||||
public VoiceService(MinioClientConfig minioClientConfig){
|
||||
this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig,SYNTHESIS_FOLDER);
|
||||
this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig,RECOGNITION_FOLDER);
|
||||
public VoiceService(MinioClientConfig minioClientConfig) {
|
||||
this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig, SYNTHESIS_FOLDER);
|
||||
this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig, RECOGNITION_FOLDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音识别
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo){
|
||||
String fileName = String.format("%s.wav",System.currentTimeMillis());
|
||||
this.uploadFile(voiceRecognitionUtil,vo.getData(),fileName,RECOGNITION_FOLDER);
|
||||
public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo) {
|
||||
String fileName = String.format("%s.wav", System.currentTimeMillis());
|
||||
this.uploadFile(voiceRecognitionUtil, vo.getData(), fileName, RECOGNITION_FOLDER);
|
||||
String filePath = this.voiceRecognitionUtil.getDownLoadPath(fileName);
|
||||
VoiceAsrResult voiceResult = voiceService.recognition(vo);
|
||||
return new VoiceRecognitionResult(filePath,voiceResult.getResult().get(0));
|
||||
return new VoiceRecognitionResult(filePath, voiceResult.getResult().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音合成
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
public VoiceCompose synthesis(BaseVoiceSynthesisVO vo){
|
||||
public VoiceCompose synthesis(BaseVoiceSynthesisVO vo) {
|
||||
String md5Code = vo.md5Code();
|
||||
String fileName = String.format("%s.wav",md5Code);
|
||||
if(Objects.equals(false,this.voiceSynthesisUtil.checkFileIsExist(fileName))){
|
||||
byte[] data = voiceService.voiceSynthesis(vo);
|
||||
this.uploadFile(voiceSynthesisUtil,data,fileName,SYNTHESIS_FOLDER);
|
||||
String fileName = String.format("%s.wav", md5Code);
|
||||
if (Objects.equals(false, this.voiceSynthesisUtil.checkFileIsExist(fileName))) {
|
||||
byte[] bytes = voiceService.voiceSynthesis(vo);
|
||||
byte[] data = bytes;
|
||||
this.uploadFile(voiceSynthesisUtil, data, fileName, SYNTHESIS_FOLDER);
|
||||
}
|
||||
String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName);
|
||||
return new VoiceCompose(filePath,md5Code,vo.getMessage());
|
||||
return new VoiceCompose(filePath, md5Code, vo.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音合成返回原数据
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
public byte[] synthesisSource(BaseVoiceSynthesisVO vo){
|
||||
public byte[] synthesisSource(BaseVoiceSynthesisVO vo) {
|
||||
byte[] data = voiceService.voiceSynthesis(vo);
|
||||
return data;
|
||||
}
|
||||
|
||||
private void uploadFile(MinioClientUtil minioClient ,byte[] data,String fileName,String folder){
|
||||
try{
|
||||
minioClient.uploadBytes(data,fileName);
|
||||
}catch (SimulationException e){
|
||||
log.error("文件上传失败 folder:{},文件名:{} errmsg:{}",folder,fileName,e.getMessage(),e);
|
||||
private void uploadFile(MinioClientUtil minioClient, byte[] data, String fileName, String folder) {
|
||||
try {
|
||||
minioClient.uploadBytes(data, fileName);
|
||||
} catch (SimulationException e) {
|
||||
log.error("文件上传失败 folder:{},文件名:{} errmsg:{}", folder, fileName, e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -330,6 +330,6 @@
|
||||
</foreach>
|
||||
UNION all
|
||||
select A.id,A.name,A.desc,A.content,A.standards,A.scene_id,A.score_rule_id as ruleId,A.parent_id from racetr_task A, task B where A.parent_id = B.id)
|
||||
select A.id,A.name,A.desc,A.content,A.standards,A.score_rule_id as ruleId,A.parent_id,B.id as scene_id,B.type as sceneType from task A left join racetr_scene B on A.scene_id = B.id
|
||||
select A.id,A.name,A.desc,A.content,A.standards,A.ruleId ,A.parent_id,B.id as scene_id,B.type as sceneType from task A left join racetr_scene B on A.scene_id = B.id
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user