Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,9 +18,9 @@ RVC_INDEX_PATH = "zeldabotw.index"
|
|
18 |
|
19 |
# Function to call RVC for voice conversion
|
20 |
def convert_voice(input_wav, output_wav):
|
21 |
-
"""Converts
|
22 |
if not os.path.exists(RVC_MODEL_PATH) or not os.path.exists(RVC_INDEX_PATH):
|
23 |
-
raise FileNotFoundError("RVC model files not found
|
24 |
|
25 |
command = f"python infer_rvc.py --input {input_wav} --output {output_wav} --model {RVC_MODEL_PATH} --index {RVC_INDEX_PATH} --pitch_shift 0"
|
26 |
|
@@ -31,9 +31,7 @@ def convert_voice(input_wav, output_wav):
|
|
31 |
return output_wav
|
32 |
|
33 |
# Chatbot Response + TTS + RVC
|
34 |
-
def respond(
|
35 |
-
message, history, system_message, max_tokens, temperature, top_p
|
36 |
-
):
|
37 |
messages = [{"role": "system", "content": system_message}]
|
38 |
|
39 |
for val in history:
|
@@ -43,9 +41,7 @@ def respond(
|
|
43 |
messages.append({"role": "user", "content": message})
|
44 |
|
45 |
response = ""
|
46 |
-
for message in client.chat_completion(
|
47 |
-
messages, max_tokens=max_tokens, stream=True, temperature=temperature, top_p=top_p
|
48 |
-
):
|
49 |
token = message.choices[0].delta.content
|
50 |
response += token
|
51 |
yield response, None, None # Text first
|
|
|
18 |
|
19 |
# Function to call RVC for voice conversion
|
20 |
def convert_voice(input_wav, output_wav):
|
21 |
+
"""Converts input TTS audio to ZeldaBotW voice using RVC."""
|
22 |
if not os.path.exists(RVC_MODEL_PATH) or not os.path.exists(RVC_INDEX_PATH):
|
23 |
+
raise FileNotFoundError("RVC model files not found! Ensure zeldabotw.pth and zeldabotw.index are in the same directory.")
|
24 |
|
25 |
command = f"python infer_rvc.py --input {input_wav} --output {output_wav} --model {RVC_MODEL_PATH} --index {RVC_INDEX_PATH} --pitch_shift 0"
|
26 |
|
|
|
31 |
return output_wav
|
32 |
|
33 |
# Chatbot Response + TTS + RVC
|
34 |
+
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
|
|
|
35 |
messages = [{"role": "system", "content": system_message}]
|
36 |
|
37 |
for val in history:
|
|
|
41 |
messages.append({"role": "user", "content": message})
|
42 |
|
43 |
response = ""
|
44 |
+
for message in client.chat_completion(messages, max_tokens=max_tokens, stream=True, temperature=temperature, top_p=top_p):
|
|
|
|
|
45 |
token = message.choices[0].delta.content
|
46 |
response += token
|
47 |
yield response, None, None # Text first
|