Commit 2455dcf2 authored by chenzhao's avatar chenzhao

修改代码

parent fa8d7e5e
......@@ -138,7 +138,7 @@ public class SpeechTranscriberDemo {
//是否生成并返回标点符号。
transcriber.setEnablePunctuation(true);
//是否将返回结果规整化,比如将一百返回为100。
transcriber.setEnableITN(false);
transcriber.setEnableITN(true);
//设置vad断句参数。默认值:800ms,有效值:200ms~2000ms。
//transcriber.addCustomedParam("max_sentence_silence", 600);
......@@ -167,12 +167,12 @@ public class SpeechTranscriberDemo {
File file = new File(filepath);
FileInputStream fis = new FileInputStream(file);
byte[] b = new byte[332];
byte[] b = new byte[320];
int len;
DatagramSocket datagramSocket = new DatagramSocket();
while ((len = fis.read(b)) > 0) {
// logger.info("send data pack length: " + len);
datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 25006));
datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 25000));
transcriber.send(b, len);
//本案例用读取本地文件的形式模拟实时获取语音流并发送的,因为读取速度较快,这里需要设置sleep。
......@@ -221,7 +221,7 @@ public class SpeechTranscriberDemo {
System.exit(-1);
}*/
//本案例使用本地文件模拟发送实时流数据。您在实际使用时,可以实时采集或接收语音流并发送到ASR服务端。
String filepath = "C:\\Users\\DELL\\Desktop\\ffmpeg-4.4-full_build-shared\\bin\\jc06102.pcm";
String filepath = "C:\\Users\\DELL\\Desktop\\ffmpeg-4.4-full_build-shared\\bin\\1839.pcm";
SpeechTranscriberDemo demo = new SpeechTranscriberDemo(appKey, id, secret, url);
demo.process(filepath);
demo.shutdown();
......
......@@ -4,11 +4,13 @@ import org.springframework.stereotype.Repository;
import com.yeejoin.amos.maintenance.dao.entity.CheckInput;
import java.util.List;
@Repository("checkInput")
public interface ICheckInputDao extends BaseDao<CheckInput, Long> {
CheckInput findByCheckIdAndInputIdAndPointClassifyId(Long checkId,Long inputId,Long pointClassifyId);
CheckInput findByCheckId(Long checkId);
List<CheckInput> findByCheckId(Long checkId);
}
......@@ -787,9 +787,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
Map<String, Object> facility = this.buildFacilityDetail(point, planTask);
List<Map<String, Object>> itemList = this.buildCheckInputItem(routePointId);
// 修复bug:6131
CheckInput checkInput = checkInputDao.findByCheckId(Long.valueOf(planTaskDetailId));
List<CheckInput> checkInput = checkInputDao.findByCheckId(Long.valueOf(planTaskDetailId));
Map<String, Object> map = itemList.get(0);
map.put("inputValue", ObjectUtils.isEmpty(checkInput) ? "" : checkInput.getInputValue());
map.put("inputValue", CollectionUtils.isEmpty(checkInput) ? "" : checkInput.get(0).getInputValue());
result.put("facility", facility);
result.put("itemList", itemList);
return result;
......
......@@ -61,7 +61,8 @@ public class AppSpeechTranscriber {
SpeechTranscriber transcriber = null;
try {
//创建实例、建立连接。
byte[] b = new byte[332];
//byte[] b = new byte[332];
byte[] b = new byte[320];
DatagramPacket datagramPacket = new DatagramPacket(b, b.length);
logger.warn("serverSocket已启动,地址:" + localIpAddress
+ "监听端口:" + serverSocket.getLocalPort() + " 等待语音融合系统推送数据...");
......@@ -75,10 +76,11 @@ public class AppSpeechTranscriber {
transcriber.start();
}
idleTime = 0;
logger.warn("收到数据包:" + b.length);
// logger.warn("收到数据包:" + b.length);
//去掉前12个字节的rtp包头,后面的320字节为语音数据
//4秒未再次调用此方法,阿里云会抛出超时异常
transcriber.send(Arrays.copyOfRange(b, 12, b.length));
// transcriber.send(Arrays.copyOfRange(b, 12, b.length));
transcriber.send(b);
}
} catch (Exception e) {
logger.error(e.getMessage());
......@@ -110,25 +112,25 @@ public class AppSpeechTranscriber {
//输入音频采样率。
transcriber.setSampleRate(SampleRateEnum.SAMPLE_RATE_16K);
//是否返回中间识别结果。
transcriber.setEnableIntermediateResult(false);
transcriber.setEnableIntermediateResult(true);
//是否生成并返回标点符号。
transcriber.setEnablePunctuation(false);
//是否将返回结果规整化,比如将一百返回为100。
transcriber.setEnableITN(true);
//设置vad断句参数。默认值:800ms,有效值:200ms~2000ms。
//transcriber.addCustomedParam("max_sentence_silence", 600);
// transcriber.addCustomedParam("max_sentence_silence", 600);
//设置是否语义断句。
//transcriber.addCustomedParam("enable_semantic_sentence_detection",false);
transcriber.addCustomedParam("enable_semantic_sentence_detection",true);
//设置是否开启顺滑。
//transcriber.addCustomedParam("disfluency",true);
//设置是否开启词模式。
//transcriber.addCustomedParam("enable_words",true);
transcriber.addCustomedParam("enable_words",true);
//设置vad噪音阈值参数,参数取值为-1~+1,如-0.9、-0.8、0.2、0.9。
//取值越趋于-1,判定为语音的概率越大,亦即有可能更多噪声被当成语音被误识别。
//取值越趋于+1,判定为噪音的越多,亦即有可能更多语音段被当成噪音被拒绝识别。
//该参数属高级参数,调整需慎重和重点测试。
//transcriber.addCustomedParam("speech_noise_threshold",0.3);
transcriber.addCustomedParam("speech_noise_threshold",0.5);
//设置训练后的定制语言模型id。
//transcriber.addCustomedParam("customization_id","你的定制语言模型id");
//设置训练后的定制热词id。
......@@ -136,7 +138,7 @@ public class AppSpeechTranscriber {
//设置是否忽略单句超时。
transcriber.addCustomedParam("enable_ignore_sentence_timeout",false);
//vad断句开启后处理。
//transcriber.addCustomedParam("enable_vad_unify_post",false);
// transcriber.addCustomedParam("enable_vad_unify_post",false);
//此方法将以上参数设置序列化为JSON发送给服务端,并等待服务端确认。
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment