Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,6 +38,19 @@ def process_audio(audio_path, image_option, creative_text_option):
|
|
38 |
if audio_path is None:
|
39 |
return "Please upload an audio file.", None, None, None
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Step 1: Transcribe audio
|
42 |
try:
|
43 |
with open(audio_path, "rb") as file:
|
@@ -63,18 +76,7 @@ def process_audio(audio_path, image_option, creative_text_option):
|
|
63 |
if creative_text_option == "Generate Creative Text":
|
64 |
creative_text = generate_creative_text(translation)
|
65 |
|
66 |
-
|
67 |
-
image = None
|
68 |
-
if image_option == "Generate Image":
|
69 |
-
try:
|
70 |
-
model_id1 = "dreamlike-art/dreamlike-diffusion-1.0"
|
71 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
|
72 |
-
pipe = pipe.to('cpu')
|
73 |
-
image = pipe(translation).images[0]
|
74 |
-
except Exception as e:
|
75 |
-
return tamil_text, translation, creative_text, f"An error occurred during image generation: {str(e)}"
|
76 |
-
|
77 |
-
return tamil_text, translation, creative_text, image
|
78 |
|
79 |
# Create Gradio interface
|
80 |
with gr.Blocks(theme=gr.themes.Base()) as iface:
|
|
|
38 |
if audio_path is None:
|
39 |
return "Please upload an audio file.", None, None, None
|
40 |
|
41 |
+
# Step 4: Generate image (if selected)
|
42 |
+
image = None
|
43 |
+
if image_option == "Generate Image":
|
44 |
+
try:
|
45 |
+
model_id1 = "dreamlike-art/dreamlike-diffusion-1.0"
|
46 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
|
47 |
+
pipe = pipe.to('cpu')
|
48 |
+
image = pipe(translation).images[0]
|
49 |
+
except Exception as e:
|
50 |
+
return tamil_text, translation, creative_text, f"An error occurred during image generation: {str(e)}"
|
51 |
+
|
52 |
+
return tamil_text, translation, creative_text, image
|
53 |
+
|
54 |
# Step 1: Transcribe audio
|
55 |
try:
|
56 |
with open(audio_path, "rb") as file:
|
|
|
76 |
if creative_text_option == "Generate Creative Text":
|
77 |
creative_text = generate_creative_text(translation)
|
78 |
|
79 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
# Create Gradio interface
|
82 |
with gr.Blocks(theme=gr.themes.Base()) as iface:
|