250305:2.0初始联调版本
authorxiewei <892331662@qq.com>
Wed, 5 Mar 2025 01:28:07 +0000 (09:28 +0800)
committerxiewei <892331662@qq.com>
Wed, 5 Mar 2025 01:28:07 +0000 (09:28 +0800)
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/ai/VoiceChatManager.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/bean/VoiceChatPayload.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/util/AudioConvertManage.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/util/MyConfig.java

index 618b5e1..3174179 100644 (file)
@@ -60,6 +60,7 @@ public class VoiceChatManager {
                         chatClient.close();
                         chatClient = null;
                     }
+                    isStart = false;
                     connectChat();
                     break;
                 case MSG_SENDPING:
@@ -212,6 +213,7 @@ public class VoiceChatManager {
                     handler.removeMessages(MSG_RECONNECT);
                     handler.sendEmptyMessageDelayed(MSG_RECONNECT,2000);
                 }*/
+                isStart = false;
                 if (!ischeckoutChannel) {
                     handler.removeMessages(MSG_RECONNECT);
                     handler.sendEmptyMessageDelayed(MSG_RECONNECT, 1500);
@@ -287,12 +289,13 @@ public class VoiceChatManager {
         VoiceChatPayload payload = new VoiceChatPayload();
         payload.setDevice_id(MyConfig.DEVICE_ID);
         payload.setUser_agent("python");
-        payload.setIn_format(in_format);
-        payload.setIn_sample_rate(in_sample_rate);
         payload.setOut_format(out_format);
         payload.setSample_rate(out_sample_rate);
-        payload.setSpace_time(100);
         payload.setVolume("100");
+        payload.setVoice("zh_female_shuangkuaisisi_moon_bigtts");
+        VoiceChatPayload.CustomVariablesBean customVariablesBean = new VoiceChatPayload.CustomVariablesBean();
+        customVariablesBean.setBot_name("柒先生");
+
         param.put("header", header);
         param.put("payload", payload);
         String msg = new Gson().toJson(param);
@@ -464,7 +467,7 @@ public class VoiceChatManager {
         if(chatClient==null||chatClient.isClosed()){
             return;
         }
-        SobLog.d(TAG, "RequestToSpeak:-"+isStart);
+        SobLog.d(TAG, "RequestToRespond:-"+isStart);
         if(!isStart){
             return;
         }
@@ -479,7 +482,7 @@ public class VoiceChatManager {
         param.put("header", header);
         param.put("payload", payload);
         String msg = new Gson().toJson(param);
-
+        SobLog.d(TAG, "RequestToRespond:-"+msg);
         chatClient.send(msg);
 
     }
index 7da846a..024dff2 100644 (file)
@@ -2,25 +2,28 @@ package com.zhixun.android.sdk.polysdk.bean;
 
 public class VoiceChatPayload {
 
+
     /**
      * device_id : test_device_id
      * user_agent : python
-     * in_format : pcm
-     * in_sample_rate : 16000
-     * out_format  : pcm
-     * sample_rate  : 16000
-     * space_time  : 100
-     * volume  : 2
+     * dialog_id :
+     * out_format : pcm
+     * volume : 10
+     * sample_rate : 16000
+     * voice : zh_female_shuangkuaisisi_moon_bigtts
+     * simple_response : true
+     * custom_variables : {"bot_name":"柒先生"}
      */
 
     private String device_id;
     private String user_agent;
-    private String in_format;
-    private int in_sample_rate;
+    private String dialog_id;
     private String out_format;
-    private int sample_rate;
-    private int space_time;
     private String volume;
+    private int sample_rate;
+    private String voice;
+    private boolean simple_response;
+    private CustomVariablesBean custom_variables;
 
     public String getDevice_id() {
         return device_id;
@@ -38,20 +41,12 @@ public class VoiceChatPayload {
         this.user_agent = user_agent;
     }
 
-    public String getIn_format() {
-        return in_format;
-    }
-
-    public void setIn_format(String in_format) {
-        this.in_format = in_format;
-    }
-
-    public int getIn_sample_rate() {
-        return in_sample_rate;
+    public String getDialog_id() {
+        return dialog_id;
     }
 
-    public void setIn_sample_rate(int in_sample_rate) {
-        this.in_sample_rate = in_sample_rate;
+    public void setDialog_id(String dialog_id) {
+        this.dialog_id = dialog_id;
     }
 
     public String getOut_format() {
@@ -62,6 +57,14 @@ public class VoiceChatPayload {
         this.out_format = out_format;
     }
 
+    public String getVolume() {
+        return volume;
+    }
+
+    public void setVolume(String volume) {
+        this.volume = volume;
+    }
+
     public int getSample_rate() {
         return sample_rate;
     }
@@ -70,19 +73,43 @@ public class VoiceChatPayload {
         this.sample_rate = sample_rate;
     }
 
-    public int getSpace_time() {
-        return space_time;
+    public String getVoice() {
+        return voice;
     }
 
-    public void setSpace_time(int space_time) {
-        this.space_time = space_time;
+    public void setVoice(String voice) {
+        this.voice = voice;
     }
 
-    public String getVolume() {
-        return volume;
+    public boolean isSimple_response() {
+        return simple_response;
     }
 
-    public void setVolume(String volume) {
-        this.volume = volume;
+    public void setSimple_response(boolean simple_response) {
+        this.simple_response = simple_response;
+    }
+
+    public CustomVariablesBean getCustom_variables() {
+        return custom_variables;
+    }
+
+    public void setCustom_variables(CustomVariablesBean custom_variables) {
+        this.custom_variables = custom_variables;
+    }
+
+    public static class CustomVariablesBean {
+        /**
+         * bot_name : 柒先生
+         */
+
+        private String bot_name;
+
+        public String getBot_name() {
+            return bot_name;
+        }
+
+        public void setBot_name(String bot_name) {
+            this.bot_name = bot_name;
+        }
     }
 }
index 79a2a35..4d3e8d2 100644 (file)
@@ -195,8 +195,8 @@ public class AudioConvertManage {
 
                     if(outfile.exists()){
                         byte[] outData = readFile(outfile);
-//                        outfile.delete();
-//                        inputFile.delete();
+                        outfile.delete();
+                        inputFile.delete();
 
                         int bufferSize = AudioRecord.getMinBufferSize(16000,
                                 AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
index 3181a1c..74cc359 100644 (file)
@@ -23,7 +23,7 @@ public class MyConfig {
 
     public final static String URL_AI_TTS= "ws://amp.raisound.com/tts/stream";
 
-    public final static String URL_VOICE_CHAT= "ws://118.145.158.207:22080/voice-chat/ws";
+    public final static String URL_VOICE_CHAT= "ws://118.145.158.207:22080/voice-chat/v2.1/ws";
     public final static String AI_IS_AUTH= "1";
 
     public final static String VOICE_CHAT_APPKEY = "j2QhAoOeBi5AUlrM";