Spaces:
Running
Running
optimize cpu usage (?)
Browse files
app.py
CHANGED
|
@@ -324,15 +324,15 @@ def process_audio(input_file, use_cuda=True, use_quantize=True, progress=gr.Prog
|
|
| 324 |
|
| 325 |
quantized_output_file = None
|
| 326 |
|
| 327 |
-
# 设置设备参数
|
| 328 |
-
device_param = "cuda" if use_cuda and cuda_available else "cpu"
|
| 329 |
-
|
| 330 |
start_time = time.time()
|
| 331 |
progress(file_progress_offset, desc="准备转录...")
|
| 332 |
|
| 333 |
# 使用命令行调用transkun
|
| 334 |
progress(file_progress_offset + 0.3 * file_progress_scale, desc="转录中...")
|
| 335 |
-
|
|
|
|
|
|
|
|
|
|
| 336 |
|
| 337 |
# 执行命令
|
| 338 |
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
|
|
| 324 |
|
| 325 |
quantized_output_file = None
|
| 326 |
|
|
|
|
|
|
|
|
|
|
| 327 |
start_time = time.time()
|
| 328 |
progress(file_progress_offset, desc="准备转录...")
|
| 329 |
|
| 330 |
# 使用命令行调用transkun
|
| 331 |
progress(file_progress_offset + 0.3 * file_progress_scale, desc="转录中...")
|
| 332 |
+
if use_cuda and cuda_available:
|
| 333 |
+
cmd = ["transkun", input_file, str(output_file), "--device", "cuda"]
|
| 334 |
+
else:
|
| 335 |
+
cmd = ["transkun", input_file, str(output_file)]
|
| 336 |
|
| 337 |
# 执行命令
|
| 338 |
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|