Vishaltiwari2019 commited on
Commit
a1855ac
·
verified ·
1 Parent(s): 1188681

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -17
app.py CHANGED
@@ -1,22 +1,33 @@
1
- from transformers import pipeline
2
-
3
  import gradio as gr
4
 
5
- tts = pipeline("text-to-speech", "facebook/wav2vec2-base-960h")
6
-
7
- def text_to_speech(text):
8
- audio = tts(text)[0]["audio"]
9
- return audio
10
-
11
- demo = gr.Blocks()
12
-
13
- with demo:
14
- text_input = gr.Textbox()
15
- audio_output = gr.Audio()
16
-
17
- b1 = gr.Button("Convert to Speech")
18
-
19
- b1.click(text_to_speech, inputs=text_input, outputs=audio_output)
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  if __name__ == "__main__":
22
  demo.launch()
 
 
 
1
  import gradio as gr
2
 
3
+ # Text to Speech Interface
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,
12
+ examples=tts_examples,
13
+ description="Give me something to say!",
14
+ )
15
+
16
+ # Sentiment Analysis Interface
17
+ sentiment_title = "Sentiment Analysis"
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()