25 lines
519 B
Python
25 lines
519 B
Python
from ahserver.serverenv import ServerEnv
|
|
from appPublic.worker import awaitify
|
|
import whisper
|
|
class Whisper:
|
|
def __init__(self, model_name):
|
|
self.model = whisper.load_model(model_name)
|
|
|
|
def _stt(self, filepath):
|
|
return self.model.transcribe(filepath)
|
|
|
|
stt = awaitify(_stt)
|
|
|
|
w = Whisper('medium')
|
|
g = ServerEnv()
|
|
g.stt_engine = w
|
|
if __name__ == '__main__':
|
|
import asyncio
|
|
import sys
|
|
async def main():
|
|
t = await g.stt_engine.stt(sys.argv[1])
|
|
print(t)
|
|
|
|
asyncio.get_event_loop().run_until_complete(main())
|
|
|