Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
# def greet(name):
|
5 |
-
# doc = nlp(name)
|
6 |
-
# #print(doc.to_conll())
|
7 |
-
# return doc.to_conll()
|
8 |
-
|
9 |
-
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
10 |
-
# iface.launch()
|
11 |
-
|
12 |
from gtts import gTTS
|
13 |
import wavio
|
14 |
from io import BytesIO
|
15 |
import base64
|
16 |
|
17 |
-
|
18 |
# Function to play the original text as audio
|
19 |
def text_to_speech(text_to_play):
|
20 |
tts = gTTS(text_to_play, lang='hr') # Assuming the text is in English
|
@@ -29,44 +18,13 @@ def text_to_speech(text_to_play):
|
|
29 |
return audio_player
|
30 |
|
31 |
|
32 |
-
# # Create Gradio interface components
|
33 |
-
# text_input = gr.Textbox(lines=2, label="Enter text to parse")
|
34 |
-
|
35 |
-
# play_audio_button = gr.Button(value="Play Original Audio")
|
36 |
-
|
37 |
-
# # Create a Gradio interface
|
38 |
-
# iface = gr.Interface(
|
39 |
-
# fn=None, # No main function needed
|
40 |
-
# inputs=[text_input,play_audio_button],
|
41 |
-
# outputs="html",
|
42 |
-
# )
|
43 |
-
|
44 |
-
# # Define functions for button clicks
|
45 |
-
|
46 |
-
|
47 |
-
# def play_audio_button_click():
|
48 |
-
# text = text_input.value
|
49 |
-
# play_original_audio(text)
|
50 |
-
|
51 |
-
# # Assign click functions to buttons
|
52 |
-
# play_audio_button.command = play_audio_button_click
|
53 |
-
|
54 |
-
|
55 |
-
# # Launch the Gradio interface
|
56 |
-
# iface.launch()
|
57 |
-
def clear():
|
58 |
-
return None
|
59 |
-
|
60 |
with gr.Blocks() as demo:
|
61 |
html = gr.HTML()
|
62 |
# html.visible = False
|
63 |
-
|
64 |
text = gr.Text()
|
65 |
btn = gr.Button("OK")
|
66 |
btn.click(text_to_speech, inputs=[text], outputs=[html])
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
clear_btn.click(clear, inputs=[], outputs=[audio_input])
|
71 |
-
|
72 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from gtts import gTTS
|
3 |
import wavio
|
4 |
from io import BytesIO
|
5 |
import base64
|
6 |
|
|
|
7 |
# Function to play the original text as audio
|
8 |
def text_to_speech(text_to_play):
|
9 |
tts = gTTS(text_to_play, lang='hr') # Assuming the text is in English
|
|
|
18 |
return audio_player
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
with gr.Blocks() as demo:
|
22 |
html = gr.HTML()
|
23 |
# html.visible = False
|
|
|
24 |
text = gr.Text()
|
25 |
btn = gr.Button("OK")
|
26 |
btn.click(text_to_speech, inputs=[text], outputs=[html])
|
27 |
+
clear = gr.Button("Clear")
|
28 |
+
clear.click(lambda x: gr.update(value=""), None, [text], queue=False)
|
29 |
+
|
|
|
|
|
30 |
demo.launch()
|