Commit b7bc0e40 authored by 周亚武's avatar 周亚武

修改类文件读取规则

parent ff0eb958
...@@ -9,15 +9,13 @@ import com.mortals.xhx.tts.utils.*; ...@@ -9,15 +9,13 @@ import com.mortals.xhx.tts.utils.*;
import com.rabbitmq.client.*; import com.rabbitmq.client.*;
import javazoom.jl.player.Player; import javazoom.jl.player.Player;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.event.WindowListener; import java.awt.event.WindowListener;
import java.io.BufferedInputStream; import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
import java.util.concurrent.BlockingDeque; import java.util.concurrent.BlockingDeque;
...@@ -258,13 +256,13 @@ public class MainWindow { ...@@ -258,13 +256,13 @@ public class MainWindow {
pushInitMsg("程序开始启动"); pushInitMsg("程序开始启动");
readConfig(); readConfig();
if (deviceId == null) { if (deviceId == null) {
// deviceId = MacAddressReader.getMacAddress();
deviceId = ReadMacAdrss.getMacAddress(); deviceId = ReadMacAdrss.getMacAddress();
} }
//读取本地配置文件 //读取本地配置文件
reloadMessage(); reloadMessage();
people = System.getProperty("user.dir")+"/src/main/resources/sound/"+speaker+"/"; people = "sound/"+speaker+"/";
//检测语音文件 //检测语音文件
scanVoice(); scanVoice();
//初始化mq等数据 //初始化mq等数据
...@@ -273,12 +271,19 @@ public class MainWindow { ...@@ -273,12 +271,19 @@ public class MainWindow {
} }
private void scanVoice(){ private void scanVoice(){
File file = new File(people); try {
if(file.exists()){ ClassPathResource classPathResource = new ClassPathResource(people);
pushInitMsg("播音员("+speaker+")检测成功"); File file = classPathResource.getFile();
}else { if(file.exists()){
pushInitMsg("播音员("+speaker+")检测失败"); pushInitMsg("播音员("+speaker+")检测成功");
}else {
pushInitMsg("播音员("+speaker+")检测失败 ->文件不存在");
}
} catch (IOException e) {
pushInitMsg("播音员("+speaker+")检测失败 ->"+e);
throw new RuntimeException(e);
} }
} }
/** /**
...@@ -747,8 +752,8 @@ public class MainWindow { ...@@ -747,8 +752,8 @@ public class MainWindow {
try { try {
//语音拼接 //语音拼接
List<String> audioList = new ArrayList<>(); List<String> audioList = new ArrayList<>();
String englishPeople = System.getProperty("user.dir")+"/src/main/resources/sound/en/"; String englishPeople = "sound/en/";
String zangPeople = System.getProperty("user.dir")+"/src/main/resources/sound/zang/"; String zangPeople = "sound/zang/";
if(english){ //英双语 if(english){ //英双语
audioList.add(englishPeople+"qing.mp3"); audioList.add(englishPeople+"qing.mp3");
......
...@@ -158,7 +158,6 @@ public class SettingWindow { ...@@ -158,7 +158,6 @@ public class SettingWindow {
readConfig(); readConfig();
if(deviceId == null){ if(deviceId == null){
// deviceId = MacAddressReader.getMacAddress();
deviceId = ReadMacAdrss.getMacAddress(); deviceId = ReadMacAdrss.getMacAddress();
writeConfig(); writeConfig();
} }
......
package com.mortals.xhx.tts.utils; package com.mortals.xhx.tts.utils;
import org.aspectj.util.FileUtil; import org.aspectj.util.FileUtil;
import org.springframework.core.io.ClassPathResource;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -18,7 +19,8 @@ public class SpliceMp3Util { ...@@ -18,7 +19,8 @@ public class SpliceMp3Util {
* *
*/ */
public static String fenLiData(String path) throws IOException { public static String fenLiData(String path) throws IOException {
File file = new File(path);// 原文件 ClassPathResource classPathResource = new ClassPathResource("path");
File file = classPathResource.getFile();// 原文件
File file1 = new File(path + "01");// 分离ID3V2后的文件,这是个中间文件,最后要被删除 File file1 = new File(path + "01");// 分离ID3V2后的文件,这是个中间文件,最后要被删除
File file2 = new File(path + "001");// 分离id3v1后的文件 File file2 = new File(path + "001");// 分离id3v1后的文件
RandomAccessFile rf = new RandomAccessFile(file, "rw");// 随机读取文件 RandomAccessFile rf = new RandomAccessFile(file, "rw");// 随机读取文件
...@@ -212,7 +214,7 @@ public class SpliceMp3Util { ...@@ -212,7 +214,7 @@ public class SpliceMp3Util {
FileOutputStream out; FileOutputStream out;
for (int i = 0; i < pathList.size(); i++) { for (int i = 0; i < pathList.size(); i++) {
String fenLiData = fenLiData(pathList.get(i)); String fenLiData = fenLiData(pathList.get(i));
File file=new File(fenLiData); File file = new File(fenLiData);
FileInputStream in=new FileInputStream(file); FileInputStream in=new FileInputStream(file);
if(i == 0){ if(i == 0){
out=new FileOutputStream(file2); out=new FileOutputStream(file2);
......
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