Jiangxz01 commited on
Commit
b274783
·
verified ·
1 Parent(s): 1a2d948

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -145,7 +145,6 @@ async def tts_generate(input_text, speaker1, speaker2):
145
  try:
146
  podcast_dict = json.loads(input_text)
147
  except json.JSONDecodeError:
148
- # 如果 JSON 解析失敗,嘗試清理輸入
149
  cleaned_input = re.sub(r',\s*}', '}', input_text)
150
  cleaned_input = re.sub(r',\s*]', ']', cleaned_input)
151
  podcast_dict = json.loads(cleaned_input)
@@ -188,8 +187,21 @@ async def process_podcast(input_text, language, speaker1, speaker2, api_key):
188
  audio_file = await tts_generate(podcast_script, speaker1, speaker2)
189
  return podcast_script, audio_file
190
 
191
- with gr.Blocks() as iface:
192
- gr.Markdown("# 🎙️ Generated Podcast Audio. Deployed by 江信宗")
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  input_text = gr.Textbox(label="請輸入 Podcast 話題(建議50~500字之間)", placeholder="輸入 Podcast 話題簡易內容......")
195
 
@@ -243,12 +255,11 @@ with gr.Blocks() as iface:
243
  )
244
 
245
  with gr.Row():
246
- generate_button = gr.Button("生成", scale=2)
247
  api_key = gr.Textbox(label="API Key", type="password", placeholder="API authentication key for large language models", scale=1)
248
 
249
- podcast_script = gr.Textbox(label="生成的結果")
250
  audio_output = gr.Audio(label="生成的音頻")
251
-
252
  generate_button.click(fn=process_podcast, inputs=[input_text, Language, Speaker_1, Speaker_2, api_key], outputs=[podcast_script, audio_output])
253
 
254
  if __name__ == "__main__":
 
145
  try:
146
  podcast_dict = json.loads(input_text)
147
  except json.JSONDecodeError:
 
148
  cleaned_input = re.sub(r',\s*}', '}', input_text)
149
  cleaned_input = re.sub(r',\s*]', ']', cleaned_input)
150
  podcast_dict = json.loads(cleaned_input)
 
187
  audio_file = await tts_generate(podcast_script, speaker1, speaker2)
188
  return podcast_script, audio_file
189
 
190
+ custom_css = """
191
+ .gen-button {
192
+ border-radius: 10px !important;
193
+ background-color: #ff4081 !important;
194
+ }
195
+ .gen-button:hover {
196
+ background-color: #f50057 !important;
197
+ }
198
+ .center-aligned {
199
+ text-align: center !important;
200
+ }
201
+ """
202
+
203
+ with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
204
+ gr.Markdown("# 🎙️ 自動生成 Podcast 節目及音檔。系統布署:江信宗。 🎙️", elem_classes="center-aligned")
205
 
206
  input_text = gr.Textbox(label="請輸入 Podcast 話題(建議50~500字之間)", placeholder="輸入 Podcast 話題簡易內容......")
207
 
 
255
  )
256
 
257
  with gr.Row():
258
+ generate_button = gr.Button("生成", scale=2, elem_classes="gen-button")
259
  api_key = gr.Textbox(label="API Key", type="password", placeholder="API authentication key for large language models", scale=1)
260
 
 
261
  audio_output = gr.Audio(label="生成的音頻")
262
+ podcast_script = gr.Textbox(label="生成的結果")
263
  generate_button.click(fn=process_podcast, inputs=[input_text, Language, Speaker_1, Speaker_2, api_key], outputs=[podcast_script, audio_output])
264
 
265
  if __name__ == "__main__":