jonathanagustin commited on
Commit
7b9da97
1 Parent(s): fb7e56c

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +56 -58
app.py CHANGED
@@ -121,7 +121,6 @@ def main():
121
  gr.set_static_paths(paths=[PREVIEW_DIR])
122
 
123
  with gr.Blocks(title="OpenAI - Text to Speech") as demo:
124
- gr.Markdown("# OpenAI Text-to-Speech Demo")
125
  with gr.Row():
126
  with gr.Column(scale=1):
127
  with gr.Group():
@@ -147,66 +146,65 @@ def main():
147
  fn=partial(play_voice_sample, voice=voice),
148
  outputs=preview_audio,
149
  )
150
-
151
- with gr.Column(scale=1):
152
- api_key_input = gr.Textbox(
153
- label="OpenAI API Key",
154
- info="https://platform.openai.com/account/api-keys",
155
- type="password",
156
- placeholder="Enter your OpenAI API Key",
157
- )
158
- model_dropdown = gr.Dropdown(
159
- choices=MODEL_OPTIONS,
160
- label="Model",
161
- value="tts-1",
162
- info="Select tts-1 for speed or tts-1-hd for quality.",
163
- )
164
- voice_dropdown = gr.Dropdown(
165
- choices=VOICE_OPTIONS,
166
- label="Voice Options",
167
- value="echo",
168
- info="The voice to use when generating the audio.",
169
- )
170
- response_format_dropdown = gr.Dropdown(
171
- choices=RESPONSE_FORMAT_OPTIONS,
172
- label="Response Format",
173
- value="mp3",
174
- )
175
- speed_slider = gr.Slider(
176
- minimum=0.25,
177
- maximum=4.0,
178
- step=0.05,
179
- label="Voice Speed",
180
- value=1.0,
181
- )
182
-
183
- with gr.Column(scale=2):
184
- input_textbox = gr.Textbox(
185
- label="Input Text",
186
- lines=10,
187
- placeholder="Type your text here...",
188
  )
189
- # Add a character counter below the input textbox
190
- char_count_text = gr.Markdown("0 / 4096")
191
-
192
- # Function to update the character count
193
- def update_char_count(input_text):
194
- char_count = len(input_text)
195
- return f"**{char_count} / 4096**"
196
-
197
- # Update character count when the user stops typing
198
- input_textbox.change(
199
- fn=update_char_count,
200
- inputs=input_textbox,
201
- outputs=char_count_text,
202
  )
203
-
204
- submit_button = gr.Button(
205
- "Convert Text to Speech",
206
- variant="primary",
 
207
  )
208
- with gr.Column(scale=1):
209
- output_audio = gr.Audio(label="Output Audio")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
  # Define the event handler for the submit button with error handling
212
  def on_submit(
 
121
  gr.set_static_paths(paths=[PREVIEW_DIR])
122
 
123
  with gr.Blocks(title="OpenAI - Text to Speech") as demo:
 
124
  with gr.Row():
125
  with gr.Column(scale=1):
126
  with gr.Group():
 
146
  fn=partial(play_voice_sample, voice=voice),
147
  outputs=preview_audio,
148
  )
149
+ with gr.Column(scale=1):
150
+ api_key_input = gr.Textbox(
151
+ label="OpenAI API Key",
152
+ info="https://platform.openai.com/account/api-keys",
153
+ type="password",
154
+ placeholder="Enter your OpenAI API Key",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  )
156
+ model_dropdown = gr.Dropdown(
157
+ choices=MODEL_OPTIONS,
158
+ label="Model",
159
+ value="tts-1",
160
+ info="Select tts-1 for speed or tts-1-hd for quality.",
 
 
 
 
 
 
 
 
161
  )
162
+ voice_dropdown = gr.Dropdown(
163
+ choices=VOICE_OPTIONS,
164
+ label="Voice Options",
165
+ value="echo",
166
+ info="The voice to use when generating the audio.",
167
  )
168
+ response_format_dropdown = gr.Dropdown(
169
+ choices=RESPONSE_FORMAT_OPTIONS,
170
+ label="Response Format",
171
+ value="mp3",
172
+ )
173
+ speed_slider = gr.Slider(
174
+ minimum=0.25,
175
+ maximum=4.0,
176
+ step=0.05,
177
+ label="Voice Speed",
178
+ value=1.0,
179
+ )
180
+
181
+ with gr.Column(scale=2):
182
+ input_textbox = gr.Textbox(
183
+ label="Input Text",
184
+ lines=10,
185
+ placeholder="Type your text here...",
186
+ )
187
+ # Add a character counter below the input textbox
188
+ char_count_text = gr.Markdown("0 / 4096")
189
+
190
+ # Function to update the character count
191
+ def update_char_count(input_text):
192
+ char_count = len(input_text)
193
+ return f"**{char_count} / 4096**"
194
+
195
+ # Update character count when the user stops typing
196
+ input_textbox.change(
197
+ fn=update_char_count,
198
+ inputs=input_textbox,
199
+ outputs=char_count_text,
200
+ )
201
+
202
+ submit_button = gr.Button(
203
+ "Convert Text to Speech",
204
+ variant="primary",
205
+ )
206
+ with gr.Column(scale=1):
207
+ output_audio = gr.Audio(label="Output Audio")
208
 
209
  # Define the event handler for the submit button with error handling
210
  def on_submit(