Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tts-client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周亚武
tts-client
Commits
41dcfb5a
Commit
41dcfb5a
authored
Aug 22, 2024
by
周亚武
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改类文件读取规则
parent
b7bc0e40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
src/main/java/com/mortals/xhx/tts/UI/MainWindow.java
src/main/java/com/mortals/xhx/tts/UI/MainWindow.java
+10
-7
src/main/java/com/mortals/xhx/tts/utils/SpliceMp3Util.java
src/main/java/com/mortals/xhx/tts/utils/SpliceMp3Util.java
+2
-4
No files found.
src/main/java/com/mortals/xhx/tts/UI/MainWindow.java
View file @
41dcfb5a
...
@@ -15,7 +15,10 @@ import javax.swing.*;
...
@@ -15,7 +15,10 @@ 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.*
;
import
java.io.BufferedInputStream
;
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
;
...
@@ -262,7 +265,6 @@ public class MainWindow {
...
@@ -262,7 +265,6 @@ public class MainWindow {
//读取本地配置文件
//读取本地配置文件
reloadMessage
();
reloadMessage
();
people
=
"sound/"
+
speaker
+
"/"
;
people
=
"sound/"
+
speaker
+
"/"
;
//检测语音文件
//检测语音文件
scanVoice
();
scanVoice
();
//初始化mq等数据
//初始化mq等数据
...
@@ -271,13 +273,14 @@ public class MainWindow {
...
@@ -271,13 +273,14 @@ public class MainWindow {
}
}
private
void
scanVoice
(){
private
void
scanVoice
(){
try
{
try
{
ClassPathResource
classPathResource
=
new
ClassPathResource
(
people
);
ClassPathResource
classPathResource
=
new
ClassPathResource
(
people
+
"0.mp3"
);
File
file
=
classPathResource
.
getFile
();
File
file
=
classPathResource
.
getFile
();
if
(
file
.
exists
()){
if
(
file
.
exists
()){
pushInitMsg
(
"播音员("
+
speaker
+
")检测成功"
);
pushInitMsg
(
"播音员("
+
speaker
+
")检测成功"
);
}
else
{
}
else
{
pushInitMsg
(
"播音员("
+
speaker
+
")检测失败
->
文件不存在"
);
pushInitMsg
(
"播音员("
+
speaker
+
")检测失败
,
文件不存在"
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
pushInitMsg
(
"播音员("
+
speaker
+
")检测失败 ->"
+
e
);
pushInitMsg
(
"播音员("
+
speaker
+
")检测失败 ->"
+
e
);
...
@@ -752,8 +755,8 @@ public class MainWindow {
...
@@ -752,8 +755,8 @@ public class MainWindow {
try
{
try
{
//语音拼接
//语音拼接
List
<
String
>
audioList
=
new
ArrayList
<>();
List
<
String
>
audioList
=
new
ArrayList
<>();
String
englishPeople
=
"
sound/en/"
;
String
englishPeople
=
System
.
getProperty
(
"user.dir"
)+
"/src/main/resources/
sound/en/"
;
String
zangPeople
=
"
sound/zang/"
;
String
zangPeople
=
System
.
getProperty
(
"user.dir"
)+
"/src/main/resources/
sound/zang/"
;
if
(
english
){
//英双语
if
(
english
){
//英双语
audioList
.
add
(
englishPeople
+
"qing.mp3"
);
audioList
.
add
(
englishPeople
+
"qing.mp3"
);
...
...
src/main/java/com/mortals/xhx/tts/utils/SpliceMp3Util.java
View file @
41dcfb5a
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
;
...
@@ -19,8 +18,7 @@ public class SpliceMp3Util {
...
@@ -19,8 +18,7 @@ public class SpliceMp3Util {
*
*
*/
*/
public
static
String
fenLiData
(
String
path
)
throws
IOException
{
public
static
String
fenLiData
(
String
path
)
throws
IOException
{
ClassPathResource
classPathResource
=
new
ClassPathResource
(
"path"
);
File
file
=
new
File
(
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"
);
// 随机读取文件
...
@@ -214,7 +212,7 @@ public class SpliceMp3Util {
...
@@ -214,7 +212,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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment