Spaces:
Runtime error
Runtime error
John Langley
commited on
Commit
·
281ff2d
1
Parent(s):
643e006
change to cpu
Browse files
app.py
CHANGED
@@ -55,32 +55,32 @@ mistral_llm = Llama(model_path=mistral_model_path,n_gpu_layers=35,max_new_tokens
|
|
55 |
|
56 |
# Load XTTS Model
|
57 |
print("Loading XTTS model")
|
58 |
-
model_name = "tts_models/multilingual/multi-dataset/xtts_v2" # move in v2, since xtts_v1 is generated keyerror, I guess you can select it with old github's release.
|
59 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
60 |
#m = ModelManager().download_model(model_name)
|
61 |
##print(m)
|
62 |
-
m = model_name
|
63 |
|
64 |
-
xtts_model = TTS(model_name, gpu=False)
|
65 |
-
xtts_model.to("cpu") # no GPU or Amd
|
66 |
#tts.to("cuda") # cuda only
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
#xtts_model.cuda()
|
83 |
-
|
84 |
|
85 |
###### Set up Gradio Interface ######
|
86 |
|
@@ -154,11 +154,10 @@ with gr.Blocks(title="Voice chat with LLM") as demo:
|
|
154 |
def handle_speech_generation(sentence, chatbot_history, chatbot_voice):
|
155 |
if sentence != "":
|
156 |
print("Processing sentence")
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
# yield (sentence, chatbot_history, audio_dict["value"])
|
162 |
|
163 |
if initial_greeting:
|
164 |
# Process only the initial greeting if specified
|
|
|
55 |
|
56 |
# Load XTTS Model
|
57 |
print("Loading XTTS model")
|
58 |
+
#model_name = "tts_models/multilingual/multi-dataset/xtts_v2" # move in v2, since xtts_v1 is generated keyerror, I guess you can select it with old github's release.
|
59 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
60 |
#m = ModelManager().download_model(model_name)
|
61 |
##print(m)
|
62 |
+
#m = model_name
|
63 |
|
64 |
+
#xtts_model = TTS(model_name, gpu=False)
|
65 |
+
#xtts_model.to("cpu") # no GPU or Amd
|
66 |
#tts.to("cuda") # cuda only
|
67 |
|
68 |
+
tts_model_name = "tts_models/multilingual/multi-dataset/xtts_v2"
|
69 |
+
ModelManager().download_model(tts_model_name)
|
70 |
+
tts_model_path = os.path.join(get_user_data_dir("tts"), tts_model_name.replace("/", "--"))
|
71 |
+
config = XttsConfig()
|
72 |
+
config.load_json(os.path.join(tts_model_path, "config.json"))
|
73 |
+
xtts_model = Xtts.init_from_config(config)
|
74 |
+
xtts_model.to("cpu")
|
75 |
+
xtts_model.load_checkpoint(
|
76 |
+
config,
|
77 |
+
checkpoint_path=os.path.join(tts_model_path, "model.pth"),
|
78 |
+
vocab_path=os.path.join(tts_model_path, "vocab.json"),
|
79 |
+
eval=True,
|
80 |
+
use_deepspeed=True,
|
81 |
+
)
|
82 |
#xtts_model.cuda()
|
83 |
+
print("Loaded XTTS model")
|
84 |
|
85 |
###### Set up Gradio Interface ######
|
86 |
|
|
|
154 |
def handle_speech_generation(sentence, chatbot_history, chatbot_voice):
|
155 |
if sentence != "":
|
156 |
print("Processing sentence")
|
157 |
+
generated_speech = generate_speech_for_sentence(chatbot_history, chatbot_voice, sentence, xtts_model, None, return_as_byte=True)
|
158 |
+
if generated_speech is not None:
|
159 |
+
_, audio_dict = generated_speech
|
160 |
+
yield (sentence, chatbot_history, audio_dict["value"])
|
|
|
161 |
|
162 |
if initial_greeting:
|
163 |
# Process only the initial greeting if specified
|