Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -168,49 +168,27 @@ rtc_configuration = {
|
|
168 |
"iceCandidatePoolSize": 10
|
169 |
}
|
170 |
|
171 |
-
# Create
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
mode="send-receive",
|
190 |
-
handler=ReplyOnPause(response, input_sample_rate=16000),
|
191 |
-
additional_outputs_handler=lambda a, b: b,
|
192 |
-
additional_inputs=[chatbot],
|
193 |
-
additional_outputs=[chatbot],
|
194 |
-
rtc_configuration=rtc_configuration,
|
195 |
-
concurrency_limit=5 if get_space() else None,
|
196 |
-
time_limit=90 if get_space() else None
|
197 |
-
)
|
198 |
-
|
199 |
-
# This event will add the Stream component after the UI loads
|
200 |
-
demo.load(lambda: None, None, None, _js=f"""
|
201 |
-
() => {{
|
202 |
-
setTimeout(() => {{
|
203 |
-
document.querySelector(".loading").style.display = "none";
|
204 |
-
}}, 2000);
|
205 |
-
}}
|
206 |
-
""")
|
207 |
|
208 |
# Launch the app
|
209 |
-
if __name__ == "__main__"
|
210 |
# Local development
|
211 |
os.environ["GRADIO_SSR_MODE"] = "false"
|
212 |
demo.launch(server_port=7860)
|
213 |
-
else:
|
214 |
-
# Hugging Face Spaces
|
215 |
-
# Need to explicitly call launch for Spaces to pick up the app
|
216 |
-
demo.launch()
|
|
|
168 |
"iceCandidatePoolSize": 10
|
169 |
}
|
170 |
|
171 |
+
# Create the Stream component outside of any Blocks context
|
172 |
+
chatbot = gr.Chatbot(type="messages", visible=False) # Will be used for state only
|
173 |
+
|
174 |
+
stream = Stream(
|
175 |
+
modality="audio",
|
176 |
+
mode="send-receive",
|
177 |
+
handler=ReplyOnPause(response, input_sample_rate=16000),
|
178 |
+
additional_outputs_handler=lambda a, b: b,
|
179 |
+
additional_inputs=[chatbot],
|
180 |
+
additional_outputs=[chatbot],
|
181 |
+
rtc_configuration=rtc_configuration,
|
182 |
+
concurrency_limit=5 if get_space() else None,
|
183 |
+
time_limit=90 if get_space() else None,
|
184 |
+
ui_args={"title": "LLM Voice Chat (Powered by DeepSeek & ElevenLabs)"}
|
185 |
+
)
|
186 |
+
|
187 |
+
# Create a basic Gradio interface
|
188 |
+
demo = stream.ui
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
# Launch the app
|
191 |
+
if __name__ == "__main__":
|
192 |
# Local development
|
193 |
os.environ["GRADIO_SSR_MODE"] = "false"
|
194 |
demo.launch(server_port=7860)
|
|
|
|
|
|
|
|