Spaces:
Runtime error
Runtime error
from flask import Flask, render_template | |
import gradio as gr | |
from chatbot_ai import chatbot | |
from voice_ai import voice_ai | |
app = Flask(__name__) | |
# Flask Route for Home | |
def index(): | |
return render_template("index.html") | |
# Flask Route for Chatbot | |
def chatbot_page(): | |
return render_template("chatbot.html") | |
# Define Gradio Interfaces | |
def chatbot_interface(input_text): | |
return chatbot(input_text) # Replace with your chatbot logic | |
def voice_ai_interface(audio_input): | |
return voice_ai(audio_input) # Replace with your voice AI logic | |
# Gradio App | |
chatbot_gradio = gr.Interface( | |
fn=chatbot_interface, | |
inputs="text", | |
outputs="text", | |
title="Chatbot AI", | |
description="Ask me anything!" | |
) | |
voice_ai_gradio = gr.Interface( | |
fn=voice_ai_interface, | |
inputs="audio", | |
outputs="text", | |
title="Voice AI", | |
description="Speak and I'll transcribe." | |
) | |
# Enable Gradio Public Links | |
def start_gradio(): | |
chatbot_gradio.launch(share=True, inbrowser=True) | |
voice_ai_gradio.launch(share=True, inbrowser=True) | |
# Main Flask Application | |
if __name__ == "__main__": | |
import threading | |
# Run Gradio in a separate thread | |
threading.Thread(target=start_gradio).start() | |
# Start Flask Server | |
app.run(debug=True) | |