Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,12 +20,21 @@ import os
|
|
20 |
from gtts import gTTS
|
21 |
|
22 |
|
|
|
|
|
23 |
def text_to_speech(script):
|
24 |
-
#
|
25 |
if isinstance(script, list):
|
26 |
# Extract text from dictionaries if needed
|
27 |
-
|
|
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
tts = gTTS(text=script, lang='en')
|
30 |
audio_file = 'output.mp3' # Specify your output audio file name
|
31 |
tts.save(audio_file)
|
@@ -33,6 +42,7 @@ def text_to_speech(script):
|
|
33 |
|
34 |
|
35 |
|
|
|
36 |
from moviepy.editor import TextClip
|
37 |
|
38 |
def generate_animation(script):
|
|
|
20 |
from gtts import gTTS
|
21 |
|
22 |
|
23 |
+
from gtts import gTTS
|
24 |
+
|
25 |
def text_to_speech(script):
|
26 |
+
# Check if script is a list and extract text
|
27 |
if isinstance(script, list):
|
28 |
# Extract text from dictionaries if needed
|
29 |
+
texts = [item['text'] for item in script if isinstance(item, dict) and 'text' in item]
|
30 |
+
script = " ".join(texts) # Join extracted texts
|
31 |
|
32 |
+
print("Final script for TTS:", script) # Debugging line
|
33 |
+
|
34 |
+
# Check if script is not empty
|
35 |
+
if not script.strip():
|
36 |
+
raise ValueError("No text to convert to speech.")
|
37 |
+
|
38 |
tts = gTTS(text=script, lang='en')
|
39 |
audio_file = 'output.mp3' # Specify your output audio file name
|
40 |
tts.save(audio_file)
|
|
|
42 |
|
43 |
|
44 |
|
45 |
+
|
46 |
from moviepy.editor import TextClip
|
47 |
|
48 |
def generate_animation(script):
|