mirror of
https://github.com/xszyou/Fay.git
synced 2026-03-12 17:51:28 +08:00
年番更新
1、自动播放逻辑优化:交互完停30秒才继续; 2、降低socket心跳频率,可以一定程序节省安卓远程设备的用电量; 3、增加消息透传接口:https://qqk9ntwbcit.feishu.cn/wiki/PNKFwVgUKig6fDkMH03cMPiInIb 4、修复底部用户列表样式错误; 5、提高agent日程执行成功率;
This commit is contained in:
@@ -116,6 +116,7 @@ class FeiFei:
|
||||
self.__running = True
|
||||
self.sp.connect() #TODO 预连接
|
||||
self.cemotion = None
|
||||
self.timer = None
|
||||
|
||||
#语音消息处理检查是否命中q&a
|
||||
def __get_answer(self, interleaver, text):
|
||||
@@ -222,7 +223,7 @@ class FeiFei:
|
||||
|
||||
#声音输出
|
||||
MyThread(target=self.say, args=[interact, text]).start()
|
||||
|
||||
return 'success'
|
||||
|
||||
except BaseException as e:
|
||||
print(e)
|
||||
@@ -433,6 +434,9 @@ class FeiFei:
|
||||
global auto_play_lock
|
||||
global can_auto_play
|
||||
with auto_play_lock:
|
||||
if self.timer is not None:
|
||||
self.timer.cancel()
|
||||
self.timer = None
|
||||
can_auto_play = False
|
||||
|
||||
self.speaking = True
|
||||
@@ -474,13 +478,26 @@ class FeiFei:
|
||||
if config_util.config["interact"]["playSound"]:
|
||||
util.printInfo(1, interact.data.get('user'), '结束播放!')
|
||||
|
||||
#恢复自动播放(如何有)
|
||||
self.speaking = False
|
||||
global can_auto_play
|
||||
global auto_play_lock
|
||||
with auto_play_lock:
|
||||
if self.timer:
|
||||
self.timer.cancel()
|
||||
self.timer = None
|
||||
if interact.interleaver != 'auto_play': #交互后暂停自动播放30秒
|
||||
self.timer = threading.Timer(30, self.set_auto_play)
|
||||
self.timer.start()
|
||||
else:
|
||||
can_auto_play = True
|
||||
|
||||
#恢复自动播放(如果有)
|
||||
def set_auto_play(self):
|
||||
global auto_play_lock
|
||||
global can_auto_play
|
||||
with auto_play_lock:
|
||||
can_auto_play = True
|
||||
|
||||
self.speaking = False
|
||||
self.timer = None
|
||||
|
||||
#启动核心服务
|
||||
def start(self):
|
||||
|
||||
@@ -196,7 +196,7 @@ def device_socket_keep_alive():
|
||||
value = DeviceInputListenerDict.pop(delkey)
|
||||
if wsa_server.get_web_instance().is_connected(value.username):
|
||||
wsa_server.get_web_instance().add_cmd({"remote_audio_connect": False, "Username" : value.username})
|
||||
time.sleep(1)
|
||||
time.sleep(10)
|
||||
|
||||
#远程音频连接
|
||||
def accept_audio_device_output_connect():
|
||||
|
||||
@@ -486,6 +486,26 @@ def to_greet():
|
||||
text = fay_booter.feiFei.on_interact(interact)
|
||||
return jsonify({'status': 'success', 'data': text, 'msg': '已进行打招呼'}), 200
|
||||
|
||||
#消息透传接口
|
||||
@__app.route('/transparent_pass', methods=['post'])
|
||||
def transparent_pass():
|
||||
try:
|
||||
data = request.form.get('data')
|
||||
if data is None:
|
||||
data = request.get_json()
|
||||
else:
|
||||
data = json.loads(data)
|
||||
user = data.get('user', 'User')
|
||||
response_text = data.get('text', '')
|
||||
audio_url = data.get('audio', '')
|
||||
interact = Interact('transparent_pass', 2, {'user': user, 'text': response_text, 'audio': audio_url})
|
||||
util.printInfo(1, user, '透传播放:{},{}'.format(response_text, audio_url), time.time())
|
||||
success = fay_booter.feiFei.on_interact(interact)
|
||||
if (success == 'success'):
|
||||
return jsonify({'code': 200, 'message' : '成功'})
|
||||
return jsonify({'code': 500, 'message' : '未错原因出错'})
|
||||
except Exception as e:
|
||||
return jsonify({'code': 500, 'message': f'出错: {e}'}), 500
|
||||
|
||||
|
||||
def run():
|
||||
|
||||
@@ -2,13 +2,28 @@ const menu = document.querySelector('.menu');
|
||||
const prevButton = document.getElementById('prevButton');
|
||||
const nextButton = document.getElementById('nextButton');
|
||||
|
||||
// 每次滑动的距离,可根据菜单项宽度和间距等实际情况调整
|
||||
const slideDistance = 500;
|
||||
let currentTranslate = 0;
|
||||
|
||||
function updateButtons() {
|
||||
prevButton.disabled = currentTranslate === 0;
|
||||
nextButton.disabled = currentTranslate <= -(menu.scrollWidth - menu.clientWidth);
|
||||
}
|
||||
|
||||
prevButton.addEventListener('click', () => {
|
||||
menu.style.transform = `translateX(${slideDistance}px)`;
|
||||
if (menu.scrollWidth > menu.clientWidth) {
|
||||
currentTranslate = Math.min(currentTranslate + slideDistance, 0);
|
||||
menu.style.transform = `translateX(${currentTranslate}px)`;
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
|
||||
nextButton.addEventListener('click', () => {
|
||||
menu.style.transform = `translateX(-${slideDistance}px)`;
|
||||
});
|
||||
if (menu.scrollWidth > menu.clientWidth) {
|
||||
currentTranslate = Math.max(currentTranslate - slideDistance, -(menu.scrollWidth - menu.clientWidth));
|
||||
menu.style.transform = `translateX(${currentTranslate}px)`;
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
|
||||
updateButtons();
|
||||
|
||||
@@ -60,7 +60,7 @@ def execute_task(task_time, id, content, uid):
|
||||
username = member_db.new_instance().find_username_by_uid(uid=uid)
|
||||
if not username:
|
||||
username = "User"
|
||||
interact = Interact("text", 1, {'user': username, 'msg': "执行任务->\n" + content, 'observation': ""})
|
||||
interact = Interact("text", 1, {'user': username, 'msg': "执行任务->立刻\n" + content, 'observation': ""})
|
||||
util.printInfo(3, "系统", '执行任务:{}'.format(interact.data["msg"]), time.time())
|
||||
text = fay_booter.feiFei.on_interact(interact)
|
||||
if text is not None and id in scheduled_tasks:
|
||||
|
||||
BIN
samples/sample-1735661618567.mp3
Normal file
BIN
samples/sample-1735661618567.mp3
Normal file
Binary file not shown.
@@ -93,7 +93,7 @@ class Speech:
|
||||
httpHeaders = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
text = f"<speak>{text}</speak>"
|
||||
# text = f"<speak>{text}</speak>"
|
||||
# 设置HTTPS Body。
|
||||
body = {'appkey': self.ali_nls_app_key, 'token': self.token,'speech_rate':0, 'text': text, 'format': 'wav', 'sample_rate': 16000, 'voice': config_util.config["attribute"]["voice"]}
|
||||
body = json.dumps(body)
|
||||
|
||||
Reference in New Issue
Block a user