bugfix
This commit is contained in:
parent
30d708d017
commit
ad9cb633fa
@ -5,25 +5,25 @@ from aiohttp.web import StreamResponse
|
|||||||
|
|
||||||
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
|
||||||
engine = None
|
engine = None
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
if model=='whisper':
|
if model=='whisper':
|
||||||
engine = g.whisper_engine
|
engine = g.whisper_engine
|
||||||
|
|
||||||
await resp.prepare(request)
|
await resp.prepare(request)
|
||||||
line = await request.content.readline()
|
line = await request.content.readline()
|
||||||
content = ''
|
content = ''
|
||||||
while line:
|
while line:
|
||||||
info(f'read from request stream {line=}')
|
info(f'read from request stream {line=}')
|
||||||
txt = await engine.stt(line)
|
txt = await engine.stt(line)
|
||||||
content += txt
|
content += txt
|
||||||
d = json.dumps({'content':content})
|
d = json.dumps({'content':content})
|
||||||
btxt = d.encode('utf8')
|
btxt = d.encode('utf8')
|
||||||
await resp.write(btxt)
|
await resp.write(btxt)
|
||||||
await resp.drain()
|
await resp.drain()
|
||||||
line = await request.content.readline()
|
line = await request.content.readline()
|
||||||
info('response finish')
|
info('response finish')
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user