Spaces:
Sleeping
Sleeping
hashhac
commited on
Commit
·
8e6480a
1
Parent(s):
1d9e509
try
Browse files
app.py
CHANGED
@@ -95,6 +95,10 @@ def load_llm_model():
|
|
95 |
# Step 3: Text-to-Speech with gTTS (Google Text-to-Speech)
|
96 |
def gtts_text_to_speech(text):
|
97 |
"""Convert text to speech using gTTS and ensure proper WAV format."""
|
|
|
|
|
|
|
|
|
98 |
# Create absolute paths for temporary files
|
99 |
temp_dir = tempfile.gettempdir()
|
100 |
mp3_filename = os.path.join(temp_dir, f"tts_temp_{os.getpid()}_{time.time()}.mp3")
|
@@ -154,12 +158,9 @@ def gtts_text_to_speech(text):
|
|
154 |
except Exception as e:
|
155 |
print(f"pydub conversion failed: {str(e)}")
|
156 |
|
157 |
-
# Method 3: Direct WAV creation
|
158 |
if not wav_created:
|
159 |
try:
|
160 |
-
import numpy as np
|
161 |
-
from scipy.io import wavfile
|
162 |
-
|
163 |
print("Generating synthetic speech directly...")
|
164 |
# Generate a simple speech-like tone pattern
|
165 |
sample_rate = 24000
|
|
|
95 |
# Step 3: Text-to-Speech with gTTS (Google Text-to-Speech)
|
96 |
def gtts_text_to_speech(text):
|
97 |
"""Convert text to speech using gTTS and ensure proper WAV format."""
|
98 |
+
# Import numpy and wavfile at the function level to ensure they're available in all code paths
|
99 |
+
import numpy as np
|
100 |
+
from scipy.io import wavfile
|
101 |
+
|
102 |
# Create absolute paths for temporary files
|
103 |
temp_dir = tempfile.gettempdir()
|
104 |
mp3_filename = os.path.join(temp_dir, f"tts_temp_{os.getpid()}_{time.time()}.mp3")
|
|
|
158 |
except Exception as e:
|
159 |
print(f"pydub conversion failed: {str(e)}")
|
160 |
|
161 |
+
# Method 3: Direct WAV creation
|
162 |
if not wav_created:
|
163 |
try:
|
|
|
|
|
|
|
164 |
print("Generating synthetic speech directly...")
|
165 |
# Generate a simple speech-like tone pattern
|
166 |
sample_rate = 24000
|