Spaces:
Running on Zero
Running on Zero
Clean up debugging output
Browse files
app.py
CHANGED
|
@@ -65,20 +65,14 @@ try:
|
|
| 65 |
with tarfile.open(voices_tgz, "r:gz") as tar:
|
| 66 |
tar.extractall(VOICES_DIR)
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
for
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
# Check if voices are in a subdirectory (e.g., "voices/")
|
| 77 |
-
subdirs = [d for d in os.listdir(VOICES_DIR) if os.path.isdir(os.path.join(VOICES_DIR, d))]
|
| 78 |
-
if subdirs and not any(f.endswith('.pt') for f in os.listdir(VOICES_DIR)):
|
| 79 |
-
# Voices are in a subdirectory
|
| 80 |
-
VOICES_DIR = os.path.join(VOICES_DIR, subdirs[0])
|
| 81 |
-
print(f" -> Using subdirectory: {VOICES_DIR}")
|
| 82 |
|
| 83 |
# Load tokenizer
|
| 84 |
TEXT_TOKENIZER = SentencePieceProcessor(TOKENIZER_PATH)
|
|
@@ -186,11 +180,10 @@ def generate_response(
|
|
| 186 |
# Load voice prompt
|
| 187 |
voice_file = VOICES.get(voice, "NATF2.pt")
|
| 188 |
voice_path = os.path.join(VOICES_DIR, voice_file)
|
| 189 |
-
print(f"Loading voice prompt: {voice_path}")
|
| 190 |
if not os.path.exists(voice_path):
|
| 191 |
-
# Try listing available voices for debugging
|
| 192 |
available = [f for f in os.listdir(VOICES_DIR) if f.endswith('.pt')]
|
| 193 |
-
raise gr.Error(f"Voice
|
|
|
|
| 194 |
lm_gen.load_voice_prompt_embeddings(voice_path)
|
| 195 |
|
| 196 |
# Set text prompt (persona)
|
|
|
|
| 65 |
with tarfile.open(voices_tgz, "r:gz") as tar:
|
| 66 |
tar.extractall(VOICES_DIR)
|
| 67 |
|
| 68 |
+
# Check if voices are in a subdirectory (some tarballs have nested structure)
|
| 69 |
+
pt_files = [f for f in os.listdir(VOICES_DIR) if f.endswith('.pt')]
|
| 70 |
+
if not pt_files:
|
| 71 |
+
subdirs = [d for d in os.listdir(VOICES_DIR) if os.path.isdir(os.path.join(VOICES_DIR, d))]
|
| 72 |
+
if subdirs:
|
| 73 |
+
VOICES_DIR = os.path.join(VOICES_DIR, subdirs[0])
|
| 74 |
+
pt_files = [f for f in os.listdir(VOICES_DIR) if f.endswith('.pt')]
|
| 75 |
+
print(f"Voices directory: {VOICES_DIR} ({len(pt_files)} voice files)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
# Load tokenizer
|
| 78 |
TEXT_TOKENIZER = SentencePieceProcessor(TOKENIZER_PATH)
|
|
|
|
| 180 |
# Load voice prompt
|
| 181 |
voice_file = VOICES.get(voice, "NATF2.pt")
|
| 182 |
voice_path = os.path.join(VOICES_DIR, voice_file)
|
|
|
|
| 183 |
if not os.path.exists(voice_path):
|
|
|
|
| 184 |
available = [f for f in os.listdir(VOICES_DIR) if f.endswith('.pt')]
|
| 185 |
+
raise gr.Error(f"Voice '{voice_file}' not found. Available: {available}")
|
| 186 |
+
print(f"Voice: {voice_file}")
|
| 187 |
lm_gen.load_voice_prompt_embeddings(voice_path)
|
| 188 |
|
| 189 |
# Set text prompt (persona)
|