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
class MAINUI:
def __init__(self) -> None:
super().__init__()
@ -628,7 +627,8 @@ class MAINUI:
return
if text2 is None:
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):
if needresult:

View File

@ -168,6 +168,11 @@ class bgmsettings(QDialog):
def __oauth(self):
gobject.baseobject.urlprotocol()
bangumioauth = gobject.getcachedir("bangumioauth")
try:
os.remove(bangumioauth)
except:
pass
gobject.baseobject.openlink(
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.lock = threading.Lock()
self.lock.acquire()
self.timestamp = None
self.lastcontext = None
threading.Thread(target=self.__dotasks).start()
def stop(self):
self.timestamp = None
try:
self.tasks = (None, 0, True)
self.lock.release()
except:
pass
def play(self, binary, volume, force):
def play(self, binary, volume, force, timestamp):
if timestamp != self.timestamp:
return
try:
self.tasks = (binary, volume, force)
self.lock.release()

View File

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

View File

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

View File

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