Spaces:
Running
on
A10G
Running
on
A10G
GitLab CI
commited on
Commit
·
2ec9baa
1
Parent(s):
eda8eea
Update game build from GitLab CI
Browse files- server/AudioTranscriber.py +15 -2
- server/__main__.py +20 -4
- server/static/godot/index.pck +0 -0
server/AudioTranscriber.py
CHANGED
@@ -4,6 +4,19 @@ from multiprocessing import Queue
|
|
4 |
from queue import Empty
|
5 |
from faster_whisper import WhisperModel
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
class AudioTranscriber(threading.Thread):
|
9 |
def __init__(self, audio_queue: "Queue[io.BytesIO]", text_queue: "Queue[str]"):
|
@@ -31,7 +44,7 @@ class AudioTranscriber(threading.Thread):
|
|
31 |
for segment in segments:
|
32 |
self.action_queue.put(segment.text)
|
33 |
# Still print for debugging
|
34 |
-
|
35 |
f"[%.2fs -> %.2fs] %s"
|
36 |
% (segment.start, segment.end, segment.text)
|
37 |
)
|
@@ -39,4 +52,4 @@ class AudioTranscriber(threading.Thread):
|
|
39 |
except Empty:
|
40 |
continue # If queue is empty, continue waiting
|
41 |
except Exception as e:
|
42 |
-
|
|
|
4 |
from queue import Empty
|
5 |
from faster_whisper import WhisperModel
|
6 |
|
7 |
+
import logging
|
8 |
+
import sys
|
9 |
+
|
10 |
+
# Configure logging
|
11 |
+
logging.basicConfig(
|
12 |
+
level=logging.INFO,
|
13 |
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
14 |
+
handlers=[logging.StreamHandler(sys.stdout)],
|
15 |
+
)
|
16 |
+
|
17 |
+
# Get a logger for your app
|
18 |
+
logger = logging.getLogger(__name__)
|
19 |
+
|
20 |
|
21 |
class AudioTranscriber(threading.Thread):
|
22 |
def __init__(self, audio_queue: "Queue[io.BytesIO]", text_queue: "Queue[str]"):
|
|
|
44 |
for segment in segments:
|
45 |
self.action_queue.put(segment.text)
|
46 |
# Still print for debugging
|
47 |
+
logger.info(
|
48 |
f"[%.2fs -> %.2fs] %s"
|
49 |
% (segment.start, segment.end, segment.text)
|
50 |
)
|
|
|
52 |
except Empty:
|
53 |
continue # If queue is empty, continue waiting
|
54 |
except Exception as e:
|
55 |
+
logger.error(f"Error processing audio chunk: {e}")
|
server/__main__.py
CHANGED
@@ -8,10 +8,22 @@ from multiprocessing import Queue
|
|
8 |
import base64
|
9 |
from typing import Any, Optional, List, Dict, Tuple
|
10 |
from queue import Queue
|
|
|
|
|
11 |
|
12 |
from server.AudioTranscriber import AudioTranscriber
|
13 |
from server.ActionProcessor import ActionProcessor
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Use a directory in the user's home folder for static files
|
16 |
STATIC_DIR = "/app/server/static" if os.getenv("DEBUG") != "true" else "./server"
|
17 |
|
@@ -78,7 +90,7 @@ def get_data():
|
|
78 |
|
79 |
@app.route("/api/process", methods=["POST"])
|
80 |
def process_data():
|
81 |
-
|
82 |
try:
|
83 |
# Check content type
|
84 |
content_type = request.headers.get("Content-Type", "")
|
@@ -170,10 +182,10 @@ class StandaloneApplication(gunicorn.app.base.BaseApplication):
|
|
170 |
|
171 |
|
172 |
if __name__ == "__main__":
|
173 |
-
|
174 |
-
|
175 |
if os.path.exists(app.static_folder):
|
176 |
-
|
177 |
|
178 |
os.makedirs(app.static_folder, exist_ok=True)
|
179 |
|
@@ -191,6 +203,10 @@ if __name__ == "__main__":
|
|
191 |
"worker_class": "sync",
|
192 |
"timeout": 120,
|
193 |
"forwarded_allow_ips": "*",
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
|
196 |
StandaloneApplication(app, options).run()
|
|
|
8 |
import base64
|
9 |
from typing import Any, Optional, List, Dict, Tuple
|
10 |
from queue import Queue
|
11 |
+
import logging
|
12 |
+
import sys
|
13 |
|
14 |
from server.AudioTranscriber import AudioTranscriber
|
15 |
from server.ActionProcessor import ActionProcessor
|
16 |
|
17 |
+
# Configure logging
|
18 |
+
logging.basicConfig(
|
19 |
+
level=logging.INFO,
|
20 |
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
21 |
+
handlers=[logging.StreamHandler(sys.stdout)],
|
22 |
+
)
|
23 |
+
|
24 |
+
# Get a logger for your app
|
25 |
+
logger = logging.getLogger(__name__)
|
26 |
+
|
27 |
# Use a directory in the user's home folder for static files
|
28 |
STATIC_DIR = "/app/server/static" if os.getenv("DEBUG") != "true" else "./server"
|
29 |
|
|
|
90 |
|
91 |
@app.route("/api/process", methods=["POST"])
|
92 |
def process_data():
|
93 |
+
logger.info("Processing data")
|
94 |
try:
|
95 |
# Check content type
|
96 |
content_type = request.headers.get("Content-Type", "")
|
|
|
182 |
|
183 |
|
184 |
if __name__ == "__main__":
|
185 |
+
logger.info(f"Static folder path: {app.static_folder}")
|
186 |
+
logger.info(f"Static folder exists: {os.path.exists(app.static_folder)}")
|
187 |
if os.path.exists(app.static_folder):
|
188 |
+
logger.info(f"Static folder contents: {os.listdir(app.static_folder)}")
|
189 |
|
190 |
os.makedirs(app.static_folder, exist_ok=True)
|
191 |
|
|
|
203 |
"worker_class": "sync",
|
204 |
"timeout": 120,
|
205 |
"forwarded_allow_ips": "*",
|
206 |
+
"accesslog": "-", # Log to stdout
|
207 |
+
"errorlog": "-", # Log to stderr
|
208 |
+
"capture_output": True,
|
209 |
+
"enable_stdio_inheritance": True,
|
210 |
}
|
211 |
|
212 |
StandaloneApplication(app, options).run()
|
server/static/godot/index.pck
CHANGED
Binary files a/server/static/godot/index.pck and b/server/static/godot/index.pck differ
|
|