thak123 commited on
Commit
a7c8bb7
·
1 Parent(s): cebd835

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -16,7 +16,7 @@ import base64
16
 
17
 
18
  # Function to play the original text as audio
19
- def play_original_audio(text_to_play):
20
  tts = gTTS(text_to_play, lang='hr') # Assuming the text is in English
21
  tts.save('original_audio.mp3')
22
 
@@ -29,35 +29,38 @@ def play_original_audio(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
-
58
 
 
 
59
 
60
 
 
 
61
 
 
 
 
62
 
 
 
 
63
 
 
 
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
21
  tts.save('original_audio.mp3')
22
 
 
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
 
58
+ with gr.Blocks() as demo:
59
+ html = gr.HTML()
60
+ # html.visible = False
61
 
62
+ text = gr.Text()
63
+ btn = gr.Button("OK")
64
+ btn.click(text_to_speech, inputs=[text], outputs=[html])
65
 
66
+ demo.launch()