ONEROCKS commited on
Commit
9730c9c
·
verified ·
1 Parent(s): 75426ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -22,12 +22,6 @@ def generate_image(prompt):
22
  except Exception as e:
23
  return f"Error: {e}"
24
 
25
- def generate_and_display(prompt):
26
- image_url = generate_image(prompt)
27
- if isinstance(image_url, str) and image_url.startswith("http"):
28
- return image_url
29
- else:
30
- return None # Or display an error message in another component
31
 
32
 
33
  def synthesize_speech(text):
@@ -314,6 +308,22 @@ def create_chatbot():
314
  return image_url
315
 
316
  generate_btn.click(fn=generate_and_display, inputs=img_prompt, outputs=image_output)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
  return demo
319
 
 
22
  except Exception as e:
23
  return f"Error: {e}"
24
 
 
 
 
 
 
 
25
 
26
 
27
  def synthesize_speech(text):
 
308
  return image_url
309
 
310
  generate_btn.click(fn=generate_and_display, inputs=img_prompt, outputs=image_output)
311
+
312
+ with gr.Tab("Text to Voice"):
313
+ with gr.Column():
314
+ tts_input = gr.Textbox(label="Enter text to synthesize", placeholder="Type something...")
315
+ tts_button = gr.Button("Generate Voice")
316
+ tts_audio_output = gr.Audio(type="filepath", label="Generated Voice")
317
+
318
+ def generate_tts(text):
319
+ if not text.strip():
320
+ return None
321
+ tts = gTTS(text)
322
+ output_path = f"/tmp/{uuid.uuid4().hex}.mp3"
323
+ tts.save(output_path)
324
+ return output_path
325
+
326
+ tts_button.click(fn=generate_tts, inputs=tts_input, outputs=tts_audio_output)
327
 
328
  return demo
329