Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
1c59c7e
1
Parent(s):
812cc3b
Resolve TTS dep error
Browse files- app.py +22 -5
- requirements.txt +6 -2
app.py
CHANGED
|
@@ -223,9 +223,14 @@ def initialize_tts_model():
|
|
| 223 |
"""Initialize TTS model for text-to-speech"""
|
| 224 |
global global_tts_model
|
| 225 |
if global_tts_model is None:
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
return global_tts_model
|
| 230 |
|
| 231 |
def transcribe_audio(audio):
|
|
@@ -266,6 +271,10 @@ def generate_speech(text: str):
|
|
| 266 |
if global_tts_model is None:
|
| 267 |
initialize_tts_model()
|
| 268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
if not text or len(text.strip()) == 0:
|
| 270 |
return None
|
| 271 |
|
|
@@ -1345,7 +1354,15 @@ if __name__ == "__main__":
|
|
| 1345 |
logger.info("Preloading Whisper model...")
|
| 1346 |
initialize_whisper_model()
|
| 1347 |
logger.info("Preloading TTS model...")
|
| 1348 |
-
|
| 1349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1350 |
demo = create_demo()
|
| 1351 |
demo.launch()
|
|
|
|
| 223 |
"""Initialize TTS model for text-to-speech"""
|
| 224 |
global global_tts_model
|
| 225 |
if global_tts_model is None:
|
| 226 |
+
try:
|
| 227 |
+
logger.info("Initializing TTS model for voice generation...")
|
| 228 |
+
global_tts_model = TTS(model_name=TTS_MODEL, progress_bar=False)
|
| 229 |
+
logger.info("TTS model initialized successfully")
|
| 230 |
+
except Exception as e:
|
| 231 |
+
logger.warning(f"TTS model initialization failed: {e}")
|
| 232 |
+
logger.warning("TTS features will be disabled. If pyworld dependency is missing, try: pip install pyworld")
|
| 233 |
+
global_tts_model = None
|
| 234 |
return global_tts_model
|
| 235 |
|
| 236 |
def transcribe_audio(audio):
|
|
|
|
| 271 |
if global_tts_model is None:
|
| 272 |
initialize_tts_model()
|
| 273 |
|
| 274 |
+
if global_tts_model is None:
|
| 275 |
+
logger.error("TTS model not available. Please check dependencies.")
|
| 276 |
+
return None
|
| 277 |
+
|
| 278 |
if not text or len(text.strip()) == 0:
|
| 279 |
return None
|
| 280 |
|
|
|
|
| 1354 |
logger.info("Preloading Whisper model...")
|
| 1355 |
initialize_whisper_model()
|
| 1356 |
logger.info("Preloading TTS model...")
|
| 1357 |
+
try:
|
| 1358 |
+
initialize_tts_model()
|
| 1359 |
+
if global_tts_model is not None:
|
| 1360 |
+
logger.info("TTS model preloaded successfully!")
|
| 1361 |
+
else:
|
| 1362 |
+
logger.warning("TTS model not available - voice generation will be disabled")
|
| 1363 |
+
except Exception as e:
|
| 1364 |
+
logger.warning(f"TTS model preloading failed: {e}")
|
| 1365 |
+
logger.warning("Voice generation features will be disabled")
|
| 1366 |
+
logger.info("Model preloading complete!")
|
| 1367 |
demo = create_demo()
|
| 1368 |
demo.launch()
|
requirements.txt
CHANGED
|
@@ -14,9 +14,13 @@ google-genai
|
|
| 14 |
langdetect
|
| 15 |
requests
|
| 16 |
beautifulsoup4
|
| 17 |
-
|
| 18 |
gradio
|
| 19 |
spaces
|
| 20 |
openai-whisper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
TTS
|
| 22 |
-
soundfile
|
|
|
|
| 14 |
langdetect
|
| 15 |
requests
|
| 16 |
beautifulsoup4
|
| 17 |
+
ddgs
|
| 18 |
gradio
|
| 19 |
spaces
|
| 20 |
openai-whisper
|
| 21 |
+
soundfile
|
| 22 |
+
numpy<2.0.0
|
| 23 |
+
setuptools>=65.0.0
|
| 24 |
+
# TTS installation - if pyworld fails, TTS will work without it for most models
|
| 25 |
+
# For maya1 model, try: pip install TTS --no-deps && pip install coqui-tts
|
| 26 |
TTS
|
|
|