Writing and speaking rework, some changes to module upload
This commit is contained in:
@@ -12,7 +12,6 @@ from typing import List
|
||||
from http import HTTPStatus
|
||||
|
||||
import httpx
|
||||
import whisper
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
@@ -27,6 +26,7 @@ from app.api import router
|
||||
from app.configs import DependencyInjector
|
||||
from app.exceptions import CustomException
|
||||
from app.middlewares import AuthenticationMiddleware, AuthBackend
|
||||
from app.services.impl import OpenAIWhisper
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
@@ -36,8 +36,6 @@ async def lifespan(_app: FastAPI):
|
||||
|
||||
https://fastapi.tiangolo.com/advanced/events/
|
||||
"""
|
||||
# Whisper model
|
||||
whisper_model = whisper.load_model("base")
|
||||
|
||||
# NLTK required datasets download
|
||||
nltk.download('words')
|
||||
@@ -56,11 +54,12 @@ async def lifespan(_app: FastAPI):
|
||||
)
|
||||
|
||||
http_client = httpx.AsyncClient()
|
||||
stt = OpenAIWhisper()
|
||||
|
||||
DependencyInjector(
|
||||
polly_client,
|
||||
http_client,
|
||||
whisper_model
|
||||
stt
|
||||
).inject()
|
||||
|
||||
# Setup logging
|
||||
@@ -72,6 +71,7 @@ async def lifespan(_app: FastAPI):
|
||||
|
||||
yield
|
||||
|
||||
stt.close()
|
||||
await http_client.aclose()
|
||||
await polly_client.close()
|
||||
await context_stack.aclose()
|
||||
|
||||
Reference in New Issue
Block a user