MichaelChou0806 commited on
Commit
7ecf1a3
·
verified ·
1 Parent(s): b1c58b3

previous ver is available, this ver is to fix mobile browsing

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -7,12 +7,15 @@ from fastapi.responses import JSONResponse
7
  from fastapi.middleware.cors import CORSMiddleware
8
 
9
  # ====== 基本設定 ======
10
- PASSWORD = os.getenv("APP_PASSWORD", "chou")
 
 
 
11
  MAX_SIZE = 25 * 1024 * 1024
12
  client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
13
 
14
  print("===== 🚀 啟動中 =====")
15
- print(f"APP_PASSWORD: {'✅ 已載入' if PASSWORD else '❌ 未載入'}")
16
 
17
  # ====== 工具函數 ======
18
  MIME_EXT = {
@@ -292,13 +295,15 @@ with gr.Blocks(title="Audio Transcription", theme=gr.themes.Soft()) as demo:
292
  password_input = gr.Textbox(
293
  label="Password",
294
  type="password",
295
- placeholder="Enter password"
 
296
  )
297
 
298
  audio_input = gr.File(
299
  label="Audio File",
300
- file_types=["audio", ".mp3", ".m4a", ".wav", ".ogg", ".webm", ".mp4"],
301
- file_count="single"
 
302
  )
303
 
304
  submit_btn = gr.Button(
@@ -321,18 +326,21 @@ with gr.Blocks(title="Audio Transcription", theme=gr.themes.Soft()) as demo:
321
  status_output = gr.Textbox(
322
  label="Status",
323
  interactive=False,
324
- lines=1
 
325
  )
326
 
327
  transcription_output = gr.Textbox(
328
  label="Transcription",
329
  lines=12,
 
330
  show_copy_button=True
331
  )
332
 
333
  summary_output = gr.Textbox(
334
  label="Summary",
335
  lines=6,
 
336
  show_copy_button=True
337
  )
338
 
 
7
  from fastapi.middleware.cors import CORSMiddleware
8
 
9
  # ====== 基本設定 ======
10
+ PASSWORD = os.getenv("APP_PASSWORD") # 從環境變數讀取,不設預設值
11
+ if not PASSWORD:
12
+ raise ValueError("APP_PASSWORD environment variable is not set!")
13
+
14
  MAX_SIZE = 25 * 1024 * 1024
15
  client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
16
 
17
  print("===== 🚀 啟動中 =====")
18
+ print(f"APP_PASSWORD: ✅ 已載入")
19
 
20
  # ====== 工具函數 ======
21
  MIME_EXT = {
 
295
  password_input = gr.Textbox(
296
  label="Password",
297
  type="password",
298
+ placeholder="Enter password",
299
+ max_lines=1
300
  )
301
 
302
  audio_input = gr.File(
303
  label="Audio File",
304
+ file_types=["audio/*", ".mp3", ".m4a", ".wav", ".ogg", ".webm", ".mp4"],
305
+ file_count="single",
306
+ type="filepath"
307
  )
308
 
309
  submit_btn = gr.Button(
 
326
  status_output = gr.Textbox(
327
  label="Status",
328
  interactive=False,
329
+ lines=1,
330
+ max_lines=2
331
  )
332
 
333
  transcription_output = gr.Textbox(
334
  label="Transcription",
335
  lines=12,
336
+ interactive=True,
337
  show_copy_button=True
338
  )
339
 
340
  summary_output = gr.Textbox(
341
  label="Summary",
342
  lines=6,
343
+ interactive=True,
344
  show_copy_button=True
345
  )
346