log
Browse files- fixed_app.py +5 -5
fixed_app.py
CHANGED
|
@@ -229,18 +229,18 @@ async def transcribe_audio(request: AudioRequest):
|
|
| 229 |
# 执行命令
|
| 230 |
start_time = time.time()
|
| 231 |
logger.info(f"开始执行命令: {' '.join(cmd)}")
|
|
|
|
| 232 |
proc = await asyncio.create_subprocess_exec(
|
| 233 |
*cmd,
|
| 234 |
stdout=asyncio.subprocess.PIPE,
|
| 235 |
stderr=asyncio.subprocess.STDOUT,
|
| 236 |
)
|
| 237 |
-
|
| 238 |
-
# 收集输出
|
| 239 |
stdout, _ = await proc.communicate()
|
| 240 |
-
|
| 241 |
|
| 242 |
# 记录输出日志
|
| 243 |
-
for line in
|
| 244 |
if line.strip():
|
| 245 |
logger.info(f"whisper输出: {line.strip()}")
|
| 246 |
|
|
@@ -265,7 +265,7 @@ async def transcribe_audio(request: AudioRequest):
|
|
| 265 |
# 如果没有JSON输出,使用命令行输出
|
| 266 |
logger.warning(f"未找到JSON输出文件: {json_output_file}")
|
| 267 |
result = {
|
| 268 |
-
"text":
|
| 269 |
"status": "completed" if exit_code == 0 else "failed",
|
| 270 |
"exit_code": exit_code
|
| 271 |
}
|
|
|
|
| 229 |
# 执行命令
|
| 230 |
start_time = time.time()
|
| 231 |
logger.info(f"开始执行命令: {' '.join(cmd)}")
|
| 232 |
+
logger.info("准备创建whisper子进程")
|
| 233 |
proc = await asyncio.create_subprocess_exec(
|
| 234 |
*cmd,
|
| 235 |
stdout=asyncio.subprocess.PIPE,
|
| 236 |
stderr=asyncio.subprocess.STDOUT,
|
| 237 |
)
|
| 238 |
+
logger.info("whisper子进程已创建,开始等待输出")
|
|
|
|
| 239 |
stdout, _ = await proc.communicate()
|
| 240 |
+
logger.info("whisper子进程输出已获取")
|
| 241 |
|
| 242 |
# 记录输出日志
|
| 243 |
+
for line in stdout.decode().splitlines():
|
| 244 |
if line.strip():
|
| 245 |
logger.info(f"whisper输出: {line.strip()}")
|
| 246 |
|
|
|
|
| 265 |
# 如果没有JSON输出,使用命令行输出
|
| 266 |
logger.warning(f"未找到JSON输出文件: {json_output_file}")
|
| 267 |
result = {
|
| 268 |
+
"text": stdout.decode(), # 使用stdout作为文本输出
|
| 269 |
"status": "completed" if exit_code == 0 else "failed",
|
| 270 |
"exit_code": exit_code
|
| 271 |
}
|