Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
tts_title = "Text to Speech Translation"
|
5 |
tts_examples = [
|
6 |
"I love learning machine learning",
|
7 |
"How do you do?",
|
8 |
]
|
|
|
9 |
tts_demo = gr.Interface.load(
|
10 |
"huggingface/facebook/fastspeech2-en-ljspeech",
|
11 |
title=tts_title,
|
@@ -13,21 +23,8 @@ tts_demo = gr.Interface.load(
|
|
13 |
description="Give me something to say!",
|
14 |
)
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
sentiment_examples = [
|
19 |
-
"I love learning machine learning",
|
20 |
-
"How do you do?",
|
21 |
-
]
|
22 |
-
sentiment_demo = gr.Interface.load(
|
23 |
-
"huggingface/nlp-sentiment-analysis",
|
24 |
-
title=sentiment_title,
|
25 |
-
examples=sentiment_examples,
|
26 |
-
description="Analyze the sentiment of the text!",
|
27 |
-
)
|
28 |
-
|
29 |
-
# Tabbed Interface
|
30 |
-
demo = gr.TabbedInterface([tts_demo, sentiment_demo], ["Text to Speech", "Sentiment Analysis"])
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Sentiment Analysis
|
5 |
+
sentiment = pipeline("sentiment-analysis")
|
6 |
+
|
7 |
+
def get_sentiment(input_text):
|
8 |
+
return sentiment(input_text)
|
9 |
+
|
10 |
+
iface_sentiment = gr.Interface(get_sentiment, inputs="text", outputs="text", title="Sentiment Analysis")
|
11 |
+
|
12 |
+
# Text to Speech Translation
|
13 |
tts_title = "Text to Speech Translation"
|
14 |
tts_examples = [
|
15 |
"I love learning machine learning",
|
16 |
"How do you do?",
|
17 |
]
|
18 |
+
|
19 |
tts_demo = gr.Interface.load(
|
20 |
"huggingface/facebook/fastspeech2-en-ljspeech",
|
21 |
title=tts_title,
|
|
|
23 |
description="Give me something to say!",
|
24 |
)
|
25 |
|
26 |
+
# Launching both interfaces
|
27 |
+
demo = gr.TabbedInterface([iface_sentiment, tts_demo], ["Sentiment Analysis", "Text to Speech"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
if __name__ == "__main__":
|
30 |
demo.launch()
|