saranbalan commited on
Commit
4f52190
·
verified ·
1 Parent(s): 3fe965b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -38,18 +38,7 @@ 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 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:
@@ -76,6 +65,19 @@ def process_audio(audio_path, image_option, creative_text_option):
76
  if creative_text_option == "Generate Creative Text":
77
  creative_text = generate_creative_text(translation)
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
 
81
  # Create Gradio interface
 
38
  if audio_path is None:
39
  return "Please upload an audio file.", None, None, None
40
 
41
+
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  # Step 1: Transcribe audio
44
  try:
 
65
  if creative_text_option == "Generate Creative Text":
66
  creative_text = generate_creative_text(translation)
67
 
68
+
69
+ # Step 4: Generate image (if selected)
70
+ image = None
71
+ if image_option == "Generate Image":
72
+ try:
73
+ model_id1 = "dreamlike-art/dreamlike-diffusion-1.0"
74
+ pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
75
+ pipe = pipe.to('cpu')
76
+ image = pipe(translation).images[0]
77
+ except Exception as e:
78
+ return tamil_text, translation, creative_text, f"An error occurred during image generation: {str(e)}"
79
+
80
+ return tamil_text, translation, creative_text, image
81
 
82
 
83
  # Create Gradio interface