commit
b0fe4b51cd
@ -0,0 +1,3 @@
|
||||
/chat
|
||||
/models
|
||||
/ollama
|
@ -0,0 +1,79 @@
|
||||
FROM nvidia/cuda:12.6.1-cudnn-runtime-ubuntu24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##
|
||||
## User.
|
||||
##
|
||||
|
||||
RUN apt update && apt install -y sudo
|
||||
|
||||
RUN groupadd -r user
|
||||
RUN useradd -r -g user -m -s /bin/bash user
|
||||
RUN usermod -aG sudo user
|
||||
|
||||
RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ENV USER=user
|
||||
|
||||
##
|
||||
## Time zone.
|
||||
##
|
||||
|
||||
ENV TZ=Europe/Moscow
|
||||
|
||||
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
RUN echo $TZ | sudo tee /etc/timezone
|
||||
|
||||
##
|
||||
## RealTimeSTT.
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y python3
|
||||
RUN sudo apt update && sudo apt install -y python3-pip
|
||||
RUN sudo apt update && sudo apt install -y python3-venv
|
||||
RUN sudo apt update && sudo apt install -y portaudio19-dev
|
||||
RUN sudo apt update && sudo apt install -y ffmpeg
|
||||
|
||||
RUN python3 -m venv venv
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install RealtimeSTT==0.3.7"
|
||||
RUN bash -c "source venv/bin/activate && pip install torch==2.3.1+cu121 --index-url https://download.pytorch.org/whl/cu121"
|
||||
RUN bash -c "source venv/bin/activate && pip install torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121"
|
||||
|
||||
# Replace `localhost` with `0.0.0.0` in STT server.
|
||||
RUN bash -c "source venv/bin/activate && \
|
||||
cd ~/venv/lib/python3.12/site-packages/RealtimeSTT_server && \
|
||||
find . -type f -exec sed -i.backup "s/localhost/0\.0\.0\.0/g" {} \;"
|
||||
|
||||
##
|
||||
## LLM.
|
||||
##
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install llama-index==0.11.23"
|
||||
RUN bash -c "source venv/bin/activate && pip install llama-index-llms-ollama==0.3.6"
|
||||
|
||||
##
|
||||
## RealTimeTTS.
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y espeak # System TTS for TTS server.
|
||||
RUN sudo apt update && sudo apt install -y git
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install 'RealTimeTTS[all]==0.4.10'"
|
||||
RUN bash -c "source venv/bin/activate && pip install fastapi==0.115.5" # For TTS server.
|
||||
RUN bash -c "source venv/bin/activate && pip install uvicorn==0.32.0" # For TTS server.
|
||||
|
||||
RUN git clone https://github.com/KoljaB/RealtimeTTS && \
|
||||
cd RealtimeTTS && \
|
||||
git reset --hard b2fab8b57717d2a14501923e9cf2b5589944b9ca
|
||||
|
||||
# Replace.
|
||||
RUN bash -c "source venv/bin/activate && \
|
||||
cd RealtimeTTS/example_fast_api && \
|
||||
sed -i.backup \"s/START_ENGINE = SUPPORTED_ENGINES\[0\]/START_ENGINE = 'coqui'/g\" server.py"
|
||||
|
@ -0,0 +1,87 @@
|
||||
import threading
|
||||
import socket
|
||||
import pyaudio
|
||||
import time
|
||||
|
||||
# Server settings
|
||||
SERVER_IP = '81.94.159.212' # Replace with your server's IP address
|
||||
DATA_SERVER_PORT = 8012
|
||||
AUDIO_SERVER_PORT = 65432
|
||||
|
||||
# Audio settings
|
||||
FORMAT = pyaudio.paInt16
|
||||
CHANNELS = 1
|
||||
RATE = 16000 # Should match the server's expected sample rate
|
||||
CHUNK = 1024
|
||||
|
||||
audio = pyaudio.PyAudio()
|
||||
|
||||
def record_and_send_audio():
|
||||
while True:
|
||||
try:
|
||||
# Connect to the server to send audio data
|
||||
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client_socket.connect((SERVER_IP, DATA_SERVER_PORT))
|
||||
print("Connected to data server")
|
||||
|
||||
# Initialize PyAudio for recording
|
||||
stream = audio.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
|
||||
|
||||
while True:
|
||||
# Read audio data from the microphone
|
||||
data = stream.read(CHUNK)
|
||||
client_socket.sendall(data)
|
||||
except Exception as e:
|
||||
print(f"Error sending audio: {e}")
|
||||
time.sleep(1) # Wait before retrying
|
||||
finally:
|
||||
# Clean up resources
|
||||
if 'stream' in locals():
|
||||
stream.stop_stream()
|
||||
stream.close()
|
||||
if 'client_socket' in locals():
|
||||
client_socket.close()
|
||||
|
||||
def receive_and_play_audio():
|
||||
while True:
|
||||
try:
|
||||
# Connect to the server to receive audio data
|
||||
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client_socket.connect((SERVER_IP, AUDIO_SERVER_PORT))
|
||||
print("Connected to audio server")
|
||||
|
||||
# Initialize PyAudio for playback
|
||||
TTS_SAMPLE_RATE = 24000 # Should match the TTS sample rate used on the server
|
||||
stream = audio.open(format=FORMAT, channels=CHANNELS, rate=TTS_SAMPLE_RATE, output=True)
|
||||
|
||||
while True:
|
||||
# Receive audio data from the server
|
||||
data = client_socket.recv(CHUNK)
|
||||
if not data:
|
||||
raise ConnectionError("Audio server disconnected")
|
||||
# Play the audio data
|
||||
stream.write(data)
|
||||
except Exception as e:
|
||||
print(f"Error receiving audio: {e}")
|
||||
time.sleep(1) # Wait before retrying
|
||||
finally:
|
||||
# Clean up resources
|
||||
if 'stream' in locals():
|
||||
stream.stop_stream()
|
||||
stream.close()
|
||||
if 'client_socket' in locals():
|
||||
client_socket.close()
|
||||
|
||||
def main():
|
||||
# Start the thread to receive and play audio
|
||||
audio_thread = threading.Thread(target=receive_and_play_audio, daemon=True)
|
||||
audio_thread.start()
|
||||
|
||||
# Start recording and sending audio
|
||||
while True:
|
||||
record_and_send_audio()
|
||||
print("Reconnecting to data server...")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,62 @@
|
||||
services:
|
||||
ai:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8012:8012" # STT server data.
|
||||
- "65432:65432" # TTS client server.
|
||||
volumes:
|
||||
- .:/app
|
||||
- ./models:/home/user/models
|
||||
- ./chat:/home/user/chat
|
||||
depends_on:
|
||||
- ollama
|
||||
command: ["bash", "-c", "
|
||||
sudo chown user:user -R /home/user/models && \
|
||||
sudo chown user:user -R /home/user/chat && \
|
||||
source venv/bin/activate && \
|
||||
python /app/server.py \
|
||||
"]
|
||||
stdin_open: true
|
||||
tty: true
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
ollama:
|
||||
volumes:
|
||||
- ./ollama/ollama:/root/.ollama
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- 7869:11434
|
||||
environment:
|
||||
- OLLAMA_KEEP_ALIVE=24h
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
ollama-webui:
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
volumes:
|
||||
- ./ollama/ollama-webui:/app/backend/data
|
||||
depends_on:
|
||||
- ollama
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
- OLLAMA_BASE_URLS=http://host.docker.internal:7869
|
||||
- ENV=dev
|
||||
- WEBUI_AUTH=False
|
||||
- WEBUI_NAME=WebUI
|
||||
- WEBUI_URL=http://localhost:8080
|
||||
- WEBUI_SECRET_KEY=t0p-s3cr3t
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
|
@ -0,0 +1,47 @@
|
||||
FROM ubuntu:24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##
|
||||
## User.
|
||||
##
|
||||
|
||||
RUN apt update && apt install -y sudo
|
||||
|
||||
RUN groupadd -r user
|
||||
RUN useradd -r -g user -m -s /bin/bash user
|
||||
RUN usermod -aG sudo user
|
||||
|
||||
RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ENV USER=user
|
||||
|
||||
##
|
||||
## Time zone.
|
||||
##
|
||||
|
||||
ENV TZ=Europe/Moscow
|
||||
|
||||
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
RUN echo $TZ | sudo tee /etc/timezone
|
||||
|
||||
##
|
||||
## ...
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y python3
|
||||
RUN sudo apt update && sudo apt install -y python3-pip
|
||||
RUN sudo apt update && sudo apt install -y python3-venv
|
||||
RUN sudo apt update && sudo apt install -y portaudio19-dev
|
||||
|
||||
RUN python3 -m venv venv
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install llama-index==0.11.23"
|
||||
RUN bash -c "source venv/bin/activate && pip install llama-index-llms-ollama==0.3.6"
|
||||
RUN bash -c "source venv/bin/activate && pip install websocket-client==1.8.0"
|
||||
RUN bash -c "source venv/bin/activate && pip install websockets==14.1"
|
||||
|
@ -0,0 +1,79 @@
|
||||
FROM ubuntu:24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##
|
||||
## User.
|
||||
##
|
||||
|
||||
RUN apt update && apt install -y sudo
|
||||
|
||||
RUN groupadd -r user
|
||||
RUN useradd -r -g user -m -s /bin/bash user
|
||||
RUN usermod -aG sudo user
|
||||
|
||||
RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ENV USER=user
|
||||
|
||||
##
|
||||
## Time zone.
|
||||
##
|
||||
|
||||
ENV TZ=Europe/Moscow
|
||||
|
||||
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
RUN echo $TZ | sudo tee /etc/timezone
|
||||
|
||||
##
|
||||
## RealTimeSTT.
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y python3
|
||||
RUN sudo apt update && sudo apt install -y python3-pip
|
||||
RUN sudo apt update && sudo apt install -y python3-venv
|
||||
RUN sudo apt update && sudo apt install -y portaudio19-dev
|
||||
RUN sudo apt update && sudo apt install -y ffmpeg
|
||||
|
||||
RUN python3 -m venv venv
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install RealtimeSTT==0.3.7"
|
||||
RUN bash -c "source venv/bin/activate && pip install torch==2.3.1+cu121 --index-url https://download.pytorch.org/whl/cu121"
|
||||
RUN bash -c "source venv/bin/activate && pip install torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121"
|
||||
|
||||
# Replace `localhost` with `0.0.0.0` in STT server.
|
||||
RUN bash -c "source venv/bin/activate && \
|
||||
cd ~/venv/lib/python3.12/site-packages/RealtimeSTT_server && \
|
||||
find . -type f -exec sed -i.backup "s/localhost/0\.0\.0\.0/g" {} \;"
|
||||
|
||||
##
|
||||
## LLM.
|
||||
##
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install llama-index==0.11.23"
|
||||
RUN bash -c "source venv/bin/activate && pip install llama-index-llms-ollama==0.3.6"
|
||||
|
||||
##
|
||||
## RealTimeTTS.
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y espeak # System TTS for TTS server.
|
||||
RUN sudo apt update && sudo apt install -y git
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install 'RealTimeTTS[all]==0.4.10'"
|
||||
RUN bash -c "source venv/bin/activate && pip install fastapi==0.115.5" # For TTS server.
|
||||
RUN bash -c "source venv/bin/activate && pip install uvicorn==0.32.0" # For TTS server.
|
||||
|
||||
RUN git clone https://github.com/KoljaB/RealtimeTTS && \
|
||||
cd RealtimeTTS && \
|
||||
git reset --hard b2fab8b57717d2a14501923e9cf2b5589944b9ca
|
||||
|
||||
# Replace.
|
||||
RUN bash -c "source venv/bin/activate && \
|
||||
cd RealtimeTTS/example_fast_api && \
|
||||
sed -i.backup \"s/START_ENGINE = SUPPORTED_ENGINES\[0\]/START_ENGINE = 'coqui'/g\" server.py"
|
||||
|
@ -0,0 +1,56 @@
|
||||
FROM ubuntu:24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##
|
||||
## User.
|
||||
##
|
||||
|
||||
RUN apt update && apt install -y sudo
|
||||
|
||||
RUN groupadd -r user
|
||||
RUN useradd -r -g user -m -s /bin/bash user
|
||||
RUN usermod -aG sudo user
|
||||
|
||||
RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ENV USER=user
|
||||
|
||||
##
|
||||
## Time zone.
|
||||
##
|
||||
|
||||
ENV TZ=Europe/Moscow
|
||||
|
||||
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
RUN echo $TZ | sudo tee /etc/timezone
|
||||
|
||||
##
|
||||
## RealTimeSTT.
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y python3
|
||||
RUN sudo apt update && sudo apt install -y python3-pip
|
||||
RUN sudo apt update && sudo apt install -y python3-venv
|
||||
RUN sudo apt update && sudo apt install -y portaudio19-dev
|
||||
RUN sudo apt update && sudo apt install -y ffmpeg
|
||||
|
||||
RUN python3 -m venv venv
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install RealtimeSTT==0.3.7"
|
||||
RUN bash -c "source venv/bin/activate && pip install torch==2.3.1+cu121 --index-url https://download.pytorch.org/whl/cu121"
|
||||
RUN bash -c "source venv/bin/activate && pip install torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121"
|
||||
|
||||
##
|
||||
## Replace `localhost` with `0.0.0.0` in STT server.
|
||||
##
|
||||
|
||||
RUN bash -c "source venv/bin/activate && \
|
||||
cd ~/venv/lib/python3.12/site-packages/RealtimeSTT_server && \
|
||||
find . -type f -exec sed -i.backup "s/localhost/0\.0\.0\.0/g" {} \;"
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
FROM ubuntu:24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##
|
||||
## User.
|
||||
##
|
||||
|
||||
RUN apt update && apt install -y sudo
|
||||
|
||||
RUN groupadd -r user
|
||||
RUN useradd -r -g user -m -s /bin/bash user
|
||||
RUN usermod -aG sudo user
|
||||
|
||||
RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ENV USER=user
|
||||
|
||||
##
|
||||
## Time zone.
|
||||
##
|
||||
|
||||
ENV TZ=Europe/Moscow
|
||||
|
||||
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
RUN echo $TZ | sudo tee /etc/timezone
|
||||
|
||||
##
|
||||
## RealTimeTTS.
|
||||
##
|
||||
|
||||
RUN sudo apt update && sudo apt install -y python3
|
||||
RUN sudo apt update && sudo apt install -y python3-pip
|
||||
RUN sudo apt update && sudo apt install -y python3-venv
|
||||
RUN sudo apt update && sudo apt install -y portaudio19-dev
|
||||
RUN sudo apt update && sudo apt install -y ffmpeg
|
||||
RUN sudo apt update && sudo apt install -y espeak # System TTS for TTS server.
|
||||
RUN sudo apt update && sudo apt install -y git
|
||||
|
||||
RUN python3 -m venv venv
|
||||
|
||||
RUN bash -c "source venv/bin/activate && pip install 'RealTimeTTS[all]==0.4.10'"
|
||||
RUN bash -c "source venv/bin/activate && pip install torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121"
|
||||
RUN bash -c "source venv/bin/activate && pip install torch==2.3.1+cu121 --index-url https://download.pytorch.org/whl/cu121"
|
||||
RUN bash -c "source venv/bin/activate && pip install fastapi==0.115.5" # For TTS server.
|
||||
RUN bash -c "source venv/bin/activate && pip install uvicorn==0.32.0" # For TTS server.
|
||||
|
||||
RUN git clone --depth 1 https://github.com/KoljaB/RealtimeTTS && \
|
||||
cd RealtimeTTS && \
|
||||
git reset --hard b2fab8b57717d2a14501923e9cf2b5589944b9ca
|
||||
|
||||
##
|
||||
## Replaces.
|
||||
##
|
||||
|
||||
RUN bash -c "source venv/bin/activate && \
|
||||
cd RealtimeTTS/example_fast_api && \
|
||||
sed -i.backup \"s/START_ENGINE = SUPPORTED_ENGINES\[0\]/START_ENGINE = 'coqui'/g\" server.py"
|
||||
|
@ -0,0 +1,85 @@
|
||||
services:
|
||||
tts:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: TTS.dockerfile
|
||||
ports:
|
||||
- "8000:8000" # TTS server.
|
||||
command: ["bash", "-c", "source venv/bin/activate && cd RealtimeTTS/example_fast_api && python server.py"]
|
||||
env_file: .env
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
stt:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: STT.dockerfile
|
||||
ports:
|
||||
- "8011:8011" # STT server control.
|
||||
- "8012:8012" # STT server data.
|
||||
command: ["bash", "-c", "source venv/bin/activate && stt-server --silero_deactivity_detection"]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
llm:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: LLM.dockerfile
|
||||
ports:
|
||||
- "8013:8012" # STT server data.
|
||||
- "65432:65432" # TTS client server.
|
||||
volumes:
|
||||
- .:/app
|
||||
command: ["bash", "-c", "source venv/bin/activate && python /app/main.py"]
|
||||
depends_on:
|
||||
- tts
|
||||
- stt
|
||||
- ollama
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
ollama:
|
||||
volumes:
|
||||
- ./ollama/ollama:/root/.ollama
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- 7869:11434
|
||||
environment:
|
||||
- OLLAMA_KEEP_ALIVE=24h
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
ollama-webui:
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
volumes:
|
||||
- ./ollama/ollama-webui:/app/backend/data
|
||||
depends_on:
|
||||
- ollama
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
- OLLAMA_BASE_URLS=http://host.docker.internal:7869
|
||||
- ENV=dev
|
||||
- WEBUI_AUTH=False
|
||||
- WEBUI_NAME=WebUI
|
||||
- WEBUI_URL=http://localhost:8080
|
||||
- WEBUI_SECRET_KEY=t0p-s3cr3t
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
|
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
|
||||
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
|
||||
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
|
||||
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
|
||||
|
||||
sudo apt update
|
||||
|
||||
sudo apt install -y nvidia-container-toolkit
|
||||
|
||||
sudo nvidia-ctk runtime configure --runtime=docker
|
||||
|
||||
sudo systemctl restart docker
|
||||
|
Loading…
Reference in new issue