Spaces:
Sleeping
Sleeping
Add logging for background music file discovery and choices
Browse files- app.py +3 -0
- engine/audio_processor.py +11 -2
app.py
CHANGED
|
@@ -156,6 +156,8 @@ def get_background_music_choices() -> list[tuple[str, str]]:
|
|
| 156 |
processor = AudioProcessor()
|
| 157 |
music_files = processor.list_available_music()
|
| 158 |
|
|
|
|
|
|
|
| 159 |
# Create choices with display names
|
| 160 |
choices = [("🔇 Keine Hintergrundmusik", "")]
|
| 161 |
for name in music_files:
|
|
@@ -163,6 +165,7 @@ def get_background_music_choices() -> list[tuple[str, str]]:
|
|
| 163 |
display = name.replace("_", " ").replace("-", " ").title()
|
| 164 |
choices.append((f"🎵 {display}", name))
|
| 165 |
|
|
|
|
| 166 |
return choices
|
| 167 |
|
| 168 |
|
|
|
|
| 156 |
processor = AudioProcessor()
|
| 157 |
music_files = processor.list_available_music()
|
| 158 |
|
| 159 |
+
logger.info(f"Background music files found: {music_files}")
|
| 160 |
+
|
| 161 |
# Create choices with display names
|
| 162 |
choices = [("🔇 Keine Hintergrundmusik", "")]
|
| 163 |
for name in music_files:
|
|
|
|
| 165 |
display = name.replace("_", " ").replace("-", " ").title()
|
| 166 |
choices.append((f"🎵 {display}", name))
|
| 167 |
|
| 168 |
+
logger.info(f"Background music choices: {len(choices) - 1} options available")
|
| 169 |
return choices
|
| 170 |
|
| 171 |
|
engine/audio_processor.py
CHANGED
|
@@ -192,10 +192,19 @@ class AudioProcessor:
|
|
| 192 |
|
| 193 |
def list_available_music(self) -> list[str]:
|
| 194 |
"""List available background music files in the assets directory."""
|
|
|
|
|
|
|
|
|
|
| 195 |
if not self.ASSETS_DIR.exists():
|
|
|
|
| 196 |
return []
|
| 197 |
|
| 198 |
music_files = []
|
| 199 |
for ext in ["mp3", "wav", "flac", "ogg"]:
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
def list_available_music(self) -> list[str]:
|
| 194 |
"""List available background music files in the assets directory."""
|
| 195 |
+
logger.debug(f"Looking for music in: {self.ASSETS_DIR}")
|
| 196 |
+
logger.debug(f"ASSETS_DIR exists: {self.ASSETS_DIR.exists()}")
|
| 197 |
+
|
| 198 |
if not self.ASSETS_DIR.exists():
|
| 199 |
+
logger.warning(f"Assets directory not found: {self.ASSETS_DIR}")
|
| 200 |
return []
|
| 201 |
|
| 202 |
music_files = []
|
| 203 |
for ext in ["mp3", "wav", "flac", "ogg"]:
|
| 204 |
+
found = list(self.ASSETS_DIR.glob(f"*.{ext}"))
|
| 205 |
+
logger.debug(f"Found {len(found)} .{ext} files")
|
| 206 |
+
music_files.extend([f.stem for f in found])
|
| 207 |
+
|
| 208 |
+
result = sorted(set(music_files))
|
| 209 |
+
logger.info(f"Available background music: {result}")
|
| 210 |
+
return result
|