forked from Chando0185/Emial_Spam_Classification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspamDetector.py
37 lines (32 loc) · 1000 Bytes
/
spamDetector.py
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
import streamlit as st
import pickle
from sklearn.feature_extraction.text import CountVectorizer
import numpy as np
from win32com.client import Dispatch
def speak(text):
speak=Dispatch(("SAPI.SpVoice"))
speak.Speak(text)
model = pickle.load(open('spam.pkl','rb'))
cv=pickle.load(open('vectorizer.pkl','rb'))
def main():
st.title("Email Spam Classification Application")
st.write("Build with Streamlit & Python")
activites=["Classification","About"]
choices=st.sidebar.selectbox("Select Activities",activites)
if choices=="Classification":
st.subheader("Classification")
msg=st.text_input("Enter a text")
if st.button("Process"):
print(msg)
print(type(msg))
data=[msg]
print(data)
vec=cv.transform(data).toarray()
result=model.predict(vec)
if result[0]==0:
st.success("This is Not A Spam Email")
speak("This is Not A Spam Email")
else:
st.error("This is A Spam Email")
speak("This is A Spam Email")
main()