-
Bug
-
Resolution: Incomplete
-
P4
-
8u141
-
generic
-
windows_2012
A DESCRIPTION OF THE PROBLEM :
Use jdk 1.8 to access jacob 20 to convert the string type into a wav file. Run on a windows 2012 server. The system is down.
REGRESSION : Last worked in version 8u401
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use jacob to generate wav files. This problem occurs after the system is running for 6 hours.
---------- BEGIN SOURCE ----------
@GetMapping(value = "/getMp3")
public CommonResult<jhczVo> getMp3(HttpServletResponse response, @RequestParam("readStr") String ip) throws IOException {
System.out.println("生成文件的镇海的ip" + ip);
ConsultingRoomIp getMp3Ip = smallscreen.getDocDept(ip);
List<PatientSignIn> ghhzghjls = jhczVo(getMp3Ip);
Map<String, List<PatientSignIn>> groupedMap = ghhzghjls.stream()
.collect(Collectors.groupingBy(PatientSignIn::getStatus));
List<ViewSingInHzb> viewSingIList =PatientSinController.viewSingInHzbList;
System.out.println("groupedMap的内容"+groupedMap);
String jz = groupedMap.get("2").get(groupedMap.get("2").size()-1).getXm();
String readStr = "请患者" + jz + "到" + getMp3Ip.getZsxx() + "就诊";
if (HosptColler.XThosptVo.getWait().equals("1")) {
String ddjza = groupedMap.get("1").get(0).getXm();
String ddjzStr = "请患者" + ddjza + ",患者在" + getMp3Ip.getZsxx() + "外,等候就诊";
readStr += ddjzStr;
}
Iterator<ViewSingInHzb> iterator = viewSingIList.iterator();
while (iterator.hasNext()) {
ViewSingInHzb item = iterator.next();
if (item.getJhxpip().equals(ip)) {
iterator.remove(); // 使用迭代器的 remove 方法移除当前项
}
}
String fileName = HosptColler.XThosptVo.getMavadd();
String wavName = groupedMap.get("2").get(groupedMap.size()-1).getMZH();
try {
VoiceReading videoReading = new VoiceReading();
VoiceReading.audioFile(readStr, fileName, wavName+jz);
} catch (Exception e) {
throw new RuntimeException(e);
}
Integer order = HosptColler.XThosptVo.getOrder();
if (HosptColler.XThosptVo.getOrder() <= 0) {
order = 1;
}
jhczVo jhczVo = new jhczVo();
jhczVo.setOrder(order);
jhczVo.setFileName(wavName+jz + ".wav");
log.info("jhczVo的内容"+jhczVo);
return CommonResult.success(jhczVo);
}
@Slf4j
public class VoiceReading {
private static final ReentrantLock lock = new ReentrantLock();
// //输入文本内容,生成文件地址 text为输入的文本信息
// public static void audioFile(String text, String mavadd, String jz) {
// Dispatch spAudioFormat = null;
// //音频文件输出流
// Dispatch spFileStream = null;
// //构建音频对象
// Dispatch spVoice = null;
// try {
// //jacob.dll没成功安装,执行这一步会出错
// //构建音频格式 调用注册表应用
// spAudioFormat = new ActiveXComponent("Sapi.SpAudioFormat").getObject();
// //音频文件输出流
// spFileStream = new ActiveXComponent("Sapi.SpFileStream").getObject();
// //构建音频对象
// spVoice = new ActiveXComponent("Sapi.SpVoice").getObject();
// Dispatch spObjectToken = Dispatch.call(spVoice, "GetVoices").toDispatch();
// //设置spAudioFormat音频流格式类型22
// Dispatch.put(spAudioFormat, "Type", new Variant(0));
// //设置spFileStream文件输出流的音频格式
// Dispatch.putRef(spFileStream, "Format", spAudioFormat);
//// Dispatch.put(spVoice, "Voice", voice);
//
// //设置spFileStream文件输出流参数地址等
// Dispatch.call(spFileStream, "Open", new Variant(mavadd + jz + ".wav"), new Variant(3), new Variant(true));
// //设置spVoice声音对象的音频输出流为输出文件对象
// Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream);
// //设置spVoice声音对象的音量大小100
// Dispatch.put(spVoice, "Volume", new Variant(100));
// //设置spVoice声音对象的速度 0为正常速度,范围【..-2 -1 0 1 2..】
// Dispatch.put(spVoice, "Rate", new Variant(0));
// //设置spVoice声音对象中的文本内容
// Dispatch.call(spVoice, "Speak", new Variant(text));
// //关闭spFileStream输出文件
// Dispatch.call(spFileStream, "Close");
// } catch (Exception e) {
// e.getMessage();
// e.printStackTrace(); // 打印异常堆栈信息
// } finally {
// // 释放资源
// if (spVoice != null) {
// spVoice.safeRelease();
// }
// if (spAudioFormat != null) {
// spAudioFormat.safeRelease();
// }
// if (spFileStream != null) {
// spFileStream.safeRelease();
// }
// }
// }
public static void audioFile(String text, String mavadd, String jz) {
lock.lock(); // 获取锁
Dispatch spAudioFormat = null;
Dispatch spFileStream = null;
Dispatch spVoice = null;
try {
// 尝试创建COM对象并配置
try {
spAudioFormat = new ActiveXComponent("Sapi.SpAudioFormat").getObject();
spFileStream = new ActiveXComponent("Sapi.SpFileStream").getObject();
spVoice = new ActiveXComponent("Sapi.SpVoice").getObject();
} catch (Exception e) {
log.error("创建 COM 对象失败: {}", e.getMessage());
return; // 提前返回,避免进一步的操作
}
try {
Dispatch.put(spAudioFormat, "Type", new Variant(0));
Dispatch.putRef(spFileStream, "Format", spAudioFormat);
Dispatch.call(spFileStream, "Open", new Variant(mavadd + jz + ".wav"), new Variant(3), new Variant(true));
Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream);
Dispatch.put(spVoice, "Volume", new Variant(100));
Dispatch.put(spVoice, "Rate", new Variant(0));
Dispatch.call(spVoice, "Speak", new Variant(text));
} catch (Exception e) {
log.error("配置语音或文件流失败: {}", e.getMessage());
} finally {
// 尝试关闭文件流
if (spFileStream != null) {
try {
Dispatch.call(spFileStream, "Close");
} catch (Exception e) {
log.error("关闭文件流失败: {}", e.getMessage());
}
}
}
} finally {
// 释放所有资源
closeQuietly(spVoice);
closeQuietly(spFileStream);
closeQuietly(spAudioFormat);
if (lock.isHeldByCurrentThread()) {
lock.unlock(); // 释放锁
}
}
}
private static void closeQuietly(Dispatch dispatchObject) {
if (dispatchObject != null) {
try {
dispatchObject.safeRelease();
} catch (Exception ex) {
log.error("释放资源时发生错误: {}", ex.getMessage());
}
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Use jdk 1.8 to access jacob 20 to convert the string type into a wav file. Run on a windows 2012 server. The system is down.
REGRESSION : Last worked in version 8u401
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use jacob to generate wav files. This problem occurs after the system is running for 6 hours.
---------- BEGIN SOURCE ----------
@GetMapping(value = "/getMp3")
public CommonResult<jhczVo> getMp3(HttpServletResponse response, @RequestParam("readStr") String ip) throws IOException {
System.out.println("生成文件的镇海的ip" + ip);
ConsultingRoomIp getMp3Ip = smallscreen.getDocDept(ip);
List<PatientSignIn> ghhzghjls = jhczVo(getMp3Ip);
Map<String, List<PatientSignIn>> groupedMap = ghhzghjls.stream()
.collect(Collectors.groupingBy(PatientSignIn::getStatus));
List<ViewSingInHzb> viewSingIList =PatientSinController.viewSingInHzbList;
System.out.println("groupedMap的内容"+groupedMap);
String jz = groupedMap.get("2").get(groupedMap.get("2").size()-1).getXm();
String readStr = "请患者" + jz + "到" + getMp3Ip.getZsxx() + "就诊";
if (HosptColler.XThosptVo.getWait().equals("1")) {
String ddjza = groupedMap.get("1").get(0).getXm();
String ddjzStr = "请患者" + ddjza + ",患者在" + getMp3Ip.getZsxx() + "外,等候就诊";
readStr += ddjzStr;
}
Iterator<ViewSingInHzb> iterator = viewSingIList.iterator();
while (iterator.hasNext()) {
ViewSingInHzb item = iterator.next();
if (item.getJhxpip().equals(ip)) {
iterator.remove(); // 使用迭代器的 remove 方法移除当前项
}
}
String fileName = HosptColler.XThosptVo.getMavadd();
String wavName = groupedMap.get("2").get(groupedMap.size()-1).getMZH();
try {
VoiceReading videoReading = new VoiceReading();
VoiceReading.audioFile(readStr, fileName, wavName+jz);
} catch (Exception e) {
throw new RuntimeException(e);
}
Integer order = HosptColler.XThosptVo.getOrder();
if (HosptColler.XThosptVo.getOrder() <= 0) {
order = 1;
}
jhczVo jhczVo = new jhczVo();
jhczVo.setOrder(order);
jhczVo.setFileName(wavName+jz + ".wav");
log.info("jhczVo的内容"+jhczVo);
return CommonResult.success(jhczVo);
}
@Slf4j
public class VoiceReading {
private static final ReentrantLock lock = new ReentrantLock();
// //输入文本内容,生成文件地址 text为输入的文本信息
// public static void audioFile(String text, String mavadd, String jz) {
// Dispatch spAudioFormat = null;
// //音频文件输出流
// Dispatch spFileStream = null;
// //构建音频对象
// Dispatch spVoice = null;
// try {
// //jacob.dll没成功安装,执行这一步会出错
// //构建音频格式 调用注册表应用
// spAudioFormat = new ActiveXComponent("Sapi.SpAudioFormat").getObject();
// //音频文件输出流
// spFileStream = new ActiveXComponent("Sapi.SpFileStream").getObject();
// //构建音频对象
// spVoice = new ActiveXComponent("Sapi.SpVoice").getObject();
// Dispatch spObjectToken = Dispatch.call(spVoice, "GetVoices").toDispatch();
// //设置spAudioFormat音频流格式类型22
// Dispatch.put(spAudioFormat, "Type", new Variant(0));
// //设置spFileStream文件输出流的音频格式
// Dispatch.putRef(spFileStream, "Format", spAudioFormat);
//// Dispatch.put(spVoice, "Voice", voice);
//
// //设置spFileStream文件输出流参数地址等
// Dispatch.call(spFileStream, "Open", new Variant(mavadd + jz + ".wav"), new Variant(3), new Variant(true));
// //设置spVoice声音对象的音频输出流为输出文件对象
// Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream);
// //设置spVoice声音对象的音量大小100
// Dispatch.put(spVoice, "Volume", new Variant(100));
// //设置spVoice声音对象的速度 0为正常速度,范围【..-2 -1 0 1 2..】
// Dispatch.put(spVoice, "Rate", new Variant(0));
// //设置spVoice声音对象中的文本内容
// Dispatch.call(spVoice, "Speak", new Variant(text));
// //关闭spFileStream输出文件
// Dispatch.call(spFileStream, "Close");
// } catch (Exception e) {
// e.getMessage();
// e.printStackTrace(); // 打印异常堆栈信息
// } finally {
// // 释放资源
// if (spVoice != null) {
// spVoice.safeRelease();
// }
// if (spAudioFormat != null) {
// spAudioFormat.safeRelease();
// }
// if (spFileStream != null) {
// spFileStream.safeRelease();
// }
// }
// }
public static void audioFile(String text, String mavadd, String jz) {
lock.lock(); // 获取锁
Dispatch spAudioFormat = null;
Dispatch spFileStream = null;
Dispatch spVoice = null;
try {
// 尝试创建COM对象并配置
try {
spAudioFormat = new ActiveXComponent("Sapi.SpAudioFormat").getObject();
spFileStream = new ActiveXComponent("Sapi.SpFileStream").getObject();
spVoice = new ActiveXComponent("Sapi.SpVoice").getObject();
} catch (Exception e) {
log.error("创建 COM 对象失败: {}", e.getMessage());
return; // 提前返回,避免进一步的操作
}
try {
Dispatch.put(spAudioFormat, "Type", new Variant(0));
Dispatch.putRef(spFileStream, "Format", spAudioFormat);
Dispatch.call(spFileStream, "Open", new Variant(mavadd + jz + ".wav"), new Variant(3), new Variant(true));
Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream);
Dispatch.put(spVoice, "Volume", new Variant(100));
Dispatch.put(spVoice, "Rate", new Variant(0));
Dispatch.call(spVoice, "Speak", new Variant(text));
} catch (Exception e) {
log.error("配置语音或文件流失败: {}", e.getMessage());
} finally {
// 尝试关闭文件流
if (spFileStream != null) {
try {
Dispatch.call(spFileStream, "Close");
} catch (Exception e) {
log.error("关闭文件流失败: {}", e.getMessage());
}
}
}
} finally {
// 释放所有资源
closeQuietly(spVoice);
closeQuietly(spFileStream);
closeQuietly(spAudioFormat);
if (lock.isHeldByCurrentThread()) {
lock.unlock(); // 释放锁
}
}
}
private static void closeQuietly(Dispatch dispatchObject) {
if (dispatchObject != null) {
try {
dispatchObject.safeRelease();
} catch (Exception ex) {
log.error("释放资源时发生错误: {}", ex.getMessage());
}
}
}
}
---------- END SOURCE ----------
FREQUENCY : always