bugfix
This commit is contained in:
parent
642e2f1ab7
commit
f8dc17f12f
46
app/asr.py
46
app/asr.py
@ -4,31 +4,33 @@ from appPublic.log import MyLogger, info, debug, warning
|
|||||||
from appPublic.folderUtils import ProgramPath
|
from appPublic.folderUtils import ProgramPath
|
||||||
from appPublic.jsonConfig import getConfig
|
from appPublic.jsonConfig import getConfig
|
||||||
from ahserver.configuredServer import ConfiguredServer
|
from ahserver.configuredServer import ConfiguredServer
|
||||||
import asr_engine
|
from ahserver.serverenv import ServerEnv
|
||||||
|
from whisper_model import WhisperBase64
|
||||||
|
|
||||||
__version__ = '0.0.1'
|
__version__ = '0.0.1'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(prog="Sage")
|
parser = argparse.ArgumentParser(prog="Sage")
|
||||||
parser.add_argument('-w', '--workdir')
|
parser.add_argument('-w', '--workdir')
|
||||||
parser.add_argument('-p', '--port')
|
parser.add_argument('-p', '--port')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
workdir = args.workdir or os.getcwd()
|
print(args)
|
||||||
p = ProgramPath()
|
workdir = args.workdir or os.getcwd()
|
||||||
config = getConfig(workdir, NS={'workdir':workdir, 'ProgramPath':p})
|
p = ProgramPath()
|
||||||
if config.logger:
|
config = getConfig(workdir, NS={'workdir':workdir, 'ProgramPath':p})
|
||||||
logger = MyLogger(config.logger.name or 'sage',
|
if config.logger:
|
||||||
levelname=config.logger.levelname or 'debug',
|
logger = MyLogger(config.logger.name or 'sage',
|
||||||
logfile=config.logger.logfile or None)
|
levelname=config.logger.levelname or 'debug',
|
||||||
else:
|
logfile=config.logger.logfile or None)
|
||||||
logger = MyLogger('sage', levelname='debug')
|
else:
|
||||||
|
logger = MyLogger('sage', levelname='debug')
|
||||||
|
|
||||||
info(f'========sage version={__version__}========')
|
info(f'========sage version={__version__}========')
|
||||||
# server = ConfiguredServer(auth_klass=MyAuthAPI, workdir=workdir)
|
# server = ConfiguredServer(auth_klass=MyAuthAPI, workdir=workdir)
|
||||||
server = ConfiguredServer(workdir=workdir)
|
server = ConfiguredServer(workdir=workdir)
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
g.whisper_model = WhisperBase64()
|
g.whisper_model = WhisperBase64()
|
||||||
port = args.port or config.website.port or 8080
|
port = args.port or config.website.port or 8080
|
||||||
port = int(port)
|
port = int(port)
|
||||||
server.run(port=port)
|
server.run(port=port)
|
||||||
|
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
from ahserver.serverenv import ServerEnv
|
from ahserver.serverenv import ServerEnv
|
||||||
from aiohttp.web import StreamResponse
|
from aiohttp.web import StreamResponse
|
||||||
|
|
||||||
from whisper.load_model import WhisperBase64
|
|
||||||
|
|
||||||
async def generate(request, **kw):
|
async def generate(request, **kw):
|
||||||
model = kw.get('model', 'whisper')
|
model = kw.get('model', 'whisper')
|
||||||
engine = None
|
engine = None
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
if model=='whisper':
|
if model=='whisper':
|
||||||
engine = g.whisper_engine
|
engine = g.whisper_engine
|
||||||
if engine is None:
|
|
||||||
engine = WhisperBase64
|
|
||||||
g.whisper_engine = engine
|
|
||||||
|
|
||||||
await resp.prepare(request)
|
await resp.prepare(request)
|
||||||
line = await request.content.readline()
|
line = await request.content.readline()
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
openai-whisper
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
from ahserver.serverenv import ServerEnv
|
from ahserver.serverenv import ServerEnv
|
||||||
from appPublic.worker import awaitify
|
from appPublic.worker import awaitify
|
||||||
from appPublic.jsonConfig import getConfig, get_definition
|
|
||||||
|
from ahserver.globalEnv import get_definition
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import base64
|
import base64
|
||||||
import whisper
|
import whisper
|
||||||
@ -40,6 +41,3 @@ class WhisperBase64(WhisperBase):
|
|||||||
ndarr = np.frombuffer(raw, dtype=np.float32)
|
ndarr = np.frombuffer(raw, dtype=np.float32)
|
||||||
return self.model.transcribe(raw)
|
return self.model.transcribe(raw)
|
||||||
|
|
||||||
g = ServerEnv()
|
|
||||||
g.whisper_engine = WhisperBase64()
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user