|
|
|
@ -80,7 +80,7 @@ class ASRProvider(ASRProviderBase):
|
|
|
|
|
# 保存音频文件
|
|
|
|
|
start_time = time.time()
|
|
|
|
|
file_path = self.save_audio_to_file(opus_data, session_id)
|
|
|
|
|
logger.bind(tag=TAG).debug(f"音频文件保存耗时: {time.time() - start_time:.3f}s | 路径: {file_path}")
|
|
|
|
|
logger.bind(tag=TAG).info(f"音频文件保存耗时: {time.time() - start_time:.3f}s | 路径: {file_path}")
|
|
|
|
|
|
|
|
|
|
# 语音识别
|
|
|
|
|
start_time = time.time()
|
|
|
|
@ -92,7 +92,7 @@ class ASRProvider(ASRProviderBase):
|
|
|
|
|
batch_size_s=60,
|
|
|
|
|
)
|
|
|
|
|
text = rich_transcription_postprocess(result[0]["text"])
|
|
|
|
|
logger.bind(tag=TAG).debug(f"语音识别耗时: {time.time() - start_time:.3f}s | 结果: {text}")
|
|
|
|
|
logger.bind(tag=TAG).info(f"语音识别耗时: {time.time() - start_time:.3f}s | 结果: {text}")
|
|
|
|
|
|
|
|
|
|
return text, file_path
|
|
|
|
|
|
|
|
|
@ -105,6 +105,6 @@ class ASRProvider(ASRProviderBase):
|
|
|
|
|
if self.delete_audio_file and file_path and os.path.exists(file_path):
|
|
|
|
|
try:
|
|
|
|
|
os.remove(file_path)
|
|
|
|
|
logger.bind(tag=TAG).debug(f"已删除临时音频文件: {file_path}")
|
|
|
|
|
logger.bind(tag=TAG).info(f"已删除临时音频文件: {file_path}")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logger.bind(tag=TAG).error(f"文件删除失败: {file_path} | 错误: {e}")
|
|
|
|
|
logger.bind(tag=TAG).info(f"文件删除失败: {file_path} | 错误: {e}")
|
|
|
|
|