File size: 720 Bytes
666bf02 |
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 |
from transformers import pipeline
from gtts import gTTS
import gradio as gr
# Load pre-trained summarization model
summarizer = pipeline("summarization", model="t5-small")
# Define the function
def dyslexia_assist(input_text):
# Simplify the text
simplified_text = summarizer(input_text, max_length=50, min_length=10, do_sample=False)[0]["summary_text"]
# Generate audio
tts = gTTS(simplified_text)
tts.save("simplified_audio.mp3")
return simplified_text, "simplified_audio.mp3"
# Create Gradio interface
interface = gr.Interface(
fn=dyslexia_assist,
inputs="text",
outputs=["text", "audio"],
title="Dyslexia Reading Assistant"
)
# Launch the app
interface.launch()
|