my-writing-mood / app.py
lifewjola's picture
Create app.py
513a379
raw
history blame
730 Bytes
import streamlit as st
from transformers import pipeline
text_classifier = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
def main():
st.title("Know The Mood of Your Writing")
# Text input area for the user
text = st.text_area("Enter your text:")
if st.button("Go!"):
if text:
analyze_text_tone(text)
else:
st.warning("Please enter some text.")
def analyze_text_tone(text):
classification_result = text_classifier(text)
predicted_label = classification_result[0]['label']
st.subheader("Text Tone Analysis Result:")
st.write(f"Predicted Tone: {predicted_label}")
if __name__ == "__main__":
main()