jonathanagustin commited on
Commit
1777fa6
1 Parent(s): 5221577

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +15 -21
app.py CHANGED
@@ -80,35 +80,29 @@ def main():
80
  choices=VOICE_OPTIONS, label="Voice Options", value="echo"
81
  )
82
 
83
- # Add voice previews
84
  gr.Markdown("### Voice Previews")
85
  for voice in VOICE_OPTIONS:
86
  audio_url = VOICE_PREVIEWS[voice]
87
- # Fetch the audio data
88
- try:
89
- response = requests.get(audio_url)
90
- response.raise_for_status()
91
- audio_data = response.content
92
- gr.Audio(
93
- value=audio_data,
94
- waveform_options=gr.WaveformOptions(
95
- show_download_button=False,
96
- ),
97
- show_share_button=False,
98
- show_controls=False,
99
- label=f"{voice.capitalize()}",
100
- autoplay=False,
101
- )
102
- except requests.exceptions.RequestException as e:
103
- gr.Markdown(
104
- f"Could not load preview for {voice.capitalize()}: {e}"
105
- )
106
 
107
  with gr.Column(scale=2):
108
  input_textbox = gr.Textbox(
109
  label="Input Text", lines=10, placeholder="Type your text here..."
110
  )
111
- submit_button = gr.Button("Convert Text to Speech", variant="primary")
 
 
112
  with gr.Column(scale=1):
113
  output_audio = gr.Audio(label="Output Audio")
114
 
 
80
  choices=VOICE_OPTIONS, label="Voice Options", value="echo"
81
  )
82
 
83
+ # Add voice previews using HTML for minimal audio interface
84
  gr.Markdown("### Voice Previews")
85
  for voice in VOICE_OPTIONS:
86
  audio_url = VOICE_PREVIEWS[voice]
87
+ # Create an HTML audio player with minimal controls
88
+ html_snippet = f'''
89
+ <div style="margin-bottom: 10px;">
90
+ <p><strong>{voice.capitalize()}</strong></p>
91
+ <audio controls style="width: 100%;">
92
+ <source src="{audio_url}" type="audio/wav">
93
+ Your browser does not support the audio element.
94
+ </audio>
95
+ </div>
96
+ '''
97
+ gr.HTML(html_snippet)
 
 
 
 
 
 
 
 
98
 
99
  with gr.Column(scale=2):
100
  input_textbox = gr.Textbox(
101
  label="Input Text", lines=10, placeholder="Type your text here..."
102
  )
103
+ submit_button = gr.Button(
104
+ "Convert Text to Speech", variant="primary"
105
+ )
106
  with gr.Column(scale=1):
107
  output_audio = gr.Audio(label="Output Audio")
108