This commit is contained in:
buua436 2025-12-02 09:36:22 +08:00
parent 33288d5491
commit 8f32b160eb
2 changed files with 8 additions and 8 deletions

View file

@ -291,8 +291,8 @@ async def sequence2txt():
text = asr_mdl.transcription(temp_audio_path)
try:
os.remove(temp_audio_path)
except:
pass
except Exception as e:
logging.error(f"Failed to remove temp audio file: {str(e)}")
return get_json_result(data={"text": text})
async def event_stream():
try:
@ -304,8 +304,8 @@ async def sequence2txt():
finally:
try:
os.remove(temp_audio_path)
except:
pass
except Exception as e:
logging.error(f"Failed to remove temp audio file: {str(e)}")
return Response(event_stream(), content_type="text/event-stream")

View file

@ -99,8 +99,8 @@ class QWenSeq2txt(Base):
try:
text = resp["output"]["choices"][0]["message"].content[0]["text"]
except:
text = ""
except Exception as e:
text = "**ERROR**: " + str(e)
return text, num_tokens_from_string(text)
def stream_transcription(self, audio_path):
@ -139,8 +139,8 @@ class QWenSeq2txt(Base):
piece = chunk["output"]["choices"][0]["message"].content[0]["text"]
full = piece
yield {"event": "delta", "text": piece}
except:
pass
except Exception as e:
yield {"event": "error", "text": str(e)}
yield {"event": "final", "text": full}