This commit is contained in:
parent
6187e6d667
commit
ba1e057bce
@ -4,8 +4,9 @@ import club.joylink.rtss.services.voice.IVoiceTrainingService;
|
||||
import club.joylink.rtss.services.voice.baidu.TokenHolder;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.voice.VoiceVerifyResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -25,6 +26,7 @@ public class VoiceController {
|
||||
|
||||
/**
|
||||
* 语音识别
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@ -35,6 +37,7 @@ public class VoiceController {
|
||||
|
||||
/**
|
||||
* 查询语音识别错误集
|
||||
*
|
||||
* @param queryVO
|
||||
* @return
|
||||
*/
|
||||
@ -50,4 +53,12 @@ public class VoiceController {
|
||||
public String getBaiduToken() {
|
||||
return TokenHolder.getInstance().getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验语音识别结果
|
||||
*/
|
||||
@PostMapping("/verify")
|
||||
public VoiceVerifyResultVO verifyVoice(MultipartFile file, String text) {
|
||||
return iVoiceTrainingService.verifyVoice(file, text);
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,22 @@ package club.joylink.rtss.controller.voice;
|
||||
|
||||
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
|
||||
import club.joylink.rtss.services.voice.IVoiceDataConfigService;
|
||||
import club.joylink.rtss.services.voice.IVoiceTrainingService;
|
||||
import club.joylink.rtss.services.voice.baidu.TokenHolder;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.voice.VoiceDiscriminateConfigVO;
|
||||
import club.joylink.rtss.vo.voice.VoiceQueryVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 语音AI接口
|
||||
* 语音管理接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/voice/manage")
|
||||
@ -27,8 +28,9 @@ public class VoiceManageController {
|
||||
|
||||
|
||||
@PostMapping("saveOrUpdate")
|
||||
public void saveOrUpdate(@RequestBody VoiceDiscriminateConfigVO configVO, @RequestAttribute(name= AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
|
||||
this.configService.saveOrUpdate(configVO,userInfoVO);
|
||||
public void saveOrUpdate(@RequestBody VoiceDiscriminateConfigVO configVO,
|
||||
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
|
||||
this.configService.saveOrUpdate(configVO, userInfoVO);
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +40,7 @@ public class VoiceManageController {
|
||||
}
|
||||
|
||||
@GetMapping("query")
|
||||
public PageVO<VoiceDiscriminateConfigVO> query(@ModelAttribute VoiceQueryVO queryVO){
|
||||
public PageVO<VoiceDiscriminateConfigVO> query(@ModelAttribute VoiceQueryVO queryVO) {
|
||||
return this.configService.query(queryVO);
|
||||
}
|
||||
|
||||
@ -46,7 +48,9 @@ public class VoiceManageController {
|
||||
* 获取百度语音识别token
|
||||
*/
|
||||
@GetMapping("{id}/{status}")
|
||||
public void changeStatus(@PathVariable(value = "id") Long id,@PathVariable(value = "status")Integer status,@RequestAttribute(name= AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
|
||||
this.configService.changeStatus(id,status,userInfoVO);
|
||||
public void changeStatus(@PathVariable(value = "id") Long id,
|
||||
@PathVariable(value = "status") Integer status,
|
||||
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
|
||||
this.configService.changeStatus(id, status, userInfoVO);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.voice.VoiceVerifyResultVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
@ -16,4 +17,13 @@ public interface IVoiceTrainingService {
|
||||
VoiceRecognitionResult voiceRecognition(MultipartFile file);
|
||||
|
||||
VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath);
|
||||
|
||||
/**
|
||||
* 校验语音识别结果
|
||||
*
|
||||
* @param file 需要校验的语音
|
||||
* @param text 正确的文本
|
||||
* @return 校验结果
|
||||
*/
|
||||
VoiceVerifyResultVO verifyVoice(MultipartFile file, String text);
|
||||
}
|
||||
|
@ -3,20 +3,20 @@ package club.joylink.rtss.services.voice;
|
||||
import club.joylink.rtss.dao.CompetitionErrorSetDAO;
|
||||
import club.joylink.rtss.entity.CompetitionErrorSet;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler;
|
||||
import club.joylink.rtss.util.StrUtils;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO;
|
||||
import club.joylink.rtss.vo.voice.VoiceVerifyResultVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
public class VoiceTrainingService implements IVoiceTrainingService {
|
||||
@ -61,4 +61,11 @@ public class VoiceTrainingService implements IVoiceTrainingService {
|
||||
result.setResult(simulationVoiceHandler.handle(result.getResult()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoiceVerifyResultVO verifyVoice(MultipartFile file, String text) {
|
||||
VoiceRecognitionResult voiceRecognitionResult = voiceRecognition(file);
|
||||
boolean match = StrUtils.isMatch(text, voiceRecognitionResult.getResult(), 20);
|
||||
return new VoiceVerifyResultVO(voiceRecognitionResult.getResult(), match);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package club.joylink.rtss.vo.voice;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class VoiceVerifyResultVO {
|
||||
|
||||
private String text;
|
||||
|
||||
private boolean match;
|
||||
}
|
Loading…
Reference in New Issue
Block a user