Spaces:
Running
on
A10G
Running
on
A10G
GitLab CI
commited on
Commit
·
93161aa
1
Parent(s):
3256e71
Update game build from GitLab CI
Browse files- Dockerfile +6 -8
- server/ActionProcessor.py +6 -1
- server/static/godot/index.html +1 -1
- server/static/godot/index.pck +0 -0
- server/static/index.html +45 -89
Dockerfile
CHANGED
@@ -14,16 +14,14 @@ WORKDIR /app
|
|
14 |
RUN apt-get update && apt-get install -y \
|
15 |
gcc \
|
16 |
portaudio19-dev \
|
17 |
-
|
18 |
libasound2-dev \
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
git \
|
25 |
wget \
|
26 |
-
gnupg2 \
|
27 |
&& rm -rf /var/lib/apt/lists/*
|
28 |
|
29 |
# Add NVIDIA repository and install CUDA
|
|
|
14 |
RUN apt-get update && apt-get install -y \
|
15 |
gcc \
|
16 |
portaudio19-dev \
|
17 |
+
python3-dev \
|
18 |
libasound2-dev \
|
19 |
+
libpulse-dev \
|
20 |
+
libportaudio2 \
|
21 |
+
libportaudiocpp0 \
|
22 |
+
libasound2 \
|
23 |
+
libasound2-data \
|
|
|
24 |
wget \
|
|
|
25 |
&& rm -rf /var/lib/apt/lists/*
|
26 |
|
27 |
# Add NVIDIA repository and install CUDA
|
server/ActionProcessor.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from threading import Thread
|
2 |
from multiprocessing import Queue
|
3 |
from typing import Dict, Any, List
|
@@ -96,7 +97,11 @@ class ActionProcessor(Thread):
|
|
96 |
|
97 |
if len(self.text_buffers[0]) < len(candidate) >= len(self.text_buffers[2]):
|
98 |
sentiment_and_action = self.get_sentiment_and_action(candidate)
|
99 |
-
return {
|
|
|
|
|
|
|
|
|
100 |
|
101 |
return None
|
102 |
|
|
|
1 |
+
import datetime
|
2 |
from threading import Thread
|
3 |
from multiprocessing import Queue
|
4 |
from typing import Dict, Any, List
|
|
|
97 |
|
98 |
if len(self.text_buffers[0]) < len(candidate) >= len(self.text_buffers[2]):
|
99 |
sentiment_and_action = self.get_sentiment_and_action(candidate)
|
100 |
+
return {
|
101 |
+
"type": "action",
|
102 |
+
"sentiment": sentiment_and_action,
|
103 |
+
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
104 |
+
}
|
105 |
|
106 |
return None
|
107 |
|
server/static/godot/index.html
CHANGED
@@ -97,7 +97,7 @@ body {
|
|
97 |
|
98 |
<script src="index.js"></script>
|
99 |
<script>
|
100 |
-
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":false,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":
|
101 |
const GODOT_THREADS_ENABLED = false;
|
102 |
const engine = new Engine(GODOT_CONFIG);
|
103 |
|
|
|
97 |
|
98 |
<script src="index.js"></script>
|
99 |
<script>
|
100 |
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":false,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":870464,"index.wasm":35376909},"focusCanvas":true,"gdextensionLibs":[]};
|
101 |
const GODOT_THREADS_ENABLED = false;
|
102 |
const engine = new Engine(GODOT_CONFIG);
|
103 |
|
server/static/godot/index.pck
CHANGED
Binary files a/server/static/godot/index.pck and b/server/static/godot/index.pck differ
|
|
server/static/index.html
CHANGED
@@ -34,100 +34,56 @@
|
|
34 |
const serverUrl = "./api/process"
|
35 |
const FETCH_TIMEOUT = 5000 // 5 seconds timeout
|
36 |
|
37 |
-
// Check
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
signal: controller.signal
|
44 |
-
})
|
45 |
-
.then(response => {
|
46 |
-
clearTimeout(timeout)
|
47 |
-
if (!response.ok) {
|
48 |
-
throw new Error(`Server check failed: ${response.status}`)
|
49 |
-
}
|
50 |
-
console.log('Server check successful')
|
51 |
-
setupAudioRecording()
|
52 |
-
})
|
53 |
-
.catch(error => {
|
54 |
-
clearTimeout(timeout)
|
55 |
-
const errorMessage = error.name === 'AbortError'
|
56 |
-
? 'Server request timed out. Please try again later.'
|
57 |
-
: 'Could not connect to the server. Please try again later.'
|
58 |
-
console.error('Server check failed:', error)
|
59 |
-
console.error(errorMessage)
|
60 |
-
throw error
|
61 |
-
})
|
62 |
-
|
63 |
-
// Move existing audio setup into a function
|
64 |
-
function setupAudioRecording() {
|
65 |
-
// Check if browser supports audio recording
|
66 |
-
if (!navigator.mediaDevices?.getUserMedia) {
|
67 |
-
console.error('Your browser does not support audio recording.')
|
68 |
-
console.error('Please try using a modern browser like Chrome, Firefox, or Edge.')
|
69 |
-
throw new Error('Audio recording not supported')
|
70 |
-
}
|
71 |
-
|
72 |
-
navigator.mediaDevices.getUserMedia({ audio: true })
|
73 |
-
.then(stream => {
|
74 |
-
const audioContext = new (window.AudioContext || window.webkitAudioContext)()
|
75 |
-
const mediaRecorder = new MediaRecorder(stream)
|
76 |
-
const audioChunks = []
|
77 |
-
|
78 |
-
mediaRecorder.ondataavailable = event => {
|
79 |
-
audioChunks.push(event.data)
|
80 |
-
}
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
reader.onloadend = () => {
|
90 |
-
// Extract the base64 data (remove the data URL prefix)
|
91 |
-
const base64Audio = reader.result.split(',')[1]
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
signal: audioController.signal
|
106 |
-
}).then(response => {
|
107 |
-
clearTimeout(audioTimeout)
|
108 |
-
console.log('Audio chunk sent successfully')
|
109 |
-
}).catch(error => {
|
110 |
-
clearTimeout(audioTimeout)
|
111 |
-
console.error('Error sending audio chunk:', error)
|
112 |
-
})
|
113 |
-
}
|
114 |
}
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
mediaRecorder.stop()
|
121 |
-
mediaRecorder.start()
|
122 |
-
} else {
|
123 |
-
mediaRecorder.start()
|
124 |
-
}
|
125 |
-
}, chunkInterval)
|
126 |
-
})
|
127 |
-
.catch(error => {
|
128 |
-
console.error('Error accessing microphone:', error)
|
129 |
-
})
|
130 |
-
}
|
131 |
</script>
|
132 |
</body>
|
133 |
|
|
|
34 |
const serverUrl = "./api/process"
|
35 |
const FETCH_TIMEOUT = 5000 // 5 seconds timeout
|
36 |
|
37 |
+
// Check if browser supports audio recording
|
38 |
+
if (!navigator.mediaDevices?.getUserMedia) {
|
39 |
+
console.error('Your browser does not support audio recording.')
|
40 |
+
alert('Your browser does not support audio recording. Please try using a modern browser like Chrome, Firefox, or Edge.')
|
41 |
+
throw new Error('Audio recording not supported')
|
42 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
+
// Set up audio recording
|
45 |
+
navigator.mediaDevices.getUserMedia({ audio: true })
|
46 |
+
.then(stream => {
|
47 |
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)()
|
48 |
+
const mediaRecorder = new MediaRecorder(stream)
|
49 |
+
const audioChunks = []
|
50 |
|
51 |
+
mediaRecorder.ondataavailable = event => {
|
52 |
+
audioChunks.push(event.data)
|
53 |
+
}
|
|
|
|
|
|
|
54 |
|
55 |
+
mediaRecorder.onstop = () => {
|
56 |
+
const audioBlob = new Blob(audioChunks, { type: 'audio/webm' })
|
57 |
+
audioChunks.length = 0 // Clear chunks after creating the Blob
|
58 |
+
|
59 |
+
// Send the audio chunk to the server
|
60 |
+
const formData = new FormData()
|
61 |
+
formData.append('audio', audioBlob)
|
62 |
+
|
63 |
+
fetch(serverUrl, {
|
64 |
+
method: 'POST',
|
65 |
+
body: formData
|
66 |
+
}).then(response => {
|
67 |
+
console.log('Audio chunk sent successfully')
|
68 |
+
}).catch(error => {
|
69 |
+
console.error('Error sending audio chunk:', error)
|
70 |
+
})
|
71 |
+
}
|
72 |
|
73 |
+
// Start recording in intervals
|
74 |
+
const chunkInterval = 300 // Chunk duration in milliseconds
|
75 |
+
setInterval(() => {
|
76 |
+
if (mediaRecorder.state === 'recording') {
|
77 |
+
mediaRecorder.stop()
|
78 |
+
mediaRecorder.start()
|
79 |
+
} else {
|
80 |
+
mediaRecorder.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
+
}, chunkInterval)
|
83 |
+
})
|
84 |
+
.catch(error => {
|
85 |
+
console.error('Error accessing microphone:', error)
|
86 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
</script>
|
88 |
</body>
|
89 |
|