This commit is contained in:
yumoqing 2024-08-10 16:58:59 +08:00
parent 77d4c4b2aa
commit f5bc75f183

View File

@ -1,4 +1,5 @@
import os import os
import time
from traceback import print_exc from traceback import print_exc
import base64 import base64
import wave import wave
@ -44,12 +45,17 @@ async def generate(request, kw):
'message':f'model={model} is not defined' 'message':f'model={model} is not defined'
} }
try: try:
txt = await engine.stt(fname) t1 = time.time()
dic = await engine.stt(fname)
t2 = time.time()
os.remove(fname) os.remove(fname)
info(f'{txt=}') info(f'{txt=}')
return { return {
"status":"ok", "status":"ok",
"content":txt "time_cost":t2-t1,
"content":dic['text'],
"segments":dic['segments'],
"language":dic['language']
} }
except Exception as e: except Exception as e:
exception(f'{e}') exception(f'{e}')