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_file = params_kw.audio_file
|
||||||
|
if not audio_file:
|
||||||
audio = params_kw.audio
|
audio = params_kw.audio
|
||||||
if audio is None:
|
if audio is None:
|
||||||
return {
|
return {
|
||||||
'status':'error',
|
'status':'error',
|
||||||
'message':'audio is null'
|
'message':'audio is null'
|
||||||
}
|
}
|
||||||
fname = temp_file(suffix='.wav')
|
audio_file = temp_file(suffix='.wav')
|
||||||
save_base64_wav(audio, fname)
|
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