Dockerise the application
This commit is contained in:
parent
7084655364
commit
48e652c9c1
2 changed files with 19 additions and 4 deletions
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM python:3.10-slim
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git-lfs \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
COPY detect.py .
|
||||||
|
|
||||||
|
CMD [ "python3", "detect.py", "-c", "/config/config.yaml"]
|
11
detect.py
11
detect.py
|
@ -36,9 +36,12 @@ args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def load_config(config_file):
|
def load_config(config_file):
|
||||||
"""Load the configuration from config.yaml file and use it to override the defaults."""
|
"""Use config.yaml to override the default configuration."""
|
||||||
with open(config_file, "r") as f:
|
try:
|
||||||
config_override = yaml.safe_load(f)
|
with open(config_file, "r") as f:
|
||||||
|
config_override = yaml.safe_load(f)
|
||||||
|
except FileNotFoundError:
|
||||||
|
config_override = {}
|
||||||
|
|
||||||
default_config = {
|
default_config = {
|
||||||
"mqtt": {
|
"mqtt": {
|
||||||
|
@ -79,7 +82,7 @@ def receive_udp_audio(port=12202):
|
||||||
audio = wave.open(io.BytesIO(data))
|
audio = wave.open(io.BytesIO(data))
|
||||||
frames = audio.readframes(RHASSPY_FRAMES)
|
frames = audio.readframes(RHASSPY_FRAMES)
|
||||||
audio_buffer.extend(np.frombuffer(frames, dtype=np.int16))
|
audio_buffer.extend(np.frombuffer(frames, dtype=np.int16))
|
||||||
print(".", end="", flush=True)
|
# print(".", end="", flush=True) # TODO can remove
|
||||||
if len(audio_buffer) > OWW_FRAMES:
|
if len(audio_buffer) > OWW_FRAMES:
|
||||||
q.put(
|
q.put(
|
||||||
np.asarray(audio_buffer[:OWW_FRAMES], dtype=np.int16)
|
np.asarray(audio_buffer[:OWW_FRAMES], dtype=np.int16)
|
||||||
|
|
Loading…
Add table
Reference in a new issue