Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Initialize the spelling correction pipeline with max_new_tokens parameter | |
spelling_correction_pipe = pipeline("text2text-generation", model="Elalimy/english_spelling_correction", max_new_tokens=100) | |
# Define the spelling correction function | |
def correct_spelling(text): | |
# Perform spelling correction | |
corrected_text = spelling_correction_pipe(text)[0]['generated_text'].strip() | |
return corrected_text | |
# Create the Gradio interface | |
iface = gr.Interface( | |
fn=correct_spelling, | |
inputs="text", | |
outputs="text", | |
title="Spelling Correction", | |
description="Enter a text to get the corrected spelling." | |
) | |
# Launch the Gradio app | |
if __name__ == "__main__": | |
iface.launch() | |