Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
b2ab862
1
Parent(s):
1c59c7e
Resolve TTS dep error
Browse files- app.py +13 -2
- requirements.txt +6 -3
app.py
CHANGED
|
@@ -37,7 +37,12 @@ from duckduckgo_search import DDGS
|
|
| 37 |
import requests
|
| 38 |
from bs4 import BeautifulSoup
|
| 39 |
import whisper
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
import numpy as np
|
| 42 |
import soundfile as sf
|
| 43 |
import tempfile
|
|
@@ -222,6 +227,9 @@ def initialize_whisper_model():
|
|
| 222 |
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 |
try:
|
| 227 |
logger.info("Initializing TTS model for voice generation...")
|
|
@@ -229,7 +237,7 @@ def initialize_tts_model():
|
|
| 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
|
| 233 |
global_tts_model = None
|
| 234 |
return global_tts_model
|
| 235 |
|
|
@@ -267,6 +275,9 @@ def transcribe_audio(audio):
|
|
| 267 |
|
| 268 |
def generate_speech(text: str):
|
| 269 |
"""Generate speech from text using TTS model"""
|
|
|
|
|
|
|
|
|
|
| 270 |
global global_tts_model
|
| 271 |
if global_tts_model is None:
|
| 272 |
initialize_tts_model()
|
|
|
|
| 37 |
import requests
|
| 38 |
from bs4 import BeautifulSoup
|
| 39 |
import whisper
|
| 40 |
+
try:
|
| 41 |
+
from TTS.api import TTS
|
| 42 |
+
TTS_AVAILABLE = True
|
| 43 |
+
except ImportError:
|
| 44 |
+
TTS_AVAILABLE = False
|
| 45 |
+
TTS = None
|
| 46 |
import numpy as np
|
| 47 |
import soundfile as sf
|
| 48 |
import tempfile
|
|
|
|
| 227 |
def initialize_tts_model():
|
| 228 |
"""Initialize TTS model for text-to-speech"""
|
| 229 |
global global_tts_model
|
| 230 |
+
if not TTS_AVAILABLE:
|
| 231 |
+
logger.warning("TTS library not installed. TTS features will be disabled.")
|
| 232 |
+
return None
|
| 233 |
if global_tts_model is None:
|
| 234 |
try:
|
| 235 |
logger.info("Initializing TTS model for voice generation...")
|
|
|
|
| 237 |
logger.info("TTS model initialized successfully")
|
| 238 |
except Exception as e:
|
| 239 |
logger.warning(f"TTS model initialization failed: {e}")
|
| 240 |
+
logger.warning("TTS features will be disabled. If pyworld dependency is missing, try: pip install TTS --no-deps && pip install coqui-tts")
|
| 241 |
global_tts_model = None
|
| 242 |
return global_tts_model
|
| 243 |
|
|
|
|
| 275 |
|
| 276 |
def generate_speech(text: str):
|
| 277 |
"""Generate speech from text using TTS model"""
|
| 278 |
+
if not TTS_AVAILABLE:
|
| 279 |
+
logger.error("TTS library not installed. Please install TTS to use voice generation.")
|
| 280 |
+
return None
|
| 281 |
global global_tts_model
|
| 282 |
if global_tts_model is None:
|
| 283 |
initialize_tts_model()
|
requirements.txt
CHANGED
|
@@ -21,6 +21,9 @@ openai-whisper
|
|
| 21 |
soundfile
|
| 22 |
numpy<2.0.0
|
| 23 |
setuptools>=65.0.0
|
| 24 |
-
# TTS installation -
|
| 25 |
-
#
|
| 26 |
-
TTS
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
soundfile
|
| 22 |
numpy<2.0.0
|
| 23 |
setuptools>=65.0.0
|
| 24 |
+
# TTS installation (OPTIONAL) - TTS features work without it
|
| 25 |
+
# If you want TTS functionality, install manually due to pyworld build issues:
|
| 26 |
+
# Option 1: pip install TTS --no-deps && pip install coqui-tts
|
| 27 |
+
# Option 2: pip install TTS (may fail on pyworld, but TTS will work for most models without it)
|
| 28 |
+
# The app will run without TTS - voice generation will be disabled
|
| 29 |
+
# TTS
|