Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tts-ranking
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
audio
tts-ranking
Commits
a9fd4496
Commit
a9fd4496
authored
Jul 13, 2026
by
程裕兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(luna-tts): load models in background thread so host responds to Chrome immediately
parent
07cae1b7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
server/native_host.py
+21
-8
No files found.
server/native_host.py
View file @
a9fd4496
...
...
@@ -89,22 +89,28 @@ def _write_status(status, detail=""):
def
main
():
_log_stderr
(
"[host] Starting Native Messaging host..."
)
_write_status
(
"starting"
,
"Loading
our references...
"
)
_write_status
(
"starting"
,
"Loading
models... (may take minutes on Intel Mac)
"
)
our_dir
=
BASE_DIR
/
REFERENCE_DIRS
[
"our"
]
competitor_dir
=
BASE_DIR
/
REFERENCE_DIRS
[
"competitor"
]
big_vendor_dir
=
BASE_DIR
/
REFERENCE_DIRS
[
"big_vendor"
]
_write_status
(
"starting"
,
"Loading competitor references..."
)
_write_status
(
"starting"
,
"Loading big vendor references..."
)
# Load models in background while message loop responds immediately to status requests
import
threading
matcher
=
[
None
]
# mutable container for thread to write into
load_done
=
threading
.
Event
()
matcher
=
MultiMatcher
(
our_dir
,
competitor_dir
,
big_vendor_dir
)
def
_load
():
matcher
[
0
]
=
MultiMatcher
(
our_dir
,
competitor_dir
,
big_vendor_dir
)
_write_status
(
"ready"
,
"Models loaded"
)
_log_stderr
(
"[host] Models loaded, ready for matching"
)
load_done
.
set
()
threading
.
Thread
(
target
=
_load
,
daemon
=
True
)
.
start
()
today_votes
=
0
today_skips
=
0
luna_votes
=
0
_write_status
(
"ready"
,
f
"Models loaded, {today_votes} votes today"
)
_log_stderr
(
"[host] Ready, waiting for messages..."
)
while
True
:
data
=
read_message
()
...
...
@@ -114,6 +120,13 @@ def main():
msg_type
=
data
.
get
(
"type"
)
if
msg_type
==
"match_request"
:
# Wait for model loading to complete
if
not
load_done
.
is_set
():
_write_status
(
"loading"
,
"Waiting for models to load before matching..."
)
_log_stderr
(
"[host] Waiting for models to load..."
)
load_done
.
wait
()
_log_stderr
(
"[host] Models ready, processing match request"
)
request_id
=
data
[
"request_id"
]
audio_left_url
=
data
[
"audio_left"
]
audio_right_url
=
data
[
"audio_right"
]
...
...
@@ -148,8 +161,8 @@ def main():
})
continue
left_result
=
matcher
.
match_one
(
left_path
)
right_result
=
matcher
.
match_one
(
right_path
)
left_result
=
matcher
[
0
]
.
match_one
(
left_path
)
right_result
=
matcher
[
0
]
.
match_one
(
right_path
)
def
_build_side
(
label
,
r
):
our_sp
,
our_sc
=
r
.
our
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment