charantejapolavarapu's picture
Update app.py
2920921 verified
import gradio as gr
def detect_lie(text):
if not text.strip():
return "⚠️ Please enter a statement."
text_lower = text.lower()
words = text.split()
result = "✅ Truthful"
confidence = 90
explanation = "The statement appears clear and neutral."
color = "#22c55e"
if len(words) > 25:
result = "⚠️ Suspicious"
confidence = 65
explanation = "Too many details may indicate over-explanation."
color = "#f59e0b"
elif "honestly" in text_lower or "trust me" in text_lower:
result = "⚠️ Suspicious"
confidence = 70
explanation = "Over-justification phrases detected."
color = "#f59e0b"
elif any(word in text_lower for word in ["never", "no", "not", "nothing"]):
result = "❌ Likely Lie"
confidence = 80
explanation = "Negative wording may indicate denial or deception."
color = "#ef4444"
return f"""
<div style="background:{color}; padding:15px; border-radius:10px; color:white;">
<h2>{result}</h2>
<p><b>Confidence:</b> {confidence}%</p>
<p><b>Explanation:</b> {explanation}</p>
</div>
"""
demo = gr.Interface(
fn=detect_lie,
inputs=gr.Textbox(lines=4, placeholder="Enter your statement..."),
outputs=gr.HTML(),
title="🕵️ AI Lie Detector",
description="Detect whether a statement is truthful, suspicious, or a lie."
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)