Test
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from gtts import gTTS
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Load pre-trained summarization model
|
6 |
+
summarizer = pipeline("summarization", model="t5-small")
|
7 |
+
|
8 |
+
# Define the function
|
9 |
+
def dyslexia_assist(input_text):
|
10 |
+
# Simplify the text
|
11 |
+
simplified_text = summarizer(input_text, max_length=50, min_length=10, do_sample=False)[0]["summary_text"]
|
12 |
+
|
13 |
+
# Generate audio
|
14 |
+
tts = gTTS(simplified_text)
|
15 |
+
tts.save("simplified_audio.mp3")
|
16 |
+
|
17 |
+
return simplified_text, "simplified_audio.mp3"
|
18 |
+
|
19 |
+
# Create Gradio interface
|
20 |
+
interface = gr.Interface(
|
21 |
+
fn=dyslexia_assist,
|
22 |
+
inputs="text",
|
23 |
+
outputs=["text", "audio"],
|
24 |
+
title="Dyslexia Reading Assistant"
|
25 |
+
)
|
26 |
+
|
27 |
+
# Launch the app
|
28 |
+
interface.launch()
|