Jayahae commited on
Commit
867646c
1 Parent(s): 7e279b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,12 +1,11 @@
1
- # Import necessary libraries
2
  import gradio as gr
3
  from gtts import gTTS
4
 
5
  # Define the text-to-speech function
6
- def text_to_speech(text):
7
- tts = gTTS(text)
8
  tts.save("output.mp3")
9
- return "output.mp3"
10
 
11
  # Predefined sentences
12
  sentences = [
@@ -33,13 +32,13 @@ sentences = [
33
  "He maintained the tradition of the lighthouse while integrating modern technology responsibly, ensuring that the lighthouse continued to be a beacon of safety and a symbol of the town’s enduring spirit.",
34
  "The story of the lighthouse keeper’s lantern became a cherished tale, reminding everyone that sometimes, the simplest solutions are the most effective in times of need.",
35
  "It taught the town the value of wisdom, experience, and the importance of blending the old with the new to navigate the future safely."
36
- ]
37
 
38
  # Create the Gradio interface
39
  interface = gr.Interface(
40
  fn=text_to_speech,
41
  inputs=gr.Dropdown(choices=sentences, label="Select a sentence"),
42
- outputs=gr.Audio(type="filepath"),
43
  title="Text-to-Speech App",
44
  description="Select a sentence and hear it read aloud using Google Text-to-Speech."
45
  )
 
 
1
  import gradio as gr
2
  from gtts import gTTS
3
 
4
  # Define the text-to-speech function
5
+ def text_to_speech(sentence):
6
+ tts = gTTS(sentence)
7
  tts.save("output.mp3")
8
+ return sentence, "output.mp3"
9
 
10
  # Predefined sentences
11
  sentences = [
 
32
  "He maintained the tradition of the lighthouse while integrating modern technology responsibly, ensuring that the lighthouse continued to be a beacon of safety and a symbol of the town’s enduring spirit.",
33
  "The story of the lighthouse keeper’s lantern became a cherished tale, reminding everyone that sometimes, the simplest solutions are the most effective in times of need.",
34
  "It taught the town the value of wisdom, experience, and the importance of blending the old with the new to navigate the future safely."
35
+ ]
36
 
37
  # Create the Gradio interface
38
  interface = gr.Interface(
39
  fn=text_to_speech,
40
  inputs=gr.Dropdown(choices=sentences, label="Select a sentence"),
41
+ outputs=[gr.Textbox(label="Selected Sentence"), gr.Audio(type="filepath")],
42
  title="Text-to-Speech App",
43
  description="Select a sentence and hear it read aloud using Google Text-to-Speech."
44
  )