Skip to content

Commit 09d6619

Browse files
authored
* Fix install/uninstall in extension manager (#481)
* Add Kokoro TTS extension
1 parent 180ca13 commit 09d6619

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474

7575
## Changelog
7676

77+
Apr 20:
78+
* Fix install/uninstall in extension manager
79+
* Add Kokoro TTS extension
80+
7781
Apr 18:
7882
* Fix extension manager startup
7983
* Convert most models to extensions, install the classic ones by default

extensions.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,21 @@
433433
"extension_website": "https://github.com/rsxdalv/extension_mars5",
434434
"extension_platform_version": "0.0.1"
435435
},
436+
{
437+
"package_name": "extension_kokoro",
438+
"name": "Kokoro",
439+
"version": "0.0.1",
440+
"requirements": "git+https://github.com/rsxdalv/extension_kokoro@main",
441+
"description": "Kokoro: A small, fast, and high-quality TTS model",
442+
"extension_type": "interface",
443+
"extension_class": "text-to-speech",
444+
"author": "hexgrad",
445+
"extension_author": "rsxdalv",
446+
"license": "MIT",
447+
"website": "https://huggingface.co/hexgrad/Kokoro-82M",
448+
"extension_website": "https://github.com/rsxdalv/extension_kokoro",
449+
"extension_platform_version": "0.0.1"
450+
},
436451
{
437452
"package_name": "extensions.builtin.extension_model_downloader",
438453
"name": "Model Downloader",

tools/extension_manager.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import importlib
88

99
# Add the project root directory to the Python path
10-
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
10+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
1111

1212
from tts_webui.css.css import full_css
1313

@@ -321,23 +321,27 @@ def display_extension_ui(x, is_installed, is_disabled):
321321
# Check if this is a built-in extension
322322
is_builtin = package_name.startswith("extensions.builtin")
323323

324+
def install_extension():
325+
yield from pip_install_wrapper(x["requirements"], package_name)()
326+
324327
if is_installed:
325328
if not is_builtin:
326329
# Update button (only for non-builtin extensions)
327330
update_btn = gr.Button("Update", variant="primary")
328331
update_btn.click(
329-
fn=lambda pkg=package_name, req=x[
330-
"requirements"
331-
]: pip_install_wrapper(req, pkg)(),
332+
fn=install_extension,
332333
outputs=[gr.HTML()],
333334
)
334335

336+
def uninstall_extension():
337+
yield from pip_uninstall_wrapper(
338+
package_name, package_name
339+
)()
340+
335341
# Uninstall button (only for non-builtin extensions)
336342
uninstall_btn = gr.Button("Uninstall", variant="stop")
337343
uninstall_btn.click(
338-
fn=lambda pkg=package_name: pip_uninstall_wrapper(
339-
pkg, pkg
340-
)(),
344+
fn=uninstall_extension,
341345
outputs=[gr.HTML()],
342346
)
343347

@@ -361,6 +365,12 @@ def toggle_extension(package_name=package_name):
361365
toggle_btn.click(
362366
fn=toggle_extension,
363367
outputs=[gr.HTML()],
368+
).then(
369+
fn=lambda button_text: gr.Button(
370+
"Enable" if button_text == "Disable" else "Disable"
371+
),
372+
inputs=[toggle_btn],
373+
outputs=[toggle_btn],
364374
)
365375

366376
if is_builtin:
@@ -371,9 +381,7 @@ def toggle_extension(package_name=package_name):
371381
# Install button
372382
install_btn = gr.Button("Install", variant="primary")
373383
install_btn.click(
374-
fn=lambda pkg=package_name, req=x[
375-
"requirements"
376-
]: pip_install_wrapper(req, pkg)(),
384+
fn=install_extension,
377385
outputs=[gr.HTML()],
378386
)
379387

0 commit comments

Comments
 (0)