import gradio as gr from transformers import pipeline chatbot = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct", trust_remote_code=True) def respond(message, history): """Simplified response function""" prompt = "" for msg in history: prompt += f"{msg['role'].capitalize()}: {msg['content']}\n" prompt += f"Human: {message}\nAssistant:" response = chatbot(prompt, max_new_tokens=100)[0]['generated_text'] return response.split("Assistant:")[-1].strip() # Simple interface with voice with gr.Blocks() as demo: gr.Markdown("# 🎤 Voice AI Assistant") # Chat interface chat_interface = gr.ChatInterface( fn=respond, title="AI Chat", description="Type or use voice input" ) # Add voice input with gr.Row(): audio = gr.Audio(sources=["microphone"], type="filepath", label="Voice Input") demo.launch()