Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,19 +8,22 @@ from pydub import AudioSegment
|
|
8 |
|
9 |
script_generator = pipeline("text-generation", model="gpt2", truncation=True, max_length=100)
|
10 |
|
|
|
11 |
def text_to_speech(script):
|
12 |
if isinstance(script, list):
|
13 |
-
texts = [item['
|
14 |
script = " ".join(texts)
|
|
|
15 |
|
16 |
if not script.strip():
|
17 |
raise ValueError("No text to convert to speech.")
|
18 |
-
|
19 |
tts = gTTS(text=script, lang='en')
|
20 |
audio_file = 'output.mp3'
|
21 |
tts.save(audio_file)
|
22 |
return audio_file
|
23 |
|
|
|
24 |
def generate_animation(script):
|
25 |
lines = script.split('\n')
|
26 |
clips = []
|
|
|
8 |
|
9 |
script_generator = pipeline("text-generation", model="gpt2", truncation=True, max_length=100)
|
10 |
|
11 |
+
|
12 |
def text_to_speech(script):
|
13 |
if isinstance(script, list):
|
14 |
+
texts = [item['generated_text'] for item in script if isinstance(item, dict) and 'generated_text' in item]
|
15 |
script = " ".join(texts)
|
16 |
+
print("Final script for TTS:", script) # Debugging line
|
17 |
|
18 |
if not script.strip():
|
19 |
raise ValueError("No text to convert to speech.")
|
20 |
+
|
21 |
tts = gTTS(text=script, lang='en')
|
22 |
audio_file = 'output.mp3'
|
23 |
tts.save(audio_file)
|
24 |
return audio_file
|
25 |
|
26 |
+
|
27 |
def generate_animation(script):
|
28 |
lines = script.split('\n')
|
29 |
clips = []
|