File size: 1,524 Bytes
468c546 2920921 3736cae 468c546 6a50145 3736cae 2920921 6a50145 3736cae 6a50145 3736cae 6a50145 2920921 6a50145 3736cae 6a50145 3736cae 6a50145 2920921 6a50145 3736cae 2920921 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 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) |