Skip to content

Commit 927548e

Browse files
committed
Docker v1
1 parent 38a6be4 commit 927548e

File tree

8 files changed

+89
-10
lines changed

8 files changed

+89
-10
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__pycache__
2+
.cache
3+
.dockerignore
4+
docker-compose.yml
5+
Dockerfile

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__
2+
.cache
3+
realtimesst.log

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 as gpu
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update -y && \
6+
apt-get install -y python3 python3-pip libcudnn8 libcudnn8-dev libcublas-12-4 portaudio19-dev
7+
8+
RUN pip3 install torch==2.3.0 torchaudio==2.3.0
9+
10+
COPY requirements-gpu.txt /app/requirements-gpu.txt
11+
RUN pip3 install -r /app/requirements-gpu.txt
12+
13+
RUN mkdir example_browserclient
14+
COPY example_browserclient/server.py /app/example_browserclient/server.py
15+
COPY RealtimeSTT /app/RealtimeSTT
16+
17+
EXPOSE 9001
18+
ENV PYTHONPATH "${PYTHONPATH}:/app"
19+
RUN export PYTHONPATH="${PYTHONPATH}:/app"
20+
CMD ["python3", "example_browserclient/server.py"]
21+
22+
# --------------------------------------------
23+
24+
FROM ubuntu22.04 as cpu
25+
26+
WORKDIR /app
27+
28+
RUN apt-get update -y && \
29+
apt-get install -y python3 python3-pip portaudio19-dev
30+
31+
RUN pip3 install torch==2.2.2+cu118 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu118
32+
33+
COPY requirements.txt /app/requirements.txt
34+
RUN pip3 install -r /app/requirements.txt
35+
36+
EXPOSE 9001
37+
ENV PYTHONPATH "${PYTHONPATH}:/app"
38+
RUN export PYTHONPATH="${PYTHONPATH}:/app"
39+
CMD ["python3", "example_browserclient/server.py"]

docker-compose.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
rtstt:
3+
build:
4+
context: .
5+
target: gpu # or cpu
6+
image: rtstt
7+
container_name: rtstt
8+
volumes:
9+
# - ./RealtimeSTT:/app/RealtimeSTT
10+
# - ./example_browserclient:/app/example_browserclient
11+
- cache:/root/.cache
12+
ports:
13+
- "9001:9001"
14+
15+
# if 'gpu' target
16+
deploy:
17+
resources:
18+
reservations:
19+
devices:
20+
- capabilities: ["gpu"]
21+
nginx:
22+
image: nginx:latest
23+
container_name: nginx_web
24+
ports:
25+
- "8081:80"
26+
volumes:
27+
- ./example_browserclient:/usr/share/nginx/html
28+
29+
volumes:
30+
cache:

example_browserclient/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def echo(websocket, path):
9898
resampled_chunk = decode_and_resample(chunk, sample_rate, 16000)
9999
recorder.feed_audio(resampled_chunk)
100100

101-
start_server = websockets.serve(echo, "localhost", 9001)
101+
start_server = websockets.serve(echo, "0.0.0.0", 9001)
102102

103103
recorder_thread = threading.Thread(target=recorder_thread)
104104
recorder_thread.start()

example_webserver/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
WAIT_FOR_START_COMMAND = False
22

33
if __name__ == '__main__':
4-
server = "localhost"
4+
server = "0.0.0.0"
55
port = 5025
66

77
print (f"STT speech to text server")

requirements-gpu.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
PyAudio==0.2.14
2-
faster-whisper==1.0.1
3-
pvporcupine==1.9.5
2+
faster-whisper==1.0.2
3+
pvporcupine==3.0.2
44
webrtcvad==2.0.10
55
halo==0.0.31
6-
scipy==1.12.0
6+
scipy==1.13.0
7+
websockets==v12.0

requirements.txt

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
PyAudio==0.2.14
2-
faster-whisper==1.0.1
3-
pvporcupine==1.9.5
2+
faster-whisper==1.0.2
3+
pvporcupine==3.0.2
44
webrtcvad==2.0.10
55
halo==0.0.31
6-
torch==2.2.2
7-
torchaudio==2.2.2
8-
scipy==1.12.0
6+
torch==2.3.0
7+
torchaudio==2.3.0
8+
scipy==1.12.0
9+
websockets==v12.0

0 commit comments

Comments
 (0)