Spaces:
PlayHT
/
Running on CPU Upgrade

1littlecoder commited on
Commit
404f122
·
verified ·
1 Parent(s): 750ff0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -19
app.py CHANGED
@@ -34,7 +34,7 @@ def generate_roast(image_path):
34
  model = genai.GenerativeModel(
35
  model_name="gemini-1.5-flash-002",
36
  generation_config=generation_config,
37
- system_instruction="You are a professional satirist and fashion expert. You will be given a profile picture. Your duty is to roast in less than 50 words whatever is given to you in the funniest way possible!",
38
  )
39
 
40
  chat_session = model.start_chat(
@@ -87,30 +87,29 @@ def generate_video(image_path, audio_path):
87
  except Exception as e:
88
  return f"Error generating video: {e}"
89
 
 
 
 
 
 
 
 
90
  # Gradio Interface
91
  with gr.Blocks(theme=theme) as demo:
92
- gr.Markdown("# Image to Text-to-Speech Roasting App")
93
- gr.Markdown("Upload an image, and the AI will roast it, convert the roast to audio, and create a video output.")
94
-
95
  with gr.Row():
96
  image_input = gr.Image(type="filepath", label="Upload Image")
97
 
98
- # Output areas
99
- output_text = gr.Textbox(label="Roast Text")
100
- audio_output = gr.Audio(label="Roast Audio")
101
- video_output = gr.Video(label="Roast Video")
102
-
103
- # Button to generate roast text
104
- roast_button = gr.Button("Generate Roast Text")
105
- roast_button.click(generate_roast, inputs=image_input, outputs=output_text)
106
-
107
- # Button to generate audio from roast text
108
- audio_button = gr.Button("Generate Roast Audio")
109
- audio_button.click(text_to_speech, inputs=output_text, outputs=audio_output)
110
 
111
- # Button to generate video from image and audio
112
- video_button = gr.Button("Generate Roast Video")
113
- video_button.click(generate_video, inputs=[image_input, audio_output], outputs=video_output)
114
 
115
  # Launch the app
116
  demo.launch(debug=True)
 
34
  model = genai.GenerativeModel(
35
  model_name="gemini-1.5-flash-002",
36
  generation_config=generation_config,
37
+ system_instruction="You are a professional satirist and fashion expert. Roast the provided profile picture in less than 50 words.",
38
  )
39
 
40
  chat_session = model.start_chat(
 
87
  except Exception as e:
88
  return f"Error generating video: {e}"
89
 
90
+ # Function to process all steps at once
91
+ def process_roast(image_path):
92
+ roast_text = generate_roast(image_path)
93
+ audio_path = text_to_speech(roast_text)
94
+ video_path = generate_video(image_path, audio_path)
95
+ return roast_text, audio_path, video_path
96
+
97
  # Gradio Interface
98
  with gr.Blocks(theme=theme) as demo:
99
+ gr.Markdown("# Image Roasting App with TTS and Video")
100
+ gr.Markdown("Upload an image, click 'Roast Image', and the AI will roast it, convert the roast to audio, and generate a video.")
101
+
102
  with gr.Row():
103
  image_input = gr.Image(type="filepath", label="Upload Image")
104
 
105
+ with gr.Column():
106
+ output_text = gr.Textbox(label="Roast Text")
107
+ audio_output = gr.Audio(label="Roast Audio")
108
+ video_output = gr.Video(label="Roast Video")
 
 
 
 
 
 
 
 
109
 
110
+ # Single button to handle all actions
111
+ roast_button = gr.Button("Roast Image")
112
+ roast_button.click(process_roast, inputs=image_input, outputs=[output_text, audio_output, video_output])
113
 
114
  # Launch the app
115
  demo.launch(debug=True)