zhoufan 10 meses atrás
pai
commit
9fd9cc4315

+ 13 - 13
midware-api/src/main/resources/application-dev.yml

@@ -34,17 +34,17 @@ common:
34 34
     register:
35 35
     #源号码
36 36
     origination:
37
-  tts:
38
-    #modelscope/ekho
39
-    type: modelscope
40
-    url: http://192.168.1.81:8000/call
37
+#  tts:
38
+#    #modelscope/ekho
39
+#    type: modelscope
40
+#    url: http://192.168.1.81:8000/call
41 41
 
42
-  ai:
43
-    llm: http://192.168.1.89:7861/chat/chat
44
-    zsk: http://192.168.1.89:7861/chat/kb_chat
45
-    sjk: http://192.168.1.89:7861/chat/db_chat
46
-    es: http://192.168.1.15:8800/km/doc/getLastInfo
47
-
48
-  funasr: ws://192.168.1.89:10095
49
-  #funasr/mrcp
50
-  asr: funasr
42
+#  ai:
43
+#    llm: http://192.168.1.89:7861/chat/chat
44
+#    zsk: http://192.168.1.89:7861/chat/kb_chat
45
+#    sjk: http://192.168.1.89:7861/chat/db_chat
46
+#    es: http://192.168.1.15:8800/km/doc/getLastInfo
47
+#
48
+#  funasr: ws://192.168.1.89:10095
49
+#  #funasr/mrcp
50
+#  asr: funasr

+ 1 - 15
midware-api/src/main/resources/application-production.yml

@@ -33,18 +33,4 @@ common:
33 33
     #注册网关
34 34
     register:
35 35
     #源号码
36
-    origination:
37
-  tts:
38
-    #modelscope/ekho
39
-    type: modelscope
40
-    url: http://192.168.1.81:8000/call
41
-
42
-  ai:
43
-    llm: http://192.168.1.89:7861/chat/chat
44
-    zsk: http://192.168.1.89:7861/chat/kb_chat
45
-    sjk: http://192.168.1.89:7861/chat/db_chat
46
-    es: http://192.168.1.15:8800/km/doc/getLastInfo
47
-
48
-  funasr: ws://192.168.1.89:10095
49
-  #funasr/mrcp
50
-  asr: funasr
36
+    origination:

+ 9 - 6
midware-service/src/main/java/midware/service/init/EslClientService.java

@@ -6,12 +6,12 @@ import midware.service.eslclient.*;
6 6
 import midware.service.eslclient.entity.Agent;
7 7
 import midware.service.eslclient.entity.Channel;
8 8
 import midware.service.eslclient.entity.Session;
9
-import midware.util.config.CommonConfig;
10 9
 import midware.util.config.EslClientConfig;
11 10
 import midware.util.enums.EslAgentEnum;
12 11
 import midware.util.enums.EslCommandEnum;
13 12
 import midware.util.enums.EslEventEnum;
14 13
 import midware.util.helper.SecretHelper;
14
+import midware.util.helper.SpringHelper;
15 15
 import midware.util.helper.StringHelper;
16 16
 import midware.util.helper.TtsHelper;
17 17
 import org.freeswitch.esl.client.inbound.Client;
@@ -542,7 +542,8 @@ public class EslClientService {
542 542
             params.put("hotwords", null);
543 543
             String arg = "";
544 544
             if (isAsr) {
545
-                arg = chanId + " start " + CommonConfig.funasr + " mono 16k " + JSON.toJSONString(params);
545
+                String url=SpringHelper.getRequiredProperty("common.funasr");
546
+                arg = chanId + " start " + url + " mono 16k " + JSON.toJSONString(params);
546 547
             } else {
547 548
                 arg = chanId + " stop " + JSON.toJSONString(params);
548 549
             }
@@ -825,8 +826,9 @@ public class EslClientService {
825 826
     //源号码
826 827
     private String getOrigination(String calleeNum) {
827 828
         String str = "";
828
-        if (!EslCommon.existExten(calleeNum) && StringHelper.isNotEmpty(CommonConfig.gateway_origination)) {
829
-            str = ",origination_caller_id_number=" + CommonConfig.gateway_origination;
829
+        String origination= SpringHelper.getRequiredProperty("common.gateway.origination");
830
+        if (!EslCommon.existExten(calleeNum) && StringHelper.isNotEmpty(origination)) {
831
+            str = ",origination_caller_id_number=" + origination;
830 832
         }
831 833
         return str;
832 834
     }
@@ -837,8 +839,9 @@ public class EslClientService {
837 839
         String callStr = "user/" + calleeNum;
838 840
         //呼叫外线号码
839 841
         if (!EslCommon.existExten(calleeNum)) {
840
-            if (StringHelper.isNotEmpty(CommonConfig.gateway_register)) {
841
-                callStr = "sofia/internal/" + calleeNum + "@" + CommonConfig.gateway_register;
842
+            String register= SpringHelper.getRequiredProperty("common.gateway.register");
843
+            if (StringHelper.isNotEmpty(register)) {
844
+                callStr = "sofia/internal/" + calleeNum + "@" + register;
842 845
 
843 846
 //            //注册网关
844 847
 //            EslMessage message = client.sendSyncApiCommand("sofia_contact", "9400");

+ 0 - 70
midware-util/src/main/java/midware/util/config/CommonConfig.java

@@ -1,70 +0,0 @@
1
-package midware.util.config;
2
-
3
-import lombok.Data;
4
-import org.springframework.beans.factory.annotation.Value;
5
-import org.springframework.context.annotation.Configuration;
6
-
7
-@Data
8
-@Configuration
9
-public class CommonConfig {
10
-    public static String gateway_register;
11
-    @Value("${common.gateway.register}")
12
-    private void setGatewayRegister(String register) {
13
-        CommonConfig.gateway_register = register;
14
-    }
15
-    public static String gateway_origination;
16
-    @Value("${common.gateway.origination}")
17
-    private void setGatewayOrigination(String origination) {
18
-        CommonConfig.gateway_origination = origination;
19
-    }
20
-
21
-
22
-    public static String tts_type;
23
-    @Value("${common.tts.type}")
24
-    private void setTtsType(String ttsType) {
25
-        CommonConfig.tts_type = ttsType;
26
-    }
27
-
28
-    public static String tts_url;
29
-    @Value("${common.tts.url}")
30
-    private void setTtsUrl(String ttsUrl) {
31
-        CommonConfig.tts_url = ttsUrl;
32
-    }
33
-
34
-
35
-    public static String ai_llm;
36
-    @Value("${common.ai.llm}")
37
-    private void setAiLlm(String aiLlm) {
38
-        CommonConfig.ai_llm = aiLlm;
39
-    }
40
-
41
-    public static String ai_zsk;
42
-    @Value("${common.ai.zsk}")
43
-    private void setAiZsk(String aiZsk) {
44
-        CommonConfig.ai_zsk = aiZsk;
45
-    }
46
-
47
-    public static String ai_sjk;
48
-    @Value("${common.ai.sjk}")
49
-    private void setAiSjk(String aiSjk) {
50
-        CommonConfig.ai_sjk = aiSjk;
51
-    }
52
-
53
-    public static String ai_es;
54
-    @Value("${common.ai.es}")
55
-    private void setAiEs(String aiEs) {
56
-        CommonConfig.ai_es = aiEs;
57
-    }
58
-
59
-    public static String funasr;
60
-    @Value("${common.funasr}")
61
-    private void setFunasr(String funasr) {
62
-        CommonConfig.funasr = funasr;
63
-    }
64
-
65
-    public static String asr;
66
-    @Value("${common.asr}")
67
-    private void setAsr(String asr) {
68
-        CommonConfig.asr = asr;
69
-    }
70
-}

+ 4 - 3
midware-util/src/main/java/midware/util/helper/TtsHelper.java

@@ -2,7 +2,6 @@ package midware.util.helper;
2 2
 
3 3
 import com.alibaba.fastjson2.JSON;
4 4
 import lombok.extern.slf4j.Slf4j;
5
-import midware.util.config.CommonConfig;
6 5
 
7 6
 import java.io.File;
8 7
 import java.io.FileOutputStream;
@@ -17,7 +16,8 @@ import java.util.Map;
17 16
 public class TtsHelper {
18 17
 
19 18
     private static void transfer(String word, String filePath) {
20
-        switch (CommonConfig.tts_type) {
19
+        String type=SpringHelper.getRequiredProperty("common.tts.type");
20
+        switch (type) {
21 21
             case "ekho":
22 22
                 try {
23 23
                     String command = "ekho " + word + " -o " + filePath;
@@ -34,7 +34,8 @@ public class TtsHelper {
34 34
                 param1.put("voice", "zhitian_emo");
35 35
                 param.put("parameters", param1);
36 36
 
37
-                String result = HttpHelper.post(CommonConfig.tts_url, JSON.toJSONString(param));
37
+                String url=SpringHelper.getRequiredProperty("common.tts.url");
38
+                String result = HttpHelper.post(url, JSON.toJSONString(param));
38 39
                 if (StringHelper.isNotEmpty(result)) {
39 40
                     try {
40 41
                         Map map = JSON.parseObject(result, Map.class);