Spaces:
Sleeping
Sleeping
Download app.py from 13ze/anon-video-chat: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/13ze/anon-video-chat/resolve/main/app.py
- Command line
-
hf download hf://spaces/13ze/anon-video-chat/app.py
-
curl -L -o app.py https://huggingface.co/spaces/13ze/anon-video-chat/resolve/main/app.py
1.33 kB
| import gradio as gr | |
| import time | |
| # Armazena as mensagens do chat (simples, não persistente) | |
| messages = [] | |
| def chat(message): | |
| timestamp = time.strftime('%H:%M:%S') | |
| messages.append(f"[{timestamp}] Anônimo: {message}") | |
| return "\n".join(messages) | |
| # Interface Gradio | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 🎥 Chat Anônimo de Texto e Vídeo") | |
| with gr.Row(): | |
| with gr.Column(): | |
| chat_output = gr.Textbox(label="Chat ao vivo:", interactive=False, lines=10) | |
| chat_input = gr.Textbox(label="Digite sua mensagem:", placeholder="Fale algo...") | |
| chat_input.submit(chat, chat_input, chat_output) | |
| with gr.Column(): | |
| gr.Markdown("Clique no botão abaixo para iniciar sua câmera") | |
| webcam_html = """ | |
| <video id='webcam' autoplay playsinline style='width: 100%;'></video> | |
| <button onclick='startWebcam()'>Iniciar câmera</button> | |
| <script> | |
| async function startWebcam() { | |
| const stream = await navigator.mediaDevices.getUserMedia({ video: true }); | |
| const video = document.getElementById('webcam'); | |
| video.srcObject = stream; | |
| } | |
| </script> | |
| """ | |
| gr.HTML(webcam_html) | |
| demo.launch(share=True) | |