Spaces:
Running
on
Zero
Running
on
Zero
Sync from GitHub repo
Browse filesThis Space is synced from the GitHub repo: https://github.com/SWivid/F5-TTS. Please submit contributions to the Space there
- app.py +40 -26
- pyproject.toml +1 -1
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
# ruff: noqa: E402
|
2 |
# Above allows ruff to ignore E402: module level import not at top of file
|
3 |
|
|
|
4 |
import json
|
5 |
import re
|
6 |
import tempfile
|
@@ -11,6 +12,7 @@ import click
|
|
11 |
import gradio as gr
|
12 |
import numpy as np
|
13 |
import soundfile as sf
|
|
|
14 |
import torchaudio
|
15 |
from cached_path import cached_path
|
16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
@@ -550,35 +552,47 @@ Have a conversation with an AI using your reference voice!
|
|
550 |
"""
|
551 |
)
|
552 |
|
553 |
-
|
554 |
-
load_chat_model_btn = gr.Button("Load Chat Model", variant="primary")
|
555 |
-
|
556 |
-
chat_interface_container = gr.Column(visible=False)
|
557 |
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
|
575 |
-
|
576 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
|
|
|
|
|
|
|
|
|
|
582 |
|
583 |
with chat_interface_container:
|
584 |
with gr.Row():
|
|
|
1 |
# ruff: noqa: E402
|
2 |
# Above allows ruff to ignore E402: module level import not at top of file
|
3 |
|
4 |
+
import gc
|
5 |
import json
|
6 |
import re
|
7 |
import tempfile
|
|
|
12 |
import gradio as gr
|
13 |
import numpy as np
|
14 |
import soundfile as sf
|
15 |
+
import torch
|
16 |
import torchaudio
|
17 |
from cached_path import cached_path
|
18 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
552 |
"""
|
553 |
)
|
554 |
|
555 |
+
chat_model_name_list = ["Qwen/Qwen2.5-3B-Instruct",]
|
|
|
|
|
|
|
556 |
|
557 |
+
@gpu_decorator
|
558 |
+
def load_chat_model(chat_model_name):
|
559 |
+
show_info = gr.Info
|
560 |
+
global chat_model_state, chat_tokenizer_state
|
561 |
+
if chat_model_state is not None:
|
562 |
+
chat_model_state = None
|
563 |
+
chat_tokenizer_state = None
|
564 |
+
gc.collect()
|
565 |
+
torch.cuda.empty_cache()
|
566 |
+
|
567 |
+
show_info(f"Loading chat model: {chat_model_name}")
|
568 |
+
chat_model_state = AutoModelForCausalLM.from_pretrained(chat_model_name, torch_dtype="auto", device_map="auto")
|
569 |
+
chat_tokenizer_state = AutoTokenizer.from_pretrained(chat_model_name)
|
570 |
+
show_info(f"Chat model {chat_model_name} loaded successfully!")
|
571 |
+
|
572 |
+
return gr.update(visible=False), gr.update(visible=True)
|
573 |
|
574 |
+
if USING_SPACES:
|
575 |
+
load_chat_model(chat_model_name_list[0])
|
576 |
+
|
577 |
+
chat_model_name_input = gr.Dropdown(
|
578 |
+
choices=chat_model_name_list,
|
579 |
+
value=chat_model_name_list[0],
|
580 |
+
label="Chat Model Name",
|
581 |
+
info="Enter the name of a HuggingFace chat model",
|
582 |
+
allow_custom_value=not USING_SPACES,
|
583 |
+
)
|
584 |
+
load_chat_model_btn = gr.Button("Load Chat Model", variant="primary", visible=not USING_SPACES)
|
585 |
+
chat_interface_container = gr.Column(visible=USING_SPACES)
|
586 |
|
587 |
+
chat_model_name_input.change(
|
588 |
+
lambda: gr.update(visible=True),
|
589 |
+
None,
|
590 |
+
load_chat_model_btn,
|
591 |
+
show_progress="hidden",
|
592 |
+
)
|
593 |
+
load_chat_model_btn.click(
|
594 |
+
load_chat_model, inputs=[chat_model_name_input], outputs=[load_chat_model_btn, chat_interface_container]
|
595 |
+
)
|
596 |
|
597 |
with chat_interface_container:
|
598 |
with gr.Row():
|
pyproject.toml
CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4 |
|
5 |
[project]
|
6 |
name = "f5-tts"
|
7 |
-
version = "1.0.
|
8 |
description = "F5-TTS: A Fairytaler that Fakes Fluent and Faithful Speech with Flow Matching"
|
9 |
readme = "README.md"
|
10 |
license = {text = "MIT License"}
|
|
|
4 |
|
5 |
[project]
|
6 |
name = "f5-tts"
|
7 |
+
version = "1.0.9"
|
8 |
description = "F5-TTS: A Fairytaler that Fakes Fluent and Faithful Speech with Flow Matching"
|
9 |
readme = "README.md"
|
10 |
license = {text = "MIT License"}
|