victor HF Staff commited on
Commit
e915802
·
1 Parent(s): 6ba985c

Clean up debugging output

Browse files
Files changed (1) hide show
  1. app.py +10 -17
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
- # List extracted files to find the correct path
69
- print(f"Voices extracted to: {VOICES_DIR}")
70
- for root, dirs, files in os.walk(VOICES_DIR):
71
- for f in files:
72
- full_path = os.path.join(root, f)
73
- rel_path = os.path.relpath(full_path, VOICES_DIR)
74
- print(f" Voice file: {rel_path}")
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 file not found: {voice_file}. Available: {available}")
 
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)