This commit is contained in:
yumoqing 2024-08-05 17:00:39 +08:00
parent fee6293cee
commit 5776c05bda
2 changed files with 6 additions and 5 deletions

View File

@ -9,8 +9,8 @@ async def generate(request, **kw):
params_kw = kw.get('params_kw', DictObject())
info(f'{params_kw=}')
model = params_kw.model
audiob64 = params_kw.audiob64
if audiob64 is None:
audio = params_kw.audio
if audio is None:
return {
'status':'error',
'message':'audio is null'
@ -26,8 +26,8 @@ async def generate(request, **kw):
'message':f'model={model} is not defined'
}
try:
txt = await engine.stt(audiob64)
info(f'{audiob64=}, {txt=}')
txt = await engine.stt(audio)
info(f'{audio=}, {txt=}')
return {
"status":"ok",
"content":txt

View File

@ -31,12 +31,12 @@ class WhisperBase:
exception(f'{e=}')
raise e
stt = awaitify(_stt)
class WhisperFile(WhisperBase):
def _stt(self, filepath):
return self.model.transcribe(filepath)
stt = awaitify(_stt)
class WhisperBase64(WhisperBase):
def _stt(self, audio_base64):
@ -45,3 +45,4 @@ class WhisperBase64(WhisperBase):
info(f'ndarr={ndarr}')
return self.model.transcribe(ndarr)
stt = awaitify(_stt)