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):
|
async def generate(request, kw):
|
||||||
params_kw = kw.get('params_kw', DictObject())
|
params_kw = kw.get('params_kw', DictObject())
|
||||||
model = params_kw.model
|
model = params_kw.model
|
||||||
audio = params_kw.audio
|
audio_file = params_kw.audio_file
|
||||||
if audio is None:
|
if not audio_file:
|
||||||
return {
|
audio = params_kw.audio
|
||||||
'status':'error',
|
if audio is None:
|
||||||
'message':'audio is null'
|
return {
|
||||||
}
|
'status':'error',
|
||||||
fname = temp_file(suffix='.wav')
|
'message':'audio is null'
|
||||||
save_base64_wav(audio, fname)
|
}
|
||||||
|
audio_file = temp_file(suffix='.wav')
|
||||||
|
save_base64_wav(audio, audio_file)
|
||||||
engine = None
|
engine = None
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
if model=='whisper':
|
if model=='whisper':
|
||||||
@ -46,9 +48,9 @@ async def generate(request, kw):
|
|||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
dic = await engine.stt(fname)
|
dic = await engine.stt(audio_file)
|
||||||
t2 = time.time()
|
t2 = time.time()
|
||||||
os.remove(fname)
|
os.remove(audio_file)
|
||||||
ret = {
|
ret = {
|
||||||
"status":"ok",
|
"status":"ok",
|
||||||
"time_cost":t2-t1,
|
"time_cost":t2-t1,
|
||||||
|
Loading…
Reference in New Issue
Block a user