DeepLearning101 commited on
Commit
7d65fe0
·
verified ·
1 Parent(s): f631c4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -32
app.py CHANGED
@@ -131,44 +131,21 @@ description_html = """
131
  if __name__ == "__main__":
132
  # 配置Gradio接口
133
  interface = gr.Interface(
134
- fn=separate_audio,
135
- inputs=gr.Audio(
136
- type="filepath",
137
- label="請上傳混音音檔 (支援格式: mp3/wav/ogg)",
138
- max_length=180 # 3分鐘限制
139
- ),
140
- outputs=[
141
- gr.Audio(label="語音軌道 1"),
142
- gr.Audio(label="語音軌道 2")
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)
 
131
  if __name__ == "__main__":
132
  # 配置Gradio接口
133
  interface = gr.Interface(
134
+ # ... (保持原有配置不变) ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  )
136
 
137
+ # 统一处理队列(兼容所有版本)
138
+ interface.queue() # 显式启用队列,无需在 launch() 中传递参数
139
+
140
+ # 启动参数(兼容5.x版本)
 
141
  launch_kwargs = {
142
  "server_name": "0.0.0.0",
143
  "server_port": 7860,
144
+ "share": False, # 5.x 中 share 参数仍有效
145
  "debug": False,
146
+ "max_threads": 2,
147
+ # "enable_queue": True # ❌ 移除这个参数
148
  }
149
 
150
+ # 启动接口
 
 
 
 
 
 
 
151
  interface.launch(**launch_kwargs)