DeepLearning101 commited on
Commit
f631c4e
·
verified ·
1 Parent(s): 8a7df0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -143,23 +143,32 @@ if __name__ == "__main__":
143
  ],
144
  title="🎙️ 語音分離 Demo - Deep Learning 101",
145
  description=description_html,
146
- allow_flagging="never",
147
  examples=[
148
  [os.path.join("examples", "sample1.wav")],
149
  [os.path.join("examples", "sample2.mp3")]
150
  ]
151
  )
152
 
153
- # 啟動服務(重要參數調整)
154
- interface.launch(
155
- server_name="0.0.0.0",
156
- server_port=7860,
157
- share=False,
158
- debug=False,
159
- max_threads=2, # 限制並行處理數
160
- # 新版队列系统参数调整
161
- enable_queue=True if gr.__version__ >= '4.0' else None,
162
- # 兼容性参数
163
- _frontend=True,
164
- prevent_thread_lock=True
165
- )
 
 
 
 
 
 
 
 
 
 
143
  ],
144
  title="🎙️ 語音分離 Demo - Deep Learning 101",
145
  description=description_html,
146
+ flagging_mode="never", # 替代 allow_flagging 参数
147
  examples=[
148
  [os.path.join("examples", "sample1.wav")],
149
  [os.path.join("examples", "sample2.mp3")]
150
  ]
151
  )
152
 
153
+ # 版本兼容性处理
154
+ gradio_version = gr.__version__.split('.')
155
+ major_version = int(gradio_version[0])
156
+
157
+ # Gradio 3.x 和 4.x 的启动参数分离
158
+ launch_kwargs = {
159
+ "server_name": "0.0.0.0",
160
+ "server_port": 7860,
161
+ "share": False,
162
+ "debug": False,
163
+ "max_threads": 2
164
+ }
165
+
166
+ if major_version >= 4:
167
+ # Gradio 4.x 需要单独启用队列
168
+ interface.queue()
169
+ launch_kwargs["enable_queue"] = True # 4.x 可能需要这个参数
170
+ else:
171
+ # Gradio 3.x 使用旧参数
172
+ launch_kwargs["enable_queue"] = True
173
+
174
+ interface.launch(**launch_kwargs)