diff --git a/README.md b/README.md
index 6302e23..f3cdbca 100644
--- a/README.md
+++ b/README.md
@@ -273,6 +273,6 @@ python main.py
技术交流群
-
+
diff --git a/android_connector_demo/fayConnectorDemo-蓝牙service后台运行版/app/src/main/java/com/yaheen/fayconnectordemo/FayConnectorService.java b/android_connector_demo/fayConnectorDemo-蓝牙service后台运行版/app/src/main/java/com/yaheen/fayconnectordemo/FayConnectorService.java
index 7e0cf3e..467111b 100644
--- a/android_connector_demo/fayConnectorDemo-蓝牙service后台运行版/app/src/main/java/com/yaheen/fayconnectordemo/FayConnectorService.java
+++ b/android_connector_demo/fayConnectorDemo-蓝牙service后台运行版/app/src/main/java/com/yaheen/fayconnectordemo/FayConnectorService.java
@@ -99,8 +99,7 @@ public class FayConnectorService extends Service {
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
if (AudioManager.SCO_AUDIO_STATE_CONNECTED == state) {
Log.d("fay", "蓝牙sco连接成功");
- mAudioManager.setBluetoothScoOn(true);
- mAudioManager.setMode(mAudioManager.MODE_IN_CALL);
+
}
}
@@ -133,6 +132,7 @@ public class FayConnectorService extends Service {
Log.d("fay", "fay控制器连接成功");
} catch (IOException e) {
Log.d("fay", "socket连接失败");
+ running = false;
return;
}
byte[] data = new byte[1024];
@@ -168,7 +168,9 @@ public class FayConnectorService extends Service {
socket.close();
} catch (Exception e) {
}
- Log.d("fay", "结束");
+ socket = null;
+ Log.d("fay", "send线程结束");
+
}
}
@@ -191,9 +193,11 @@ public class FayConnectorService extends Service {
Log.d("fay", "开始接收音频文件");
String filedata = "";
data = new byte[1024];
- while (data != null && data.length > 0) {
- in.read(data);
- filedata += MainActivity.bytesToHexString(data);
+ int len = 0;
+ while ((len = in.read(data)) != -1) {
+ byte[] temp = new byte[len];
+ System.arraycopy(data, 0, temp, 0, len);
+ filedata += MainActivity.bytesToHexString(temp);
int index = filedata.indexOf("080706050403020100");
if (filedata.length() > 9 && index > 0) {//wav文件结束标记
filedata = filedata.substring(0, index).replaceAll("F0F1F2F3F4F5F6F7F8", "");
@@ -234,6 +238,7 @@ public class FayConnectorService extends Service {
mp.release();
mAudioManager.startBluetoothSco();
mAudioManager.setMode(mAudioManager.MODE_IN_CALL);
+ mAudioManager.setBluetoothScoOn(true);
}
@@ -268,6 +273,7 @@ public class FayConnectorService extends Service {
} catch (Exception e) {//通过异常判断socket已经关闭,退出循环
} finally {
+ Log.d("fay", "rece线程结束");
}
}
@@ -292,7 +298,7 @@ public class FayConnectorService extends Service {
}catch (Exception e){
Log.e("fay", e.toString());
}finally {
- FayConnectorService.this.stopForeground(true);
+ FayConnectorService.this.stopSelf();
}
}
}).start();
diff --git a/core/recorder.py b/core/recorder.py
index 5028db7..584b886 100644
--- a/core/recorder.py
+++ b/core/recorder.py
@@ -32,7 +32,7 @@ class Recorder:
self.__processing = False
self.__history_level = []
self.__history_data = []
- self.__dynamic_threshold = 0.5 # 声音识别的音量阈值
+ self.__dynamic_threshold = 0.35 # 声音识别的音量阈值
self.__MAX_LEVEL = 25000
self.__MAX_BLOCK = 100
@@ -147,7 +147,6 @@ class Recorder:
- print("接收完成:{}".format(self.total))
def set_processing(self, processing):
diff --git a/fay_booter.py b/fay_booter.py
index 44ba353..a8a39df 100644
--- a/fay_booter.py
+++ b/fay_booter.py
@@ -94,15 +94,15 @@ class DeviceInputListener(Recorder):
super().__init__(fei)
self.__running = True
self.ngrok = None
+ self.streamCache = None
self.thread = MyThread(target=self.run)
self.thread.start() #启动远程音频输入设备监听线程
def run(self):
#启动ngork
- if config_util.key_ngrok_cc_id is not None and config_util.key_ngrok_cc_id != "":
- MyThread(target=self.start_ngrok, args=[config_util.key_ngrok_cc_id]).start()
-
self.streamCache = stream_util.StreamCache(1024*1024*20)
+ if config_util.key_ngrok_cc_id and config_util.key_ngrok_cc_id is not None and config_util.key_ngrok_cc_id.strip() != "":
+ MyThread(target=self.start_ngrok, args=[config_util.key_ngrok_cc_id]).start()
addr = None
while self.__running:
try:
@@ -125,15 +125,18 @@ class DeviceInputListener(Recorder):
feiFei.on_interact(interact)
time.sleep(2)
+ #recorder会等待stream不为空才开始录音
def get_stream(self):
- while feiFei.deviceConnect is None:
+ while self.streamCache is None:
+ time.sleep(1)
pass
return self.streamCache
def stop(self):
super().stop()
self.__running = False
- self.ngrok.stop()
+ if config_util.key_ngrok_cc_id and config_util.key_ngrok_cc_id is not None and config_util.key_ngrok_cc_id.strip() != "":
+ self.ngrok.stop()
def start_ngrok(self, clientId):
self.ngrok = ngrok_util.NgrokCilent(clientId)
diff --git a/gui/static/js/index.js b/gui/static/js/index.js
index cf212d2..05ea01d 100644
--- a/gui/static/js/index.js
+++ b/gui/static/js/index.js
@@ -386,16 +386,7 @@ new Vue({
return this.isEmptyItem(this.items_data[this.items_data.length - 1])
},
uuid() {
- let s = []
- let hexDigits = '0123456789abcdef'
- for (let i = 0; i < 36; i++) {
- s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
- }
- s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010
- s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01
- s[8] = s[13] = s[18] = s[23] = '-'
-
- let uuid = s.join('')
+ let uuid = Math.random().toString(36);
return uuid
},
runnnable() {
diff --git a/images/20230209125339.jpg b/images/20230209125339.jpg
new file mode 100644
index 0000000..be9ba87
Binary files /dev/null and b/images/20230209125339.jpg differ