<整个场景的语音校验接口>小改动
This commit is contained in:
parent
16c88d6357
commit
1660113cb3
@ -129,13 +129,13 @@ public class CompetitionPracticalController {
|
||||
|
||||
@ApiOperation("语音录制校验")
|
||||
@PostMapping("/voice/record/check/{recordId}")
|
||||
public VoiceErrorSetVO voiceRecordCheck(@PathVariable Long recordId, @RequestBody CommandPublishStatisticVO commandPublishStatisticVO) {
|
||||
public VoiceErrorVO voiceRecordCheck(@PathVariable Long recordId, @RequestBody CommandPublishStatisticVO commandPublishStatisticVO) {
|
||||
return iCompetitionPracticalService.voiceRecordCheck(recordId, commandPublishStatisticVO);
|
||||
}
|
||||
|
||||
@ApiOperation("语音录制校验(整个场景)")
|
||||
@GetMapping("/voice/record/check/{competitionId}/{userId}")
|
||||
public List<VoiceErrorSetVO> voiceRecordCheck(@PathVariable Long competitionId, @PathVariable Long userId) {
|
||||
public List<VoiceErrorVO> voiceRecordCheck(@PathVariable Long competitionId, @PathVariable Long userId) {
|
||||
return iCompetitionPracticalService.voiceRecordCheck(competitionId, userId);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorSetVO;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -41,7 +41,7 @@ public class VoiceController {
|
||||
|
||||
@ApiOperation("查询语音识别错误集")
|
||||
@GetMapping("/errorSet/paged")
|
||||
public PageVO<VoiceErrorSetVO> pagedQueryErrorSet(PageQueryVO queryVO) {
|
||||
public PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO) {
|
||||
return iVoiceTrainingService.pagedQueryErrorSet(queryVO);
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoiceErrorSetVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO) {
|
||||
public VoiceErrorVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO) {
|
||||
String actionContent = commandPublishStatisticVO.getActionVO().getContent();
|
||||
List<String> keyWords = commandPublishStatisticVO.getKeyWords();
|
||||
CompetitionVoiceRecord record = getVoiceRecordEntity(recordId);
|
||||
@ -499,7 +499,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VoiceErrorSetVO> voiceRecordCheck(Long competitionId, Long userId) {
|
||||
public List<VoiceErrorVO> voiceRecordCheck(Long competitionId, Long userId) {
|
||||
CompetitionWithBLOBs competitionWithBLOBs = getEntity(competitionId);
|
||||
CompetitionVO competitionVO = new CompetitionVO(competitionWithBLOBs);
|
||||
ScriptVO scriptVO = iScriptService.getDetailById(competitionWithBLOBs.getScriptId());
|
||||
@ -507,7 +507,9 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
|
||||
return records.stream().map(record -> {
|
||||
List<String> keyWords = competitionVO.getCmdPubStaVO(record.getCommandEvaluationRuleId()).getKeyWords();
|
||||
String actionContent = scriptVO.getActionById(record.getActionId()).getContent();
|
||||
return voiceRecordCheck(record, actionContent, keyWords);
|
||||
VoiceErrorVO errorVO = voiceRecordCheck(record, actionContent, keyWords);
|
||||
errorVO.setRecordId(record.getId());
|
||||
return errorVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -534,7 +536,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
|
||||
return competitionVoiceRecordDAO.selectByExample(example);
|
||||
}
|
||||
|
||||
private VoiceErrorSetVO voiceRecordCheck(CompetitionVoiceRecord record, String actionContent, List<String> keyWords) {
|
||||
private VoiceErrorVO voiceRecordCheck(CompetitionVoiceRecord record, String actionContent, List<String> keyWords) {
|
||||
String filePath = record.getFilePath();
|
||||
String uri = IVoiceService.FileUriPrefix + filePath;
|
||||
byte[] bytes = restTemplate.getForObject(uri, byte[].class);
|
||||
@ -543,8 +545,8 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
|
||||
String replacedContent = competitionAndScriptManager.pronunciationCheckAndReplace(result.getResult(), actionContent, errorPNCT);
|
||||
List<String> errorKW = new ArrayList<>();
|
||||
competitionAndScriptManager.keyWordsCheck(replacedContent, keyWords, errorKW);
|
||||
return new VoiceErrorSetVO(null, record.getUserId(), record.getCompetitionId(), record.getCommandEvaluationRuleId(), record.getActionId(), actionContent,
|
||||
replacedContent, errorKW, errorPNCT, filePath);
|
||||
return new VoiceErrorVO(null, record.getUserId(), record.getCompetitionId(), record.getCommandEvaluationRuleId(), record.getActionId(), actionContent,
|
||||
replacedContent, errorKW, errorPNCT, filePath, record.getId());
|
||||
}
|
||||
|
||||
private CompetitionVoiceRecord getVoiceRecordEntity(Long id) {
|
||||
|
@ -126,9 +126,9 @@ public interface ICompetitionPracticalService {
|
||||
|
||||
CompetitionVoiceRecordVO updateVoiceRecord(Long recordId, MultipartFile file, UserVO user);
|
||||
|
||||
VoiceErrorSetVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO);
|
||||
VoiceErrorVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO);
|
||||
|
||||
List<VoiceErrorSetVO> voiceRecordCheck(Long competitionId, Long userId);
|
||||
List<VoiceErrorVO> voiceRecordCheck(Long competitionId, Long userId);
|
||||
|
||||
List<CompetitionVoiceRecordVO> queryVoiceRecords(Long userId, Long competitionId);
|
||||
|
||||
|
@ -3,7 +3,7 @@ package club.joylink.rtss.services.voice;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorSetVO;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
@ -11,7 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
*/
|
||||
public interface IVoiceTrainingService {
|
||||
|
||||
PageVO<VoiceErrorSetVO> pagedQueryErrorSet(PageQueryVO queryVO);
|
||||
PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO);
|
||||
|
||||
VoiceRecognitionResult voiceRecognition(MultipartFile file);
|
||||
|
||||
|
@ -7,7 +7,7 @@ import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorSetVO;
|
||||
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -33,10 +33,10 @@ public class VoiceTrainingService implements IVoiceTrainingService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageVO<VoiceErrorSetVO> pagedQueryErrorSet(PageQueryVO queryVO) {
|
||||
public PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO) {
|
||||
Page<Object> page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
List<CompetitionErrorSet> sets = competitionErrorSetDAO.selectByExample(null);
|
||||
List<VoiceErrorSetVO> list = sets.stream().map(VoiceErrorSetVO::new).collect(Collectors.toList());
|
||||
List<VoiceErrorVO> list = sets.stream().map(VoiceErrorVO::new).collect(Collectors.toList());
|
||||
return PageVO.convert(page, list);
|
||||
}
|
||||
|
||||
|
@ -278,14 +278,14 @@ public class CompetitionAndScriptManager {
|
||||
//发音校验
|
||||
List<String> errorPNCT = new ArrayList<>(); //错误的发音
|
||||
String replacedContent = pronunciationCheckAndReplace(conversationMessage.getContent(), action.getContent(), errorPNCT);
|
||||
boolean match = CollectionUtils.isEmpty(errorPNCT); //发音正确
|
||||
boolean pronunciationRight = CollectionUtils.isEmpty(errorPNCT); //发音正确
|
||||
//关键词校验
|
||||
List<String> errorKW = new ArrayList<>(); //错误的关键词
|
||||
CommandPublishStatisticBO statistic = competition.findCommandPublishStatistic(action.getId());
|
||||
boolean keyWordsRight = keyWordsCheck(replacedContent, statistic.getKeyWords(), errorKW); //关键词正确
|
||||
match = match && keyWordsRight;
|
||||
pronunciationRight = pronunciationRight && keyWordsRight;
|
||||
|
||||
if (match) {
|
||||
if (pronunciationRight) {
|
||||
action.finish();
|
||||
applicationContext.publishEvent(new SimulationScriptActionFinishEvent(this, simulation, action));
|
||||
CommandPublishStatisticBO commandPublishStatistic = competition.findCommandPublishStatistic(action.getId());
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -13,7 +14,7 @@ import java.util.List;
|
||||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class VoiceErrorSetVO {
|
||||
public class VoiceErrorVO {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@ -27,17 +28,21 @@ public class VoiceErrorSetVO {
|
||||
|
||||
private String actionId;
|
||||
|
||||
private String right = "道岔试验";
|
||||
private String right;
|
||||
|
||||
private String result = "刀叉试验";
|
||||
private String result;
|
||||
|
||||
private List<String> keyWords = List.of("道岔");
|
||||
private List<String> keyWords;
|
||||
|
||||
private List<String> tripNumbers = List.of("2027");
|
||||
private List<String> tripNumbers;
|
||||
|
||||
private String filePath;
|
||||
|
||||
public VoiceErrorSetVO(CompetitionErrorSet set) {
|
||||
@Setter
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long recordId;
|
||||
|
||||
public VoiceErrorVO(CompetitionErrorSet set) {
|
||||
this.id = set.getId();
|
||||
this.userId = set.getUserId();
|
||||
this.competitionId = set.getId();
|
||||
@ -52,8 +57,8 @@ public class VoiceErrorSetVO {
|
||||
this.filePath = set.getFilePath();
|
||||
}
|
||||
|
||||
public VoiceErrorSetVO(Long id, Long userId, Long competitionId, Long cmdEvaRuleId, String actionId, String right,
|
||||
String result, List<String> keyWords, List<String> tripNumbers, String filePath) {
|
||||
public VoiceErrorVO(Long id, Long userId, Long competitionId, Long cmdEvaRuleId, String actionId, String right,
|
||||
String result, List<String> keyWords, List<String> tripNumbers, String filePath, Long recordId) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.competitionId = competitionId;
|
||||
@ -64,5 +69,6 @@ public class VoiceErrorSetVO {
|
||||
this.keyWords = keyWords;
|
||||
this.tripNumbers = tripNumbers;
|
||||
this.filePath = filePath;
|
||||
this.recordId = recordId;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user