bugfix
This commit is contained in:
parent
7e30812a09
commit
08369052c5
@ -26,14 +26,16 @@ def save_base64_wav(base64_data, output_file,sample_rate=16000, num_channels=1):
|
||||
async def generate(request, kw):
|
||||
params_kw = kw.get('params_kw', DictObject())
|
||||
model = params_kw.model
|
||||
audio_file = params_kw.audio_file
|
||||
if not audio_file:
|
||||
audio = params_kw.audio
|
||||
if audio is None:
|
||||
return {
|
||||
'status':'error',
|
||||
'message':'audio is null'
|
||||
}
|
||||
fname = temp_file(suffix='.wav')
|
||||
save_base64_wav(audio, fname)
|
||||
audio_file = temp_file(suffix='.wav')
|
||||
save_base64_wav(audio, audio_file)
|
||||
engine = None
|
||||
g = ServerEnv()
|
||||
if model=='whisper':
|
||||
@ -46,9 +48,9 @@ async def generate(request, kw):
|
||||
}
|
||||
try:
|
||||
t1 = time.time()
|
||||
dic = await engine.stt(fname)
|
||||
dic = await engine.stt(audio_file)
|
||||
t2 = time.time()
|
||||
os.remove(fname)
|
||||
os.remove(audio_file)
|
||||
ret = {
|
||||
"status":"ok",
|
||||
"time_cost":t2-t1,
|
||||
|
Loading…
Reference in New Issue
Block a user