udayl commited on
Commit
df1a68a
·
1 Parent(s): bfc166e

updated app

Browse files
Files changed (1) hide show
  1. gradio_app.py +19 -14
gradio_app.py CHANGED
@@ -39,7 +39,8 @@ def generate_audio_from_script_with_voices(script, speaker1_voice, speaker2_voic
39
  chosen_voice = voice_map.get(speaker, "af_heart")
40
  print(f"Generating audio for {speaker} with voice '{chosen_voice}'...")
41
 
42
- pipeline = KPipeline(lang_code="a")
 
43
  generator = pipeline(dialogue, voice=chosen_voice)
44
 
45
  segment_audio = []
@@ -152,15 +153,10 @@ def create_gradio_app():
152
  )
153
  speaker2_voice = gr.Dropdown(
154
  choices=["af_nicole", "af_heart", "bf_emma"],
155
- value="af_nicole",
156
  label="Speaker 2 Voice"
157
  )
158
 
159
- provider = gr.Radio(
160
- choices=["openai", "openrouter"],
161
- value="openrouter",
162
- label="API Provider"
163
- )
164
 
165
  with gr.Group():
166
  provider = gr.Radio(
@@ -173,13 +169,14 @@ def create_gradio_app():
173
  label="API Key",
174
  placeholder="Enter your API key here...",
175
  type="password",
176
- class_name="api-key-input"
177
  )
178
 
179
  openrouter_base = gr.Textbox(
180
  label="OpenRouter Base URL (optional)",
181
  placeholder="https://openrouter.ai/api/v1",
182
- visible=False
 
183
  )
184
 
185
  # Show/hide OpenRouter base URL based on provider selection
@@ -207,9 +204,9 @@ def create_gradio_app():
207
  # Examples section
208
  gr.Examples(
209
  examples=[
210
- ["sample.pdf", "af_heart", "af_nicole", "openrouter"],
211
  ],
212
- inputs=[pdf_input, speaker1_voice, speaker2_voice, provider],
213
  outputs=[status_output, audio_output],
214
  fn=process_pdf,
215
  cache_examples=True,
@@ -217,7 +214,14 @@ def create_gradio_app():
217
 
218
  submit_btn.click(
219
  fn=process_pdf,
220
- inputs=[pdf_input, speaker1_voice, speaker2_voice, provider],
 
 
 
 
 
 
 
221
  outputs=[status_output, audio_output],
222
  api_name="generate"
223
  )
@@ -235,9 +239,10 @@ def create_gradio_app():
235
 
236
  if __name__ == "__main__":
237
  demo = create_gradio_app()
238
- demo.queue(concurrency_count=1).launch(
239
  server_name="0.0.0.0",
240
  server_port=7860,
241
  share=True,
242
- debug=True
 
243
  )
 
39
  chosen_voice = voice_map.get(speaker, "af_heart")
40
  print(f"Generating audio for {speaker} with voice '{chosen_voice}'...")
41
 
42
+ # Updated KPipeline initialization with explicit repo_id
43
+ pipeline = KPipeline(lang_code="a", repo_id="hexgrad/Kokoro-82M")
44
  generator = pipeline(dialogue, voice=chosen_voice)
45
 
46
  segment_audio = []
 
153
  )
154
  speaker2_voice = gr.Dropdown(
155
  choices=["af_nicole", "af_heart", "bf_emma"],
156
+ value="bf_emma",
157
  label="Speaker 2 Voice"
158
  )
159
 
 
 
 
 
 
160
 
161
  with gr.Group():
162
  provider = gr.Radio(
 
169
  label="API Key",
170
  placeholder="Enter your API key here...",
171
  type="password",
172
+ elem_classes="api-input"
173
  )
174
 
175
  openrouter_base = gr.Textbox(
176
  label="OpenRouter Base URL (optional)",
177
  placeholder="https://openrouter.ai/api/v1",
178
+ visible=False,
179
+ elem_classes="api-input"
180
  )
181
 
182
  # Show/hide OpenRouter base URL based on provider selection
 
204
  # Examples section
205
  gr.Examples(
206
  examples=[
207
+ ["sample.pdf", "af_heart", "af_nicole", "openrouter", "your-api-key-here", "https://openrouter.ai/api/v1"],
208
  ],
209
+ inputs=[pdf_input, speaker1_voice, speaker2_voice, provider, api_key, openrouter_base],
210
  outputs=[status_output, audio_output],
211
  fn=process_pdf,
212
  cache_examples=True,
 
214
 
215
  submit_btn.click(
216
  fn=process_pdf,
217
+ inputs=[
218
+ pdf_input,
219
+ speaker1_voice,
220
+ speaker2_voice,
221
+ provider,
222
+ api_key,
223
+ openrouter_base
224
+ ],
225
  outputs=[status_output, audio_output],
226
  api_name="generate"
227
  )
 
239
 
240
  if __name__ == "__main__":
241
  demo = create_gradio_app()
242
+ demo.queue().launch(
243
  server_name="0.0.0.0",
244
  server_port=7860,
245
  share=True,
246
+ debug=True,
247
+ pwa=True
248
  )