diff --git a/ChatTTS/model/cuda/patch.py b/ChatTTS/model/cuda/patch.py index 873a383..cff8ff7 100644 --- a/ChatTTS/model/cuda/patch.py +++ b/ChatTTS/model/cuda/patch.py @@ -1,5 +1,6 @@ import torch + class LlamaRMSNorm(torch.nn.Module): def __init__(self, hidden_size, eps=1e-6): """ diff --git a/ChatTTS/model/cuda/te_llama.py b/ChatTTS/model/cuda/te_llama.py index 9e9b241..a625f69 100644 --- a/ChatTTS/model/cuda/te_llama.py +++ b/ChatTTS/model/cuda/te_llama.py @@ -34,9 +34,7 @@ def replace_decoder(te_decoder_cls, llama_rms_norm_cls): transformers.models.llama.modeling_llama.LlamaDecoderLayer ) transformers.models.llama.modeling_llama.LlamaDecoderLayer = te_decoder_cls - original_llama_rms_norm_cls = ( - transformers.models.llama.modeling_llama.LlamaRMSNorm - ) + original_llama_rms_norm_cls = transformers.models.llama.modeling_llama.LlamaRMSNorm transformers.models.llama.modeling_llama.LlamaRMSNorm = llama_rms_norm_cls try: yield @@ -44,7 +42,9 @@ def replace_decoder(te_decoder_cls, llama_rms_norm_cls): transformers.models.llama.modeling_llama.LlamaDecoderLayer = ( original_llama_decoder_cls ) - transformers.models.llama.modeling_llama.LlamaRMSNorm = original_llama_rms_norm_cls + transformers.models.llama.modeling_llama.LlamaRMSNorm = ( + original_llama_rms_norm_cls + ) class TELlamaDecoderLayer(te.pytorch.TransformerLayer): @@ -104,7 +104,9 @@ class TELlamaModel: """ def __new__(cls, config: LlamaConfig): - with replace_decoder(te_decoder_cls=TELlamaDecoderLayer, llama_rms_norm_cls=LlamaRMSNorm): + with replace_decoder( + te_decoder_cls=TELlamaDecoderLayer, llama_rms_norm_cls=LlamaRMSNorm + ): model = LlamaModel(config) return model diff --git a/examples/web/funcs.py b/examples/web/funcs.py index 8f02d74..6c53ce7 100644 --- a/examples/web/funcs.py +++ b/examples/web/funcs.py @@ -151,7 +151,15 @@ def refine_text( def generate_audio( - text, temperature, top_P, top_K, spk_emb_text: str, stream, audio_seed_input, sample_text_input, sample_audio_code_input, + text, + temperature, + top_P, + top_K, + spk_emb_text: str, + stream, + audio_seed_input, + sample_text_input, + sample_audio_code_input, ): global chat, has_interrupted diff --git a/examples/web/webui.py b/examples/web/webui.py index 2c2ff2a..110addb 100644 --- a/examples/web/webui.py +++ b/examples/web/webui.py @@ -158,7 +158,8 @@ def main(): sample_audio_input.change( fn=on_upload_sample_audio, - inputs=sample_audio_input, outputs=sample_audio_code_input, + inputs=sample_audio_input, + outputs=sample_audio_code_input, ).then(fn=lambda: gr.Info("Sampled Audio Code generated at another Tab.")) # 使用Gradio的回调功能来更新数值输入框