rafaa commited on
Commit
1710d3b
·
verified ·
1 Parent(s): 84c1638

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -26
app.py CHANGED
@@ -128,29 +128,25 @@ def generate(
128
  # Return None if the TTS is not enabled or the password is incorrect
129
  return None
130
 
131
- # Create a gr.Blocks instance
132
- with gr.Blocks(outputs=gr.Audio(label="Audio")) as demo: # Add the gr.Audio component to the outputs parameter
133
- # Create a gr.Column block with scale=1
134
- with gr.Column(scale=1):
135
- # Add the chatbot and the additional inputs
136
- mychatbot = gr.Chatbot(
137
- avatar_images=["./user.png", "./stella.jpg"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True
138
- )
139
- checkbox = gr.Checkbox(label="Enable TTS")
140
- passwordInput = gr.Textbox(label="TTS Password", type="password")
141
- demo = gr.ChatInterface(
142
- fn=generate, # Replace with your actual generate function
143
- chatbot=mychatbot,
144
- title="Stella 🌸",
145
- retry_btn=None,
146
- undo_btn=None,
147
- additional_inputs=[checkbox, passwordInput],
148
- # Remove the outputs parameter from the ChatInterface
149
- )
150
- # Create another gr.Column block with scale=1
151
- with gr.Column(scale=1):
152
- # Add some empty space
153
- pass
154
-
155
- # Launch the demo
156
- demo.queue().launch(show_api=False)
 
128
  # Return None if the TTS is not enabled or the password is incorrect
129
  return None
130
 
131
+ iface = gr.Blocks()
132
+
133
+ with iface.container():
134
+ checkbox = gr.Checkbox(label="Enable TTS")
135
+ passwordInput = gr.Textbox(label="TTS Password", type="password")
136
+
137
+ chat = gr.ChatInterface(
138
+ fn=generate,
139
+ chatbot=mychatbot,
140
+ title="Stella ",
141
+ retry_btn=None,
142
+ undo_btn=None,
143
+ additional_inputs=[checkbox, passwordInput],
144
+ )
145
+
146
+ hidden_audio_output = gr.Textbox(label="Audio Output", visible=False)
147
+ audio_player = gr.Audio(source="Audio Output")
148
+
149
+ # Connect the hidden Textbox to the Audio component
150
+ hidden_audio_output.link(audio_player, source="file")
151
+
152
+ iface.launch(show_api=False)