Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
# app.py
|
2 |
# =============
|
3 |
-
# This is a complete app.py file for a web scraping and text-to-speech app using gTTS, BeautifulSoup, and Gradio.
|
4 |
|
5 |
import requests
|
6 |
from bs4 import BeautifulSoup
|
7 |
from gtts import gTTS
|
8 |
import os
|
9 |
import gradio as gr
|
|
|
10 |
|
11 |
def get_text_from_webpage(url):
|
12 |
response = requests.get(url)
|
@@ -21,7 +22,8 @@ def text_to_speech(text, lang='en'):
|
|
21 |
|
22 |
def process_url(url):
|
23 |
text = get_text_from_webpage(url)
|
24 |
-
|
|
|
25 |
return audio_file, text
|
26 |
|
27 |
# Create Gradio interface
|
@@ -41,7 +43,8 @@ if __name__ == "__main__":
|
|
41 |
# - requests
|
42 |
# - beautifulsoup4
|
43 |
# - gtts
|
|
|
44 |
# - gradio
|
45 |
#
|
46 |
# You can install these dependencies using pip:
|
47 |
-
# pip install requests beautifulsoup4 gtts gradio
|
|
|
1 |
# app.py
|
2 |
# =============
|
3 |
+
# This is a complete app.py file for a web scraping and text-to-speech app using gTTS, BeautifulSoup, langdetect, and Gradio.
|
4 |
|
5 |
import requests
|
6 |
from bs4 import BeautifulSoup
|
7 |
from gtts import gTTS
|
8 |
import os
|
9 |
import gradio as gr
|
10 |
+
from langdetect import detect
|
11 |
|
12 |
def get_text_from_webpage(url):
|
13 |
response = requests.get(url)
|
|
|
22 |
|
23 |
def process_url(url):
|
24 |
text = get_text_from_webpage(url)
|
25 |
+
lang = detect(text)
|
26 |
+
audio_file = text_to_speech(text, lang)
|
27 |
return audio_file, text
|
28 |
|
29 |
# Create Gradio interface
|
|
|
43 |
# - requests
|
44 |
# - beautifulsoup4
|
45 |
# - gtts
|
46 |
+
# - langdetect
|
47 |
# - gradio
|
48 |
#
|
49 |
# You can install these dependencies using pip:
|
50 |
+
# pip install requests beautifulsoup4 gtts langdetect gradio
|