Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from transformers import pipeline
|
|
3 |
from gtts import gTTS
|
4 |
import tempfile
|
5 |
|
6 |
-
# Load
|
7 |
sentiment_model = pipeline("sentiment-analysis")
|
8 |
summarizer_model = pipeline("summarization")
|
9 |
|
@@ -26,27 +26,29 @@ def text_to_speech(text):
|
|
26 |
tts.save(fp.name)
|
27 |
return fp.name
|
28 |
|
29 |
-
#
|
30 |
with gr.Blocks() as demo:
|
31 |
gr.Markdown("## π Homework - Tuwaiq Academy")
|
32 |
|
33 |
-
with gr.
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
|
52 |
demo.launch()
|
|
|
3 |
from gtts import gTTS
|
4 |
import tempfile
|
5 |
|
6 |
+
# Load Hugging Face pipelines
|
7 |
sentiment_model = pipeline("sentiment-analysis")
|
8 |
summarizer_model = pipeline("summarization")
|
9 |
|
|
|
26 |
tts.save(fp.name)
|
27 |
return fp.name
|
28 |
|
29 |
+
# Gradio app with separate tabs/pages
|
30 |
with gr.Blocks() as demo:
|
31 |
gr.Markdown("## π Homework - Tuwaiq Academy")
|
32 |
|
33 |
+
with gr.Tab("π Sentiment Analysis"):
|
34 |
+
gr.Markdown("### Analyze the sentiment of your text")
|
35 |
+
input_sent = gr.Textbox(label="Enter your text", lines=6, placeholder="Type something...")
|
36 |
+
output_sent = gr.Textbox(label="Sentiment Result")
|
37 |
+
btn_sent = gr.Button("Analyze")
|
38 |
+
btn_sent.click(analyze_sentiment, inputs=input_sent, outputs=output_sent)
|
39 |
+
|
40 |
+
with gr.Tab("π Summarization"):
|
41 |
+
gr.Markdown("### Summarize your text")
|
42 |
+
input_sum = gr.Textbox(label="Enter your text", lines=6, placeholder="Paste a paragraph...")
|
43 |
+
output_sum = gr.Textbox(label="Summary")
|
44 |
+
btn_sum = gr.Button("Summarize")
|
45 |
+
btn_sum.click(summarize_text, inputs=input_sum, outputs=output_sum)
|
46 |
+
|
47 |
+
with gr.Tab("π Text to Speech"):
|
48 |
+
gr.Markdown("### Convert text to speech")
|
49 |
+
input_tts = gr.Textbox(label="Enter your text", lines=6, placeholder="Text for audio...")
|
50 |
+
output_audio = gr.Audio(label="Speech Output", type="filepath")
|
51 |
+
btn_tts = gr.Button("Convert")
|
52 |
+
btn_tts.click(text_to_speech, inputs=input_tts, outputs=output_audio)
|
53 |
|
54 |
demo.launch()
|