This commit is contained in:
恍兮惚兮 2024-08-27 16:25:56 +08:00
parent 862d5378eb
commit d84e2a1dda
6 changed files with 21 additions and 11 deletions

View File

@ -53,7 +53,6 @@ from gui.dynalang import LAction, LMenu
from gui.setting_textinput_ocr import showocrimage from gui.setting_textinput_ocr import showocrimage
class MAINUI: class MAINUI:
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
@ -628,7 +627,8 @@ class MAINUI:
return return
if text2 is None: if text2 is None:
text2 = self.ttsrepair(text1, self.__usewhich()) text2 = self.ttsrepair(text1, self.__usewhich())
reader.read(text2, force) self.audioplayer.timestamp = uuid.uuid4()
reader.read(text2, force, self.audioplayer.timestamp)
def readcurrent(self, force=False, needresult=False): def readcurrent(self, force=False, needresult=False):
if needresult: if needresult:

View File

@ -168,6 +168,11 @@ class bgmsettings(QDialog):
def __oauth(self): def __oauth(self):
gobject.baseobject.urlprotocol() gobject.baseobject.urlprotocol()
bangumioauth = gobject.getcachedir("bangumioauth")
try:
os.remove(bangumioauth)
except:
pass
gobject.baseobject.openlink( gobject.baseobject.openlink(
f'https://bgm.tv/oauth/authorize?client_id={static_data["bangumi_oauth"]["client_id"]}&response_type=code&redirect_uri=lunatranslator://bangumioauth' f'https://bgm.tv/oauth/authorize?client_id={static_data["bangumi_oauth"]["client_id"]}&response_type=code&redirect_uri=lunatranslator://bangumioauth'
) )

View File

@ -99,18 +99,21 @@ class series_audioplayer:
self.tasks = None self.tasks = None
self.lock = threading.Lock() self.lock = threading.Lock()
self.lock.acquire() self.lock.acquire()
self.timestamp = None
self.lastcontext = None self.lastcontext = None
threading.Thread(target=self.__dotasks).start() threading.Thread(target=self.__dotasks).start()
def stop(self): def stop(self):
self.timestamp = None
try: try:
self.tasks = (None, 0, True) self.tasks = (None, 0, True)
self.lock.release() self.lock.release()
except: except:
pass pass
def play(self, binary, volume, force): def play(self, binary, volume, force, timestamp):
if timestamp != self.timestamp:
return
try: try:
self.tasks = (binary, volume, force) self.tasks = (binary, volume, force)
self.lock.release() self.lock.release()

View File

@ -158,8 +158,8 @@ class TS(basetrans):
"Temperature": self.config["Temperature"], "Temperature": self.config["Temperature"],
} }
headers = _build_req_with_tc3_signature( headers = _build_req_with_tc3_signature(
self.multiapikeycurrent["secret_id"],
self.multiapikeycurrent["secret_key"], self.multiapikeycurrent["secret_key"],
self.multiapikeycurrent["secret_id"],
"ChatCompletions", "ChatCompletions",
json_data, json_data,
) )

View File

@ -67,12 +67,12 @@ class TTSbase:
if init: if init:
self.init() self.init()
def read(self, content, force=False): def read(self, content, force=False, timestamp=None):
def _(force, volume, data): def _(force, volume, timestamp, data):
self.playaudiofunction(data, volume, force) self.playaudiofunction(data, volume, force, timestamp)
self.ttscallback(content, functools.partial(_, force, self.volume)) self.ttscallback(content, functools.partial(_, force, self.volume, timestamp))
@threader @threader
def ttscallback(self, content, callback): def ttscallback(self, content, callback):

View File

@ -337,10 +337,12 @@
"rank": 2.5 "rank": 2.5
}, },
"secret_id": { "secret_id": {
"rank": 0 "rank": 0,
"name": "SecretId"
}, },
"secret_key": { "secret_key": {
"rank": 1 "rank": 1,
"name": "SecretKey"
}, },
"model": { "model": {
"rank": 2 "rank": 2