Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,26 +15,24 @@ def get_text_from_webpage(url):
|
|
15 |
text = soup.get_text()
|
16 |
return text
|
17 |
|
18 |
-
def text_to_speech(text, lang='en'
|
19 |
-
tts = gTTS(text=text, lang=lang
|
20 |
tts.save("output.mp3")
|
21 |
return "output.mp3"
|
22 |
|
23 |
-
def process_url(url
|
24 |
text = get_text_from_webpage(url)
|
25 |
-
|
|
|
26 |
return audio_file, text
|
27 |
|
28 |
# Create Gradio interface
|
29 |
with gr.Blocks() as demo:
|
30 |
url_input = gr.Textbox(lines=1, placeholder="Enter the URL of the webpage...")
|
31 |
-
lang_input = gr.Dropdown(choices=["en", "fr", "de", "es", "it", "ja", "ko", "zh-CN", "zh-TW", "ru"], label="Language", value="en")
|
32 |
-
slow_checkbox = gr.Checkbox(label="Slow Speed")
|
33 |
-
tld_input = gr.Dropdown(choices=["com", "co.uk", "fr", "de", "es", "it", "co.jp", "co.kr", "com.cn", "com.tw"], label="Accent", value="com")
|
34 |
audio_output = gr.Audio(label="Generated Speech")
|
35 |
text_output = gr.Textbox(lines=10, label="Extracted Text")
|
36 |
greet_btn = gr.Button("Submit")
|
37 |
-
greet_btn.click(fn=process_url, inputs=
|
38 |
|
39 |
if __name__ == "__main__":
|
40 |
demo.launch()
|
|
|
15 |
text = soup.get_text()
|
16 |
return text
|
17 |
|
18 |
+
def text_to_speech(text, lang='en'):
|
19 |
+
tts = gTTS(text=text, lang=lang)
|
20 |
tts.save("output.mp3")
|
21 |
return "output.mp3"
|
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
|
30 |
with gr.Blocks() as demo:
|
31 |
url_input = gr.Textbox(lines=1, placeholder="Enter the URL of the webpage...")
|
|
|
|
|
|
|
32 |
audio_output = gr.Audio(label="Generated Speech")
|
33 |
text_output = gr.Textbox(lines=10, label="Extracted Text")
|
34 |
greet_btn = gr.Button("Submit")
|
35 |
+
greet_btn.click(fn=process_url, inputs=url_input, outputs=[audio_output, text_output])
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
demo.launch()
|