| import streamlit as st |
| from transformers import pipeline |
|
|
| def humanize_text(input_text): |
| """ |
| Humanizes the input text using a Hugging Face language model. |
| |
| Args: |
| input_text: The text to humanize. |
| |
| Returns: |
| The humanized text. |
| """ |
|
|
| |
| model_name = "google/flan-t5-large" |
|
|
| try: |
| humanizer = pipeline("text2text-generation", model=model_name) |
|
|
| |
| prompt = f""" |
| Rewrite the following text to make it sound more human, conversational, and engaging. |
| Use more informal language, add personal touches, and make it less robotic. |
| |
| Original Text: |
| {input_text} |
| |
| Humanized Text: |
| """ |
|
|
| |
| humanized_output = humanizer(prompt, max_length=500, num_beams=5, early_stopping=True)[0]['generated_text'] |
|
|
| return humanized_output |
|
|
| except Exception as e: |
| print(f"Error during text humanization: {e}") |
| return "An error occurred while processing the text." |
|
|
| st.title("Text Humanizer") |
|
|
| input_text = st.text_area("Enter the text you want to humanize:", height=200) |
|
|
| if st.button("Humanize"): |
| if input_text: |
| with st.spinner("Humanizing..."): |
| humanized_text = humanize_text(input_text) |
| st.subheader("Humanized Output:") |
| st.write(humanized_text) |
| else: |
| st.warning("Please enter some text to humanize.") |