Spaces:
Sleeping

mindSoftPro commited on
Commit
5383670
·
verified ·
1 Parent(s): 0b56da9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -21,18 +21,6 @@ logging.basicConfig(
21
  )
22
  logger = logging.getLogger(__name__)
23
 
24
- openai_client = openai.Client(api_key=OPENAI_API_KEY) if OPENAI_API_KEY else None
25
-
26
- # Initialize models at server startup
27
- logger.info("Loading diarization pipeline...")
28
- pipeline = Pipeline.from_pretrained(
29
- "pyannote/speaker-diarization-3.1",
30
- use_auth_token=HUGGINGFACE_ACCESS_TOKEN
31
- )
32
-
33
- logger.info("Loading Whisper model...")
34
- whisper_model = whisper.load_model("turbo")
35
-
36
  app = FastAPI()
37
 
38
  # Environment variables
@@ -49,6 +37,18 @@ AUTH_TOKEN = os.getenv("API_AUTH_TOKEN")
49
  if not AUTH_TOKEN:
50
  raise EnvironmentError("API_AUTH_TOKEN is not set")
51
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  security = HTTPBearer()
53
 
54
  class DiarizeRequest(BaseModel):
 
21
  )
22
  logger = logging.getLogger(__name__)
23
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  app = FastAPI()
25
 
26
  # Environment variables
 
37
  if not AUTH_TOKEN:
38
  raise EnvironmentError("API_AUTH_TOKEN is not set")
39
 
40
+ openai_client = openai.Client(api_key=OPENAI_API_KEY) if OPENAI_API_KEY else None
41
+
42
+ # Initialize models at server startup
43
+ logger.info("Loading diarization pipeline...")
44
+ pipeline = Pipeline.from_pretrained(
45
+ "pyannote/speaker-diarization-3.1",
46
+ use_auth_token=HUGGINGFACE_ACCESS_TOKEN
47
+ )
48
+
49
+ logger.info("Loading Whisper model...")
50
+ whisper_model = whisper.load_model("turbo")
51
+
52
  security = HTTPBearer()
53
 
54
  class DiarizeRequest(BaseModel):