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()) params_kw = kw.get('params_kw', DictObject())
info(f'{params_kw=}') info(f'{params_kw=}')
model = params_kw.model model = params_kw.model
audiob64 = params_kw.audiob64 audio = params_kw.audio
if audiob64 is None: if audio is None:
return { return {
'status':'error', 'status':'error',
'message':'audio is null' 'message':'audio is null'
@ -26,8 +26,8 @@ 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(audiob64) txt = await engine.stt(audio)
info(f'{audiob64=}, {txt=}') info(f'{audio=}, {txt=}')
return { return {
"status":"ok", "status":"ok",
"content":txt "content":txt

View File

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