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
cf0fd371
Commit
cf0fd371
authored
Jul 26, 2024
by
周亚武
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
双语叫号
parent
706e3cb7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
280 additions
and
86 deletions
+280
-86
src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartedService.java
...als/xhx/daemon/applicationservice/DemoStartedService.java
+2
-1
src/main/java/com/mortals/xhx/tts/UI/MainWindow.java
src/main/java/com/mortals/xhx/tts/UI/MainWindow.java
+264
-73
src/main/java/com/mortals/xhx/tts/UI/SettingWindow.java
src/main/java/com/mortals/xhx/tts/UI/SettingWindow.java
+10
-10
src/main/java/com/mortals/xhx/tts/utils/SpliceMp3Util.java
src/main/java/com/mortals/xhx/tts/utils/SpliceMp3Util.java
+4
-2
src/main/resources/img/icon.png
src/main/resources/img/icon.png
+0
-0
No files found.
src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartedService.java
View file @
cf0fd371
...
@@ -41,8 +41,9 @@ public class DemoStartedService implements IApplicationStartedService {
...
@@ -41,8 +41,9 @@ public class DemoStartedService implements IApplicationStartedService {
log
.
info
(
"configPath:{}"
,
configPath
);
log
.
info
(
"configPath:{}"
,
configPath
);
log
.
info
(
"host:{}"
,
host
);
log
.
info
(
"host:{}"
,
host
);
log
.
info
(
"version:{}"
,
version
);
log
.
info
(
"version:{}"
,
version
);
MainWindow
.
getInstance
().
initWindow
(
configPath
,
host
,
version
);
SettingWindow
.
getInstance
().
initWindow
(
configPath
,
host
);
SettingWindow
.
getInstance
().
initWindow
(
configPath
,
host
);
MainWindow
.
getInstance
().
initWindow
(
configPath
,
host
,
version
);
log
.
info
(
"初始化托盘完成!"
);
log
.
info
(
"初始化托盘完成!"
);
...
...
src/main/java/com/mortals/xhx/tts/UI/MainWindow.java
View file @
cf0fd371
package
com.mortals.xhx.tts.UI
;
package
com.mortals.xhx.tts.UI
;
import
cn.hutool.core.codec.Base64Decoder
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpUtil
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.mortals.xhx.common.utils.EncryptUtil
;
import
com.mortals.xhx.common.utils.EncryptUtil
;
import
com.mortals.xhx.tts.bean.*
;
import
com.mortals.xhx.tts.bean.*
;
import
com.mortals.xhx.tts.utils.*
;
import
com.mortals.xhx.tts.utils.*
;
import
com.rabbitmq.client.*
;
import
com.rabbitmq.client.*
;
import
com.sun.media.jfxmedia.events.PlayerStateEvent
;
import
com.sun.media.jfxmedia.events.PlayerStateListener
;
import
javafx.scene.media.Media
;
import
javafx.scene.media.MediaPlayer
;
import
javafx.scene.media.MediaPlayerBuilder
;
import
javazoom.jl.player.Player
;
import
javazoom.jl.player.Player
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
sun.net.www.protocol.file.Handler
;
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
...
@@ -99,6 +91,9 @@ public class MainWindow {
...
@@ -99,6 +91,9 @@ public class MainWindow {
Player
player
;
Player
player
;
//发音人
String
people
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
//初始化窗口
//初始化窗口
getInstance
().
initWindow
(
getInstance
().
configPath
,
getInstance
().
host
,
instance
.
version
);
getInstance
().
initWindow
(
getInstance
().
configPath
,
getInstance
().
host
,
instance
.
version
);
...
@@ -236,7 +231,10 @@ public class MainWindow {
...
@@ -236,7 +231,10 @@ public class MainWindow {
@Override
@Override
public
void
windowClosed
(
WindowEvent
e
)
{
public
void
windowClosed
(
WindowEvent
e
)
{
if
(
player
!=
null
){
player
.
close
();
player
=
null
;
}
}
}
@Override
@Override
...
@@ -263,11 +261,25 @@ public class MainWindow {
...
@@ -263,11 +261,25 @@ public class MainWindow {
deviceId
=
MacAddressReader
.
getMacAddress
();
deviceId
=
MacAddressReader
.
getMacAddress
();
}
}
//读取本地配置文件
reloadMessage
();
reloadMessage
();
people
=
System
.
getProperty
(
"user.dir"
)+
"/src/main/resources/sound/"
+
speaker
+
"/"
;
//检测语音文件
scanVoice
();
//初始化mq等数据
initData
();
initData
();
}
}
private
void
scanVoice
(){
File
file
=
new
File
(
people
);
if
(
file
.
exists
()){
pushInitMsg
(
"播音员("
+
speaker
+
")检测成功"
);
}
else
{
pushInitMsg
(
"播音员("
+
speaker
+
")检测失败"
);
}
}
/**
/**
* 初始化数据
* 初始化数据
*/
*/
...
@@ -358,31 +370,58 @@ public class MainWindow {
...
@@ -358,31 +370,58 @@ public class MainWindow {
@Override
@Override
public
void
handleDelivery
(
String
consumerTag
,
Envelope
envelope
,
AMQP
.
BasicProperties
properties
,
byte
[]
body
)
throws
IOException
{
public
void
handleDelivery
(
String
consumerTag
,
Envelope
envelope
,
AMQP
.
BasicProperties
properties
,
byte
[]
body
)
throws
IOException
{
String
message
=
new
String
(
body
,
"UTF-8"
);
String
message
=
new
String
(
body
,
"UTF-8"
);
pushRabbitMsg
(
message
);
try
{
handleVoiceMsg
(
message
);
RabbitMessageBean
rb
=
gson
.
fromJson
(
message
,
RabbitMessageBean
.
class
);
String
type
=
rb
.
getHeaders
().
getData
().
getMessageType
();
if
(
type
.
equals
(
"call"
)){
//表示叫号消息
String
data
=
EncryptUtil
.
base64ToString
(
rb
.
getData
());
pushRabbitMsg
(
data
);
handleVoiceMsg
(
data
);
}
}
catch
(
Exception
e
)
{
pushRabbitMsg
(
"异常消息:"
+
message
);
log
.
error
(
"异常消息:"
+
message
);
}
}
}
};
};
// 监听队列,autoAck参数为true表示自动确认
// 监听队列,autoAck参数为true表示自动确认
channel
.
basicConsume
(
downTopicFilter
,
true
,
consumer
);
channel
.
basicConsume
(
downTopicFilter
,
true
,
consumer
);
pushInitMsg
(
"RabbitMq链接成功"
);
pushInitMsg
(
"消息服务链接成功"
);
pushInitMsg
(
"初始化完成"
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
pushInitMsg
(
"
MQ
链接异常:"
+
e
.
toString
());
pushInitMsg
(
"
消息服务
链接异常:"
+
e
.
toString
());
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
// while (true){
// String data = "{\"qid\":670313,\"flownum\":\"ZH00"+(msgIndex%100)+"\",\"windowfromnum\":\"A05\"}";
// pushRabbitMsg(data);
// handleVoiceMsg(data);
//
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
//
//
// }
}
}
/**
/**
* 刷新底部提示消息
* 刷新底部提示消息
*/
*/
private
void
reloadMessage
(){
private
void
reloadMessage
(){
noticeArea
.
setText
(
"<html>&emsp软件版本 V"
+
version
+
"  
  服务器:"
+
host
+
"    英双语:"
+(
english
?
"开启"
:
"关闭"
)
+
noticeArea
.
setText
(
"<html>&emsp软件版本 V"
+
version
+
"  
设备编号:"
+
deviceId
+
"  服务器:"
+
host
+
"  
  藏双语:"
+(
zang
?
"开启"
:
"关闭"
)
+
"    播音员:"
+
speaker
+
"  
英双语:"
+(
english
?
"开启"
:
"关闭"
)
+
"  藏双语:"
+(
zang
?
"开启"
:
"关闭"
)
+
"
<br> 消息服务器:"
+
rabbitHost
+
"    虚拟机:"
+
virtualHost
+
"    队列:"
+
downTopicFilter
+
"
  播音员:"
+
speaker
+
"<br> 消息服务器:"
+
rabbitHost
+
"    虚拟机:"
+
virtualHost
+
"    
本机ip:"
+
MacAddressReader
.
getLocalIp
()+
"<br> 设备状态:"
+(
enabled
==
0
?
"禁用"
:
"启用"
)+
"    
队列:"
+
downTopicFilter
+
"    本机ip:"
+
MacAddressReader
.
getLocalIp
(
)+
"
    设备来源:"
+(
isOld
?
"利旧设备"
:
"新设备"
)+
"    站点编码:"
+
siteCode
+
"
<br> 设备状态:"
+(
enabled
==
0
?
"禁用"
:
"启用"
)+
"    设备来源:"
+(
isOld
?
"利旧设备"
:
"新设备"
)
+
"    站点名称:"
+
siteName
);
"    站点
编码:"
+
siteCode
+
"    站点
名称:"
+
siteName
);
}
}
/**
/**
...
@@ -391,7 +430,7 @@ public class MainWindow {
...
@@ -391,7 +430,7 @@ public class MainWindow {
* @return
* @return
*/
*/
private
String
addTimeStamp
(
String
mess
){
private
String
addTimeStamp
(
String
mess
){
return
" "
+
mess
+
" -- "
+
DateUtil
.
date
()+
"\n"
;
return
" "
+
mess
+
" -- "
+
DateUtil
.
date
()
.
toString
(
"HH:mm:ss"
)
+
"\n"
;
}
}
/**
/**
...
@@ -405,7 +444,7 @@ public class MainWindow {
...
@@ -405,7 +444,7 @@ public class MainWindow {
msgIndex
=
0
;
msgIndex
=
0
;
msgArea
.
setText
(
""
);
msgArea
.
setText
(
""
);
}
}
msgArea
.
append
(
addTimeStamp
(
msg
));
msgArea
.
append
(
addTimeStamp
(
msg
Index
+
":"
+
msg
));
}
}
/**
/**
...
@@ -432,25 +471,26 @@ public class MainWindow {
...
@@ -432,25 +471,26 @@ public class MainWindow {
/**
/**
* 添加语音播报消息
* 添加语音播报消息
* @param
message
* @param
data
*/
*/
private
void
handleVoiceMsg
(
String
message
){
private
void
handleVoiceMsg
(
String
data
){
try
{
new
Thread
(
new
Runnable
()
{
RabbitMessageBean
rb
=
gson
.
fromJson
(
message
,
RabbitMessageBean
.
class
);
@Override
String
type
=
rb
.
getHeaders
().
getData
().
getMessageType
();
public
void
run
()
{
if
(
type
.
equals
(
"call"
)){
//表示叫号消息
try
{
String
data
=
EncryptUtil
.
base64ToString
(
rb
.
getData
());
FlowNumBean
fnb
=
gson
.
fromJson
(
data
,
FlowNumBean
.
class
);
FlowNumBean
fnb
=
gson
.
fromJson
(
data
,
FlowNumBean
.
class
);
flowNumBeanList
.
putLast
(
fnb
);
flowNumBeanList
.
putLast
(
fnb
);
if
(!
isCalling
)
{
if
(!
isCalling
){
isCalling
=
true
;
isCalling
=
true
;
calling
();
calling
();
}
}
catch
(
Exception
e
)
{
pushVoiceMsg
(
"添加语音队列失败:"
+
data
);
log
.
error
(
"添加语音队列失败:"
+
data
);
}
}
}
}
}
catch
(
Exception
e
)
{
}).
start
();
pushVoiceMsg
(
"添加语音队列失败:"
+
message
);
log
.
error
(
"添加语音队列失败:"
+
message
);
}
}
}
...
@@ -537,7 +577,6 @@ public class MainWindow {
...
@@ -537,7 +577,6 @@ public class MainWindow {
}
else
{
}
else
{
isShow
=
false
;
isShow
=
false
;
pushInitMsg
(
"读取配置文件失败->配置文件为空"
);
pushInitMsg
(
"读取配置文件失败->配置文件为空"
);
log
.
info
(
"配置文件为空"
);
;
}
}
...
@@ -567,55 +606,53 @@ public class MainWindow {
...
@@ -567,55 +606,53 @@ public class MainWindow {
FlowNumBean
flowNumBean
=
flowNumBeanList
.
takeFirst
();
FlowNumBean
flowNumBean
=
flowNumBeanList
.
takeFirst
();
String
flownum
=
flowNumBean
.
getFlownum
();
String
flownum
=
flowNumBean
.
getFlownum
();
String
windownum
=
flowNumBean
.
getWindowfromnum
();
String
windownum
=
flowNumBean
.
getWindowfromnum
();
//选择发音人
String
peple
=
System
.
getProperty
(
"user.dir"
)+
"/src/main/resources/sound/"
+
speaker
+
"/"
;
//语音拼接
//语音拼接
List
<
String
>
audioList
=
new
ArrayList
<>();
List
<
String
>
audioList
=
new
ArrayList
<>();
audioList
.
add
(
peple
+
"qing.mp3"
);
audioList
.
add
(
pe
o
ple
+
"qing.mp3"
);
//拼接排队号
//拼接排队号
if
(
flownum
.
length
()
>
0
){
if
(
flownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
flownum
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
flownum
.
length
();
i
++)
{
audioList
.
add
(
peple
+
flownum
.
charAt
(
i
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
flownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
}
audioList
.
add
(
peple
+
"haodao.mp3"
);
audioList
.
add
(
pe
o
ple
+
"haodao.mp3"
);
//拼接窗口号
//拼接窗口号
if
(
speaker
.
equals
(
"en"
)){
//发音人为英文发音
if
(
speaker
.
equals
(
"en"
)){
//发音人为英文发音
if
(
windownum
.
length
()
>
0
){
if
(
windownum
.
length
()
>
0
){
Pattern
p
=
Pattern
.
compile
(
".*[a-zA-Z]+.*"
);
Pattern
p
=
Pattern
.
compile
(
".*[a-zA-Z]+.*"
);
if
(
p
.
matcher
(
windownum
).
matches
()){
//窗口号中有字母
if
(
p
.
matcher
(
windownum
).
matches
()){
//窗口号中有字母
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
peple
+
windownum
.
charAt
(
i
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
else
{
//窗口号为纯数字
}
else
{
//窗口号为纯数字
int
num
=
Integer
.
parseInt
(
windownum
);
int
num
=
Integer
.
parseInt
(
windownum
);
if
(
num
<=
20
){
if
(
num
<=
20
){
audioList
.
add
(
peple
+
num
+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
num
+
".mp3"
);
}
else
if
(
num
<
100
){
}
else
if
(
num
<
100
){
audioList
.
add
(
peple
+(
num
/
10
)+
"0.mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
/
10
)+
"0.mp3"
);
if
(
num
%
10
>
0
){
if
(
num
%
10
>
0
){
audioList
.
add
(
peple
+(
num
%
10
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
%
10
)+
".mp3"
);
}
}
}
else
if
(
num
<=
100
){
}
else
if
(
num
<=
100
){
audioList
.
add
(
peple
+
"1.mp3"
);
audioList
.
add
(
pe
o
ple
+
"1.mp3"
);
audioList
.
add
(
peple
+
"bai.mp3"
);
audioList
.
add
(
pe
o
ple
+
"bai.mp3"
);
}
}
else
if
(
num
<
1000
){
else
if
(
num
<
1000
){
audioList
.
add
(
peple
+(
num
/
100
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
/
100
)+
".mp3"
);
audioList
.
add
(
peple
+
"bai.mp3"
);
audioList
.
add
(
pe
o
ple
+
"bai.mp3"
);
audioList
.
add
(
peple
+
"and.mp3"
);
audioList
.
add
(
pe
o
ple
+
"and.mp3"
);
if
((
num
%
100
)/
10
>
0
){
if
((
num
%
100
)/
10
>
0
){
if
(
num
%
100
<=
20
){
if
(
num
%
100
<=
20
){
audioList
.
add
(
peple
+
num
%
100
+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
num
%
100
+
".mp3"
);
}
else
{
}
else
{
audioList
.
add
(
peple
+((
num
%
100
)/
10
)+
"0.mp3"
);
audioList
.
add
(
pe
o
ple
+((
num
%
100
)/
10
)+
"0.mp3"
);
}
}
}
}
audioList
.
add
(
peple
+(
num
%
100
%
10
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
%
100
%
10
)+
".mp3"
);
}
else
{
}
else
{
if
(
windownum
.
length
()
>
0
){
if
(
windownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
peple
+
windownum
.
charAt
(
i
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
}
}
}
...
@@ -626,54 +663,63 @@ public class MainWindow {
...
@@ -626,54 +663,63 @@ public class MainWindow {
Pattern
p
=
Pattern
.
compile
(
".*[a-zA-Z]+.*"
);
Pattern
p
=
Pattern
.
compile
(
".*[a-zA-Z]+.*"
);
if
(
p
.
matcher
(
windownum
).
matches
()){
//窗口号中有字母
if
(
p
.
matcher
(
windownum
).
matches
()){
//窗口号中有字母
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
peple
+
windownum
.
charAt
(
i
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
else
{
//窗口号为纯数字
}
else
{
//窗口号为纯数字
int
num
=
Integer
.
parseInt
(
windownum
);
int
num
=
Integer
.
parseInt
(
windownum
);
if
(
num
<
10
){
if
(
num
<
10
){
audioList
.
add
(
peple
+
num
+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
num
+
".mp3"
);
}
else
if
(
num
<
100
){
}
else
if
(
num
<
100
){
audioList
.
add
(
peple
+(
num
/
10
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
/
10
)+
".mp3"
);
audioList
.
add
(
peple
+
"shi.mp3"
);
audioList
.
add
(
pe
o
ple
+
"shi.mp3"
);
if
(
num
%
10
>
0
){
if
(
num
%
10
>
0
){
audioList
.
add
(
peple
+(
num
%
10
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
%
10
)+
".mp3"
);
}
}
}
else
if
(
num
<
1000
){
}
else
if
(
num
<
1000
){
audioList
.
add
(
peple
+(
num
/
100
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
/
100
)+
".mp3"
);
audioList
.
add
(
peple
+
"bai.mp3"
);
audioList
.
add
(
pe
o
ple
+
"bai.mp3"
);
if
((
num
%
100
)/
10
>
0
){
if
((
num
%
100
)/
10
>
0
){
audioList
.
add
(
peple
+((
num
%
100
)/
10
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+((
num
%
100
)/
10
)+
".mp3"
);
audioList
.
add
(
peple
+
"shi.mp3"
);
audioList
.
add
(
pe
o
ple
+
"shi.mp3"
);
}
else
{
}
else
{
audioList
.
add
(
peple
+
"0.mp3"
);
audioList
.
add
(
pe
o
ple
+
"0.mp3"
);
}
}
audioList
.
add
(
peple
+(
num
%
100
%
10
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+(
num
%
100
%
10
)+
".mp3"
);
}
else
{
}
else
{
if
(
windownum
.
length
()
>
0
){
if
(
windownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
peple
+
windownum
.
charAt
(
i
)+
".mp3"
);
audioList
.
add
(
pe
o
ple
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
}
}
}
}
}
}
}
audioList
.
add
(
peple
+
"haochuangkou.mp3"
);
audioList
.
add
(
pe
o
ple
+
"haochuangkou.mp3"
);
}
}
audioList
.
add
(
peple
+
"kk.mp3"
);
audioList
.
add
(
pe
o
ple
+
"kk.mp3"
);
String
url
=
SpliceMp3Util
.
heBingMp3
(
audioList
);
String
url
=
SpliceMp3Util
.
heBingMp3
(
audioList
);
if
(
url
!=
null
){
if
(
url
!=
null
){
pushVoiceMsg
(
"请"
+
flownum
+
"号到"
+
windownum
+
"号窗口"
);
if
(
speaker
.
equals
(
"en"
)){
pushVoiceMsg
(
"(英)请"
+
flownum
+
"号到"
+
windownum
+
"号窗口"
);
}
else
{
pushVoiceMsg
(
"请"
+
flownum
+
"号到"
+
windownum
+
"号窗口"
);
}
FileInputStream
fis
=
new
FileInputStream
(
url
);
FileInputStream
fis
=
new
FileInputStream
(
url
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
fis
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
fis
);
player
=
new
Player
(
bis
);
player
=
new
Player
(
bis
);
player
.
play
();
player
.
play
();
// pushVoiceMsg("播放完毕");
isCalling
=
true
;
isCalling
=
true
;
calling
();
if
(
english
||
zang
){
callOtherLangage
(
flownum
,
windownum
);
}
else
{
calling
();
}
}
else
{
}
else
{
isCalling
=
true
;
isCalling
=
true
;
...
@@ -682,6 +728,10 @@ public class MainWindow {
...
@@ -682,6 +728,10 @@ public class MainWindow {
}
}
}
else
{
}
else
{
isCalling
=
false
;
isCalling
=
false
;
if
(
player
!=
null
){
player
.
close
();
player
=
null
;
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -692,4 +742,145 @@ public class MainWindow {
...
@@ -692,4 +742,145 @@ public class MainWindow {
}
}
}
}
private
void
callOtherLangage
(
String
flownum
,
String
windownum
){
try
{
//语音拼接
List
<
String
>
audioList
=
new
ArrayList
<>();
String
englishPeople
=
System
.
getProperty
(
"user.dir"
)+
"/src/main/resources/sound/en/"
;
String
zangPeople
=
System
.
getProperty
(
"user.dir"
)+
"/src/main/resources/sound/zang/"
;
if
(
english
){
//英双语
audioList
.
add
(
englishPeople
+
"qing.mp3"
);
//拼接排队号
if
(
flownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
flownum
.
length
();
i
++)
{
audioList
.
add
(
englishPeople
+
flownum
.
charAt
(
i
)+
".mp3"
);
}
}
audioList
.
add
(
englishPeople
+
"haodao.mp3"
);
if
(
windownum
.
length
()
>
0
){
Pattern
p
=
Pattern
.
compile
(
".*[a-zA-Z]+.*"
);
if
(
p
.
matcher
(
windownum
).
matches
()){
//窗口号中有字母
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
englishPeople
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
else
{
//窗口号为纯数字
int
num
=
Integer
.
parseInt
(
windownum
);
if
(
num
<=
20
){
audioList
.
add
(
englishPeople
+
num
+
".mp3"
);
}
else
if
(
num
<
100
){
audioList
.
add
(
englishPeople
+(
num
/
10
)+
"0.mp3"
);
if
(
num
%
10
>
0
){
audioList
.
add
(
englishPeople
+(
num
%
10
)+
".mp3"
);
}
}
else
if
(
num
<=
100
){
audioList
.
add
(
englishPeople
+
"1.mp3"
);
audioList
.
add
(
people
+
"bai.mp3"
);
}
else
if
(
num
<
1000
){
audioList
.
add
(
englishPeople
+(
num
/
100
)+
".mp3"
);
audioList
.
add
(
englishPeople
+
"bai.mp3"
);
audioList
.
add
(
englishPeople
+
"and.mp3"
);
if
((
num
%
100
)/
10
>
0
){
if
(
num
%
100
<=
20
){
audioList
.
add
(
englishPeople
+
num
%
100
+
".mp3"
);
}
else
{
audioList
.
add
(
englishPeople
+((
num
%
100
)/
10
)+
"0.mp3"
);
}
}
audioList
.
add
(
englishPeople
+(
num
%
100
%
10
)+
".mp3"
);
}
else
{
if
(
windownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
englishPeople
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
}
}
}
else
{
audioList
.
add
(
zangPeople
+
"qing.mp3"
);
//拼接排队号
if
(
flownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
flownum
.
length
();
i
++)
{
audioList
.
add
(
zangPeople
+
flownum
.
charAt
(
i
)+
".mp3"
);
}
}
audioList
.
add
(
zangPeople
+
"haodao.mp3"
);
if
(
windownum
.
length
()
>
0
){
Pattern
p
=
Pattern
.
compile
(
".*[a-zA-Z]+.*"
);
if
(
p
.
matcher
(
windownum
).
matches
()){
//窗口号中有字母
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
zangPeople
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
else
{
//窗口号为纯数字
int
num
=
Integer
.
parseInt
(
windownum
);
if
(
num
<
10
){
audioList
.
add
(
zangPeople
+
num
+
".mp3"
);
}
else
if
(
num
<
100
){
audioList
.
add
(
zangPeople
+(
num
/
10
)+
".mp3"
);
audioList
.
add
(
zangPeople
+
"shi.mp3"
);
if
(
num
%
10
>
0
){
audioList
.
add
(
zangPeople
+(
num
%
10
)+
".mp3"
);
}
}
else
if
(
num
<
1000
){
audioList
.
add
(
zangPeople
+(
num
/
100
)+
".mp3"
);
audioList
.
add
(
zangPeople
+
"bai.mp3"
);
if
((
num
%
100
)/
10
>
0
){
audioList
.
add
(
zangPeople
+((
num
%
100
)/
10
)+
".mp3"
);
audioList
.
add
(
zangPeople
+
"shi.mp3"
);
}
else
{
audioList
.
add
(
zangPeople
+
"0.mp3"
);
}
audioList
.
add
(
zangPeople
+(
num
%
100
%
10
)+
".mp3"
);
}
else
{
if
(
windownum
.
length
()
>
0
){
for
(
int
i
=
0
;
i
<
windownum
.
length
();
i
++)
{
audioList
.
add
(
zangPeople
+
windownum
.
charAt
(
i
)+
".mp3"
);
}
}
}
}
}
audioList
.
add
(
zangPeople
+
"haochuangkou.mp3"
);
}
audioList
.
add
(
people
+
"kk.mp3"
);
String
url
=
SpliceMp3Util
.
heBingMp3
(
audioList
);
if
(
url
!=
null
){
if
(
english
){
pushVoiceMsg
(
"(英)请"
+
flownum
+
"号到"
+
windownum
+
"号窗口"
);
}
else
{
pushVoiceMsg
(
"(藏)请"
+
flownum
+
"号到"
+
windownum
+
"号窗口"
);
}
FileInputStream
fis
=
new
FileInputStream
(
url
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
fis
);
player
=
new
Player
(
bis
);
player
.
play
();
// pushVoiceMsg("播放完毕");
isCalling
=
true
;
calling
();
}
else
{
isCalling
=
true
;
calling
();
pushVoiceMsg
(
"语音包提取失败:"
+
url
);
}
}
catch
(
Exception
e
)
{
//如果异常 则放弃这条语音 继续循环
isCalling
=
true
;
calling
();
pushVoiceMsg
(
"语音播报异常:"
+
e
.
toString
());
}
}
}
}
src/main/java/com/mortals/xhx/tts/UI/SettingWindow.java
View file @
cf0fd371
...
@@ -355,28 +355,28 @@ public class SettingWindow {
...
@@ -355,28 +355,28 @@ public class SettingWindow {
jComboBox3
.
addItem
(
"xy"
);
jComboBox3
.
addItem
(
"xy"
);
jComboBox3
.
addItem
(
"yy"
);
jComboBox3
.
addItem
(
"yy"
);
jComboBox3
.
addItem
(
"zang"
);
jComboBox3
.
addItem
(
"zang"
);
if
(
speaker
==
"en"
){
if
(
speaker
.
equals
(
"en"
)
){
jComboBox3
.
setSelectedIndex
(
0
);
jComboBox3
.
setSelectedIndex
(
0
);
}
}
if
(
speaker
==
"tb"
){
if
(
speaker
.
equals
(
"tb"
)
){
jComboBox3
.
setSelectedIndex
(
1
);
jComboBox3
.
setSelectedIndex
(
1
);
}
}
if
(
speaker
==
"xr"
){
if
(
speaker
.
equals
(
"xr"
)
){
jComboBox3
.
setSelectedIndex
(
2
);
jComboBox3
.
setSelectedIndex
(
2
);
}
}
if
(
speaker
==
"xx"
){
if
(
speaker
.
equals
(
"xx"
)
){
jComboBox3
.
setSelectedIndex
(
3
);
jComboBox3
.
setSelectedIndex
(
3
);
}
}
if
(
speaker
==
"xy"
){
if
(
speaker
.
equals
(
"xy"
)
){
jComboBox3
.
setSelectedIndex
(
4
);
jComboBox3
.
setSelectedIndex
(
4
);
}
}
if
(
speaker
==
"yy"
){
if
(
speaker
.
equals
(
"yy"
)
){
jComboBox3
.
setSelectedIndex
(
5
);
jComboBox3
.
setSelectedIndex
(
5
);
}
}
if
(
speaker
==
"zang"
){
if
(
speaker
.
equals
(
"zang"
)
){
jComboBox3
.
setSelectedIndex
(
6
);
jComboBox3
.
setSelectedIndex
(
6
);
}
}
jComboBox
2
.
addItemListener
(
new
ItemListener
()
{
jComboBox
3
.
addItemListener
(
new
ItemListener
()
{
@Override
@Override
public
void
itemStateChanged
(
ItemEvent
e
)
{
public
void
itemStateChanged
(
ItemEvent
e
)
{
if
(
jComboBox3
.
getSelectedIndex
()
==
0
){
if
(
jComboBox3
.
getSelectedIndex
()
==
0
){
...
@@ -408,7 +408,7 @@ public class SettingWindow {
...
@@ -408,7 +408,7 @@ public class SettingWindow {
//保存本地配置按钮
//保存本地配置按钮
JButton
jb1
=
new
JButton
(
"保存"
);
JButton
jb1
=
new
JButton
(
"保存
本地配置
"
);
jb1
.
setPreferredSize
(
new
Dimension
(
460
,
30
));
jb1
.
setPreferredSize
(
new
Dimension
(
460
,
30
));
jb1
.
addActionListener
(
new
ActionListener
()
{
jb1
.
addActionListener
(
new
ActionListener
()
{
@Override
@Override
...
@@ -507,7 +507,7 @@ public class SettingWindow {
...
@@ -507,7 +507,7 @@ public class SettingWindow {
frame
.
add
(
jPanel7
);
frame
.
add
(
jPanel7
);
//上传站点信息
//上传站点信息
JButton
jb2
=
new
JButton
(
"上传"
);
JButton
jb2
=
new
JButton
(
"上传
站点信息
"
);
jb2
.
setPreferredSize
(
new
Dimension
(
460
,
30
));
jb2
.
setPreferredSize
(
new
Dimension
(
460
,
30
));
jb2
.
addActionListener
(
new
ActionListener
()
{
jb2
.
addActionListener
(
new
ActionListener
()
{
@Override
@Override
...
...
src/main/java/com/mortals/xhx/tts/utils/SpliceMp3Util.java
View file @
cf0fd371
...
@@ -201,8 +201,10 @@ public class SpliceMp3Util {
...
@@ -201,8 +201,10 @@ public class SpliceMp3Util {
* @throws IOException
* @throws IOException
*/
*/
public
static
String
heBingMp3
(
List
<
String
>
pathList
)
throws
IOException
{
public
static
String
heBingMp3
(
List
<
String
>
pathList
)
throws
IOException
{
// String luJing= "/tmp/";
String
luJing
=
"/tmp/"
;
String
luJing
=
"F:\\\\"
;
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
)){
//windows电脑测试路径
luJing
=
"F:\\\\"
;
}
File
f
=
new
File
(
luJing
);
File
f
=
new
File
(
luJing
);
f
.
mkdirs
();
f
.
mkdirs
();
//生成处理后的文件
//生成处理后的文件
...
...
src/main/resources/img/icon.png
0 → 100644
View file @
cf0fd371
2.52 KB
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