nuernie commited on
Commit
d680376
Β·
1 Parent(s): 789655e

remove fast api

Browse files
Files changed (1) hide show
  1. app.py +6 -50
app.py CHANGED
@@ -1,10 +1,5 @@
1
- from fastapi import FastAPI, WebSocket, WebSocketDisconnect
2
- from contextlib import asynccontextmanager
3
- import uvicorn
4
  from whisper_live.server import TranscriptionServer
5
  import logging
6
- import numpy as np
7
- import threading
8
 
9
  # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
10
  # Logging
@@ -12,50 +7,11 @@ import threading
12
  logging.basicConfig(level=logging.INFO)
13
  logger = logging.getLogger(__name__)
14
 
15
- # Global server instance
16
- transcription_server = None
17
- server_thread = None
18
-
19
- @asynccontextmanager
20
- async def lifespan(app: FastAPI):
21
- # Startup: create and start the transcription server
22
- global transcription_server, server_thread
23
  transcription_server = TranscriptionServer()
24
- server_thread = threading.Thread(
25
- target=transcription_server.run,
26
- kwargs={
27
- 'host': '0.0.0.0',
28
- 'port': 7860, # WebSocket port for transcription
29
- 'backend': 'faster_whisper'
30
- }
31
  )
32
- server_thread.daemon = True
33
- server_thread.start()
34
- yield
35
- # Cleanup
36
- if transcription_server:
37
- transcription_server.cleanup()
38
-
39
- app = FastAPI(
40
- title="Whisper Live Server",
41
- version="1.0.0",
42
- lifespan=lifespan
43
- )
44
-
45
- @app.get("/")
46
- async def root():
47
- return {
48
- "message": "Welcome to Whisper Live Server",
49
- "websocket_endpoint": "ws://localhost:9090", # Direct WebSocket connection
50
- "health_endpoint": "/health"
51
- }
52
-
53
- @app.get("/health")
54
- async def health_check():
55
- global transcription_server, server_thread
56
- if transcription_server and server_thread.is_alive():
57
- return {"status": "healthy"}
58
- return {"status": "unhealthy"}
59
-
60
- if __name__ == "__main__":
61
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
1
  from whisper_live.server import TranscriptionServer
2
  import logging
 
 
3
 
4
  # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
5
  # Logging
 
7
  logging.basicConfig(level=logging.INFO)
8
  logger = logging.getLogger(__name__)
9
 
10
+ if __name__ == "__main__":
11
+ # Create and start the transcription server
 
 
 
 
 
 
12
  transcription_server = TranscriptionServer()
13
+ transcription_server.run(
14
+ host='0.0.0.0',
15
+ port=7860,
16
+ backend='faster_whisper'
 
 
 
17
  )