Jiangxz01 commited on
Commit
d40bc91
·
verified ·
1 Parent(s): 57d4798

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -180,12 +180,17 @@ async def tts_generate(input_text, speaker1, speaker2):
180
 
181
  async def process_podcast(input_text, language, speaker1, speaker2, api_key):
182
  podcast_script = generate_response(input_text, language, speaker1, speaker2, api_key)
 
 
183
 
184
  try:
185
  podcast_data = json.loads(podcast_script)
186
  podcast_text = ""
187
  for line in podcast_data.get("podcast", []):
188
- speaker = f"speaker{line['speaker']}" if isinstance(line['speaker'], int) else line['speaker']
 
 
 
189
  podcast_text += f"{speaker}:{line['line']}\n"
190
  except json.JSONDecodeError:
191
  podcast_text = "Error: Unable to parse the podcast script."
@@ -253,7 +258,8 @@ body {
253
  margin: 0 !important;
254
  }
255
  .clear-button {
256
- background-color: #FFF5CD !important;
 
257
  padding: 5px !important;
258
  border-radius: 10px !important;
259
  margin: 0 !important;
@@ -281,7 +287,7 @@ body {
281
  with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
282
  gr.Markdown("# 🎙️ 自動生成 Podcast 節目及音檔。系統布署:江信宗。 🎙️", elem_classes="center-aligned")
283
 
284
- input_text = gr.Textbox(label="請輸入 Podcast 話題(建議50~500字之間)", placeholder="輸入 Podcast 話題內容,越詳細劇本越佳......", elem_classes="input-background")
285
 
286
  with gr.Row():
287
  Language = gr.Dropdown(
@@ -331,7 +337,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
331
  elem_classes="sk2-background"
332
  )
333
 
334
- clear_input_text_button = gr.Button("清除輸入文字", scale=1, elem_classes="clear-button")
335
  clear_input_text_button.click(fn=lambda: "", inputs=None, outputs=input_text)
336
 
337
  with gr.Row():
 
180
 
181
  async def process_podcast(input_text, language, speaker1, speaker2, api_key):
182
  podcast_script = generate_response(input_text, language, speaker1, speaker2, api_key)
183
+ speaker1_name = speaker1.split(' - ')[0]
184
+ speaker2_name = speaker2.split(' - ')[0]
185
 
186
  try:
187
  podcast_data = json.loads(podcast_script)
188
  podcast_text = ""
189
  for line in podcast_data.get("podcast", []):
190
+ if isinstance(line['speaker'], int):
191
+ speaker = speaker1_name if line['speaker'] == 1 else speaker2_name
192
+ else:
193
+ speaker = line['speaker']
194
  podcast_text += f"{speaker}:{line['line']}\n"
195
  except json.JSONDecodeError:
196
  podcast_text = "Error: Unable to parse the podcast script."
 
258
  margin: 0 !important;
259
  }
260
  .clear-button {
261
+ color: black !important;
262
+ background-color: #FFCFB3 !important;
263
  padding: 5px !important;
264
  border-radius: 10px !important;
265
  margin: 0 !important;
 
287
  with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
288
  gr.Markdown("# 🎙️ 自動生成 Podcast 節目及音檔。系統布署:江信宗。 🎙️", elem_classes="center-aligned")
289
 
290
+ input_text = gr.Textbox(label="請輸入 Podcast 話題(建議50~500字之間)", placeholder="輸入 Podcast 話題內容越詳細劇本越佳 ......", elem_classes="input-background")
291
 
292
  with gr.Row():
293
  Language = gr.Dropdown(
 
337
  elem_classes="sk2-background"
338
  )
339
 
340
+ clear_input_text_button = gr.Button("清除Podcast話題", scale=1, elem_classes="clear-button")
341
  clear_input_text_button.click(fn=lambda: "", inputs=None, outputs=input_text)
342
 
343
  with gr.Row():