4cfad5ae0f
- 全新ui - 全面优化websocket逻辑,提高数字人和ui连接的稳定性及资源开销 - 全面优化唤醒逻辑,提供稳定的普通唤醒模式和前置词唤醒模式 - 优化拾音质量,支持多声道麦克风拾音 - 优化自动播放服务器的对接机制,提供稳定和兼容旧版ue工程的对接模式 - 数字人接口输出机器人表情,以适应新fay ui及单片机的数字人表情输出 - 使用更高级的音频时长计算方式,可以更精准控制音频播放完成后的逻辑 - 修复点击关闭按钮会导致程序退出的bug - 修复没有麦克风的设备开启麦克风会出错的问题 - 为服务器主机地址提供配置项,以方便服务器部署
65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
import sqlite3
|
|
import time
|
|
import threading
|
|
import functools
|
|
def synchronized(func):
|
|
@functools.wraps(func)
|
|
def wrapper(self, *args, **kwargs):
|
|
with self.lock:
|
|
return func(self, *args, **kwargs)
|
|
return wrapper
|
|
class Authorize_Tb:
|
|
|
|
def __init__(self) -> None:
|
|
self.lock = threading.Lock()
|
|
|
|
|
|
|
|
#初始化
|
|
def init_tb(self):
|
|
conn = sqlite3.connect('fay.db')
|
|
c = conn.cursor()
|
|
c.execute('''
|
|
CREATE TABLE IF NOT EXISTS T_Authorize
|
|
(id INTEGER PRIMARY KEY autoincrement,
|
|
userid char(100),
|
|
accesstoken TEXT,
|
|
expirestime BigInt,
|
|
createtime Int);
|
|
''')
|
|
conn.commit()
|
|
conn.close()
|
|
|
|
#添加
|
|
@synchronized
|
|
def add(self,userid,accesstoken,expirestime):
|
|
self.init_tb()
|
|
conn = sqlite3.connect("fay.db")
|
|
cur = conn.cursor()
|
|
cur.execute("insert into T_Authorize (userid,accesstoken,expirestime,createtime) values (?,?,?,?)",(userid,accesstoken,expirestime,int(time.time())))
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
return cur.lastrowid
|
|
|
|
#查询
|
|
@synchronized
|
|
def find_by_userid(self,userid):
|
|
self.init_tb()
|
|
conn = sqlite3.connect("fay.db")
|
|
cur = conn.cursor()
|
|
cur.execute("select accesstoken,expirestime from T_Authorize where userid = ? order by id desc limit 1",(userid,))
|
|
info = cur.fetchone()
|
|
conn.close()
|
|
return info
|
|
|
|
# 更新token
|
|
@synchronized
|
|
def update_by_userid(self, userid, new_accesstoken, new_expirestime):
|
|
self.init_tb()
|
|
conn = sqlite3.connect("fay.db")
|
|
cur = conn.cursor()
|
|
cur.execute("UPDATE T_Authorize SET accesstoken = ?, expirestime = ? WHERE userid = ?",
|
|
(new_accesstoken, new_expirestime, userid))
|
|
conn.commit()
|
|
conn.close() |