Spaces:
Runtime error
Runtime error
Update spaces.py
Browse files
spaces.py
CHANGED
|
@@ -159,7 +159,7 @@ def create_video_clip(image, duration, target_resolution=(1920, 1080)):
|
|
| 159 |
return clip.set_duration(duration)
|
| 160 |
|
| 161 |
def process_message(args):
|
| 162 |
-
i, message, logo_image, voice_ids = args
|
| 163 |
voice_id = voice_ids[i % len(voice_ids)]
|
| 164 |
|
| 165 |
if i % len(voice_ids) == 0:
|
|
@@ -168,8 +168,8 @@ def process_message(args):
|
|
| 168 |
style = 0
|
| 169 |
else:
|
| 170 |
text_color = "#FFFFFF"
|
| 171 |
-
stability =
|
| 172 |
-
style =
|
| 173 |
|
| 174 |
try:
|
| 175 |
audio_content = generate_speech(message, voice_id, stability=stability, style=style)
|
|
@@ -197,7 +197,7 @@ def process_message(args):
|
|
| 197 |
print(f"Error processing message {i+1}: {e}")
|
| 198 |
return (None, None, None)
|
| 199 |
|
| 200 |
-
def generate_conversation_video(messages, voice_ids, logo_url):
|
| 201 |
logo_image = download_and_convert_svg_to_png(logo_url)
|
| 202 |
if logo_image is None:
|
| 203 |
return None
|
|
@@ -206,7 +206,7 @@ def generate_conversation_video(messages, voice_ids, logo_url):
|
|
| 206 |
audio_clips = []
|
| 207 |
temp_audio_paths = []
|
| 208 |
|
| 209 |
-
args = [(i, message, logo_image, voice_ids) for i, message in enumerate(messages)]
|
| 210 |
max_workers = 5
|
| 211 |
|
| 212 |
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
@@ -259,7 +259,7 @@ def generate_conversation_video(messages, voice_ids, logo_url):
|
|
| 259 |
|
| 260 |
return temp_video_path
|
| 261 |
|
| 262 |
-
def generate_video(description):
|
| 263 |
voice_ids = [
|
| 264 |
"cgSgspJ2msm6clMCkdW9", # First speaker
|
| 265 |
"3Niy6MUaDzcs7Liw7dFs" # Second speaker
|
|
@@ -267,19 +267,35 @@ def generate_video(description):
|
|
| 267 |
logo_url = "https://opencall.ai/images/logo-symbol.svg"
|
| 268 |
|
| 269 |
messages = get_convo_list(description)
|
| 270 |
-
video_path = generate_conversation_video(messages, voice_ids, logo_url)
|
| 271 |
|
| 272 |
return video_path
|
| 273 |
|
| 274 |
# Create Gradio interface
|
| 275 |
iface = gr.Interface(
|
| 276 |
fn=generate_video,
|
| 277 |
-
inputs=
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
outputs=gr.Video(label="Generated Video"),
|
| 284 |
title="AI Conversation Video Generator",
|
| 285 |
description="Generate a video conversation between two speakers based on your description."
|
|
|
|
| 159 |
return clip.set_duration(duration)
|
| 160 |
|
| 161 |
def process_message(args):
|
| 162 |
+
i, message, logo_image, voice_ids, male_stability, male_style = args
|
| 163 |
voice_id = voice_ids[i % len(voice_ids)]
|
| 164 |
|
| 165 |
if i % len(voice_ids) == 0:
|
|
|
|
| 168 |
style = 0
|
| 169 |
else:
|
| 170 |
text_color = "#FFFFFF"
|
| 171 |
+
stability = male_stability
|
| 172 |
+
style = male_style
|
| 173 |
|
| 174 |
try:
|
| 175 |
audio_content = generate_speech(message, voice_id, stability=stability, style=style)
|
|
|
|
| 197 |
print(f"Error processing message {i+1}: {e}")
|
| 198 |
return (None, None, None)
|
| 199 |
|
| 200 |
+
def generate_conversation_video(messages, voice_ids, logo_url, male_stability, male_style):
|
| 201 |
logo_image = download_and_convert_svg_to_png(logo_url)
|
| 202 |
if logo_image is None:
|
| 203 |
return None
|
|
|
|
| 206 |
audio_clips = []
|
| 207 |
temp_audio_paths = []
|
| 208 |
|
| 209 |
+
args = [(i, message, logo_image, voice_ids, male_stability, male_style) for i, message in enumerate(messages)]
|
| 210 |
max_workers = 5
|
| 211 |
|
| 212 |
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
|
|
| 259 |
|
| 260 |
return temp_video_path
|
| 261 |
|
| 262 |
+
def generate_video(description, male_stability=0.65, male_style=0.35):
|
| 263 |
voice_ids = [
|
| 264 |
"cgSgspJ2msm6clMCkdW9", # First speaker
|
| 265 |
"3Niy6MUaDzcs7Liw7dFs" # Second speaker
|
|
|
|
| 267 |
logo_url = "https://opencall.ai/images/logo-symbol.svg"
|
| 268 |
|
| 269 |
messages = get_convo_list(description)
|
| 270 |
+
video_path = generate_conversation_video(messages, voice_ids, logo_url, male_stability, male_style)
|
| 271 |
|
| 272 |
return video_path
|
| 273 |
|
| 274 |
# Create Gradio interface
|
| 275 |
iface = gr.Interface(
|
| 276 |
fn=generate_video,
|
| 277 |
+
inputs=[
|
| 278 |
+
gr.Textbox(
|
| 279 |
+
label="Enter conversation description",
|
| 280 |
+
lines=5,
|
| 281 |
+
placeholder="Describe the conversation you want to generate...",
|
| 282 |
+
info="You can be specific about the number of turns, tone, and content of the conversation"
|
| 283 |
+
),
|
| 284 |
+
gr.Slider(
|
| 285 |
+
minimum=0.1,
|
| 286 |
+
maximum=1.0,
|
| 287 |
+
value=0.65,
|
| 288 |
+
label="Male Voice Stability",
|
| 289 |
+
info="Controls the consistency of the male voice (default: 0.65)"
|
| 290 |
+
),
|
| 291 |
+
gr.Slider(
|
| 292 |
+
minimum=0.1,
|
| 293 |
+
maximum=1.0,
|
| 294 |
+
value=0.35,
|
| 295 |
+
label="Male Voice Style",
|
| 296 |
+
info="Controls the expressiveness of the male voice (default: 0.35)"
|
| 297 |
+
)
|
| 298 |
+
],
|
| 299 |
outputs=gr.Video(label="Generated Video"),
|
| 300 |
title="AI Conversation Video Generator",
|
| 301 |
description="Generate a video conversation between two speakers based on your description."
|