seawolf2357 commited on
Commit
8f6b527
·
1 Parent(s): 6e56ebe

initial commit

Browse files
Files changed (1) hide show
  1. app.py +20 -43
app.py CHANGED
@@ -1,50 +1,27 @@
1
- from newspaper import Article
2
- from newspaper import Config
3
- from datetime import datetime
4
- import nltk
5
-
6
- nltk.download("punkt")
7
-
8
  import gradio as gr
9
 
 
10
 
11
- def summarize(url):
12
- USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0"
13
- config = Config()
14
- config.browser_user_agent = USER_AGENT
15
- config.request_timeout = 10
16
-
17
- article = Article(url, config=config)
18
- try:
19
- article.download()
20
- article.parse()
21
- article.nlp()
22
- print("==========================", datetime.utcnow(), url, article.summary, sep="\n")
23
- except Exception as e:
24
- return f"Failed to summarize. Error: {e}"
25
- return article.summary
26
-
27
-
28
- sample_url = [
29
- [
30
- "https://www.technologyreview.com/2021/07/22/1029973/deepmind-alphafold-protein-folding-biology-disease-drugs-proteome/"
31
- ],
32
- [
33
- "https://www.technologyreview.com/2021/07/21/1029860/disability-rights-employment-discrimination-ai-hiring/"
34
- ],
35
- [
36
- "https://www.technologyreview.com/2021/07/09/1028140/ai-voice-actors-sound-human/"
37
- ],
38
  ]
39
 
 
 
 
 
 
 
40
 
41
- iface = gr.Interface(
42
- fn=summarize,
43
- inputs=gr.inputs.Textbox(lines=2, label="URL"),
44
- outputs="text",
45
- title="News Summarizer",
46
- theme="huggingface",
47
- description="Fast and simple article summarizer. [Install iOS shortcut](https://www.icloud.com/shortcuts/a7e092bccae34551b24724798f195590) to use from your iPhone",
48
- examples=sample_url,
49
  )
50
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ title = "AI Multi Set"
4
 
5
+ tts_examples = [
6
+ "I love learning machine learning",
7
+ "How do you do?",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ]
9
 
10
+ tts_demo = gr.Interface.load(
11
+ "huggingface.co/spaces/seawolf2357/multi_test",
12
+ title=None,
13
+ examples=tts_examples,
14
+ description="Give me something to say!",
15
+ )
16
 
17
+ stt_demo = gr.Interface.load(
18
+ "huggingface.co/spaces/seawolf2357/PDF-text-extractor",
19
+ title=None,
20
+ inputs="mic",
21
+ description="Let me try to guess what you're saying!",
 
 
 
22
  )
23
+
24
+ demo = gr.TabbedInterface([tts_demo, stt_demo], ["Text-to-speech", "Speech-to-text"])
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()