radames commited on
Commit
886d19b
1 Parent(s): 967ca9c

fixes for new dockerfile

Browse files
.dockerignore ADDED
@@ -0,0 +1 @@
 
 
1
+ seamless_server/models/*.pt
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  *.mp3 filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  *.mp3 filter=lfs diff=lfs merge=lfs -text
37
+ *.whl filter=lfs diff=lfs merge=lfs -text
.gitignore CHANGED
@@ -1,2 +1,5 @@
1
  .vscode/settings.json
2
  __pycache__/
 
 
 
 
1
  .vscode/settings.json
2
  __pycache__/
3
+ *.pt
4
+ *.model
5
+ venv/
Dockerfile CHANGED
@@ -1,7 +1,25 @@
1
- # TODO: This doesn't work, copied over from M4T but needs an update
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04
4
  ENV DEBIAN_FRONTEND=noninteractive
 
 
5
  RUN apt-get update && \
6
  apt-get upgrade -y && \
7
  apt-get install -y --no-install-recommends \
@@ -23,6 +41,7 @@ RUN apt-get update && \
23
  libxmlsec1-dev \
24
  libffi-dev \
25
  liblzma-dev \
 
26
  # gradio dependencies \
27
  ffmpeg \
28
  # fairseq2 dependencies \
@@ -33,30 +52,39 @@ RUN apt-get update && \
33
  RUN useradd -m -u 1000 user
34
  USER user
35
  ENV HOME=/home/user \
36
- PATH=/home/user/.local/bin:${PATH}
37
- WORKDIR ${HOME}/app
38
 
39
  RUN curl https://pyenv.run | bash
40
- ENV PATH=${HOME}/.pyenv/shims:${HOME}/.pyenv/bin:${PATH}
41
  ARG PYTHON_VERSION=3.10.12
42
- RUN pyenv install ${PYTHON_VERSION} && \
43
- pyenv global ${PYTHON_VERSION} && \
44
  pyenv rehash && \
45
  pip install --no-cache-dir -U pip setuptools wheel
46
 
47
- COPY --chown=1000 ./requirements.txt /tmp/requirements.txt
48
- RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt
49
-
50
- COPY --chown=1000 . ${HOME}/app
51
- ENV PYTHONPATH=${HOME}/app \
52
- PYTHONUNBUFFERED=1 \
53
- GRADIO_ALLOW_FLAGGING=never \
54
- GRADIO_NUM_PORTS=1 \
55
- GRADIO_SERVER_NAME=0.0.0.0 \
56
- GRADIO_THEME=huggingface \
57
- SYSTEM=spaces
58
-
59
- # gradio instead of python for reload on file save with mountin pwd volume:
60
- # docker run -p 7860:7860 -v $(pwd):/home/user/app seamless_m4t_text
61
- CMD ["gradio", "app.py"]
62
- # CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
1
+ # build frontend with node
2
+ FROM node:20-alpine AS frontend
3
+ RUN apk add --no-cache libc6-compat
4
+ WORKDIR /app
5
+
6
+ COPY streaming-react-app .
7
+ RUN \
8
+ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
9
+ elif [ -f package-lock.json ]; then npm ci; \
10
+ elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
11
+ else echo "Lockfile not found." && exit 1; \
12
+ fi
13
+
14
+ RUN npm run build
15
+
16
+ # build backend on CUDA
17
+ FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 AS backend
18
+ WORKDIR /app
19
 
 
20
  ENV DEBIAN_FRONTEND=noninteractive
21
+ ENV NODE_MAJOR=20
22
+
23
  RUN apt-get update && \
24
  apt-get upgrade -y && \
25
  apt-get install -y --no-install-recommends \
 
41
  libxmlsec1-dev \
42
  libffi-dev \
43
  liblzma-dev \
44
+ sox libsox-fmt-all \
45
  # gradio dependencies \
46
  ffmpeg \
47
  # fairseq2 dependencies \
 
52
  RUN useradd -m -u 1000 user
53
  USER user
54
  ENV HOME=/home/user \
55
+ PATH=/home/user/.local/bin:$PATH
56
+ WORKDIR $HOME/app
57
 
58
  RUN curl https://pyenv.run | bash
59
+ ENV PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH
60
  ARG PYTHON_VERSION=3.10.12
61
+ RUN pyenv install $PYTHON_VERSION && \
62
+ pyenv global $PYTHON_VERSION && \
63
  pyenv rehash && \
64
  pip install --no-cache-dir -U pip setuptools wheel
65
 
66
+ COPY --chown=user:user ./seamless_server ./seamless_server
67
+ # change dir since pip needs to seed whl folder
68
+ RUN cd seamless_server && pip install --no-cache-dir --upgrade -r requirements.txt
69
+ COPY --from=frontend /app/dist ./streaming-react-app/dist
70
+
71
+ WORKDIR $HOME/app/seamless_server
72
+ # temporary hack to link SeamlessStreaming models
73
+ ARG HF_TOKEN
74
+ RUN huggingface-cli download meta-private/SeamlessStreaming seamless_streaming_unity.pt spm_char_lang38_tc.model seamless_streaming_monotonic_decoder.pt --local-dir ./models/ && \
75
+ huggingface-cli download meta-private/SeamlessExpressive pretssel_melhifigan_wm-final.pt --local-dir ./models/
76
+ USER root
77
+ RUN mkdir -p /large_experiments/seamless/ust/krs/fairseq2_checkpoints/ && \
78
+ mkdir -p /large_experiments/seamless/workstream/expressivity/oss/checkpoints/ && \
79
+ mkdir -p /checkpoint/krs/unity2/ && \
80
+ chown -R user:user /large_experiments/ && \
81
+ chown -R user:user /checkpoint/ && \
82
+ ln -s $(readlink -f models/seamless_streaming_unity.pt) /large_experiments/seamless/ust/krs/fairseq2_checkpoints/seamless_streaming_unity.pt && \
83
+ ln -s $(readlink -f models/seamless_streaming_monotonic_decoder.pt) /large_experiments/seamless/ust/krs/fairseq2_checkpoints/seamless_streaming_monotonic_decoder.pt && \
84
+ ln -s $(readlink -f models/pretssel_melhifigan_wm-final.pt) /large_experiments/seamless/workstream/expressivity/oss/checkpoints/pretssel_melhifigan_wm-final.pt && \
85
+ ln -s $(readlink -f models/spm_char_lang38_tc.model) /checkpoint/krs/unity2/
86
+
87
+ USER user
88
+ CMD [ "uvicorn", "app_pubsub:app", "--host", "0.0.0.0", "--port", "7860" ]
89
+
90
+
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Seamless M4T
3
  emoji: 📞
4
  colorFrom: blue
5
  colorTo: yellow
 
1
  ---
2
+ title: Seamless Streaming Backend/Frontend
3
  emoji: 📞
4
  colorFrom: blue
5
  colorTo: yellow
seamless_server/app_pubsub.py CHANGED
@@ -12,6 +12,10 @@ import sys
12
  import time
13
  import random
14
  import string
 
 
 
 
15
 
16
  from src.room import Room, Member
17
  from src.simuleval_agent_directory import NoAvailableAgentException
@@ -86,7 +90,15 @@ sio = socketio.AsyncServer(
86
  # engineio_logger=logger,
87
  )
88
  # sio.logger.setLevel(logging.DEBUG)
89
- app = socketio.ASGIApp(sio, static_files=static_files)
 
 
 
 
 
 
 
 
90
 
91
  # rooms is indexed by room_id
92
  rooms: Dict[str, Room] = {}
 
12
  import time
13
  import random
14
  import string
15
+ from starlette.applications import Starlette
16
+ from starlette.routing import Mount, Route
17
+ from starlette.staticfiles import StaticFiles
18
+
19
 
20
  from src.room import Room, Member
21
  from src.simuleval_agent_directory import NoAvailableAgentException
 
90
  # engineio_logger=logger,
91
  )
92
  # sio.logger.setLevel(logging.DEBUG)
93
+ socketio_app = socketio.ASGIApp(sio)
94
+
95
+ app_routes = [
96
+ Mount("/ws", app=socketio_app), # Mount Socket.IO server under /app
97
+ Mount(
98
+ "/", app=StaticFiles(directory=CLIENT_BUILD_PATH, html=True)
99
+ ), # Serve static files from root
100
+ ]
101
+ app = Starlette(debug=True, routes=app_routes)
102
 
103
  # rooms is indexed by room_id
104
  rooms: Dict[str, Room] = {}
seamless_server/requirements.txt CHANGED
@@ -1,5 +1,7 @@
1
- # fairseq2
 
2
  # seamless_communication
 
3
  Flask==2.1.3
4
  Flask_Sockets==0.2.1
5
  g2p_en==2.1.0
@@ -12,7 +14,7 @@ protobuf==4.24.2
12
  psola==0.0.1
13
  pydub==0.25.1
14
  silero==0.4.1
15
- simuleval==1.1.1
16
  soundfile==0.11.0
17
  stable_ts==1.4.0
18
  torch # specific torch version depends on fairseq2 installation
@@ -23,3 +25,6 @@ python-socketio==5.9.0
23
  uvicorn[standard]==0.23.2
24
  parallel-wavegan==0.5.5
25
  python-jose[cryptography]==3.3.0
 
 
 
 
1
+ --pre --extra-index-url https://fair.pkg.atmeta.com/fairseq2/whl/nightly/pt2.1.1/cu118
2
+ git+https://github.com/facebookresearch/SimulEval.git
3
  # seamless_communication
4
+ ./whl/seamless_communication-1.0.0-py3-none-any.whl
5
  Flask==2.1.3
6
  Flask_Sockets==0.2.1
7
  g2p_en==2.1.0
 
14
  psola==0.0.1
15
  pydub==0.25.1
16
  silero==0.4.1
17
+ # simuleval==1.1.1
18
  soundfile==0.11.0
19
  stable_ts==1.4.0
20
  torch # specific torch version depends on fairseq2 installation
 
25
  uvicorn[standard]==0.23.2
26
  parallel-wavegan==0.5.5
27
  python-jose[cryptography]==3.3.0
28
+ starlette==0.32.0.post1
29
+ hf_transfer==0.1.4
30
+ huggingface_hub==0.19.4
seamless_server/whl/seamless_communication-1.0.0-py3-none-any.whl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3380dc7d6613c4dc9ef4d78fd3dcf1a50f7c6a659b8ba0b37ad5237533d002e
3
+ size 234811
streaming-react-app/src/SocketWrapper.tsx CHANGED
@@ -11,8 +11,9 @@ import {getURLParams} from './URLParams';
11
 
12
  // The time to wait before showing a "disconnected" screen upon initial app load
13
  const INITIAL_DISCONNECT_SCREEN_DELAY = 2000;
14
- const SERVER_URL_DEFAULT = "localhost:8000"
15
-
 
16
  export default function SocketWrapper({children}) {
17
  const [socket, setSocket] = useState<Socket | null>(null);
18
  const [connected, setConnected] = useState<boolean | null>(null);
@@ -63,6 +64,7 @@ export default function SocketWrapper({children}) {
63
  // want that because that'd mean awful performance. It'd be better for the app
64
  // to simply break in that case and not connect.
65
  transports: ['websocket'],
 
66
  });
67
 
68
  const onServerID = (serverID: string) => {
 
11
 
12
  // The time to wait before showing a "disconnected" screen upon initial app load
13
  const INITIAL_DISCONNECT_SCREEN_DELAY = 2000;
14
+ const SERVER_URL_DEFAULT = `${window.location.protocol === "https:" ? "wss" : "ws"
15
+ }://${window.location.host}`;
16
+
17
  export default function SocketWrapper({children}) {
18
  const [socket, setSocket] = useState<Socket | null>(null);
19
  const [connected, setConnected] = useState<boolean | null>(null);
 
64
  // want that because that'd mean awful performance. It'd be better for the app
65
  // to simply break in that case and not connect.
66
  transports: ['websocket'],
67
+ path: '/ws/socket.io'
68
  });
69
 
70
  const onServerID = (serverID: string) => {
streaming-react-app/vite.config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {defineConfig} from 'vite';
2
  import react from '@vitejs/plugin-react';
3
  // import {resolve} from 'path';
4
 
@@ -7,10 +7,18 @@ import react from '@vitejs/plugin-react';
7
  // const typesDir = resolve(__dirname, 'types');
8
 
9
  // https://vitejs.dev/config/
10
- export default defineConfig(({command}) => {
11
  let define = {};
12
  return {
13
  plugins: [react()],
14
  define: define,
15
- };
 
 
 
 
 
 
 
 
16
  });
 
1
+ import { defineConfig } from 'vite';
2
  import react from '@vitejs/plugin-react';
3
  // import {resolve} from 'path';
4
 
 
7
  // const typesDir = resolve(__dirname, 'types');
8
 
9
  // https://vitejs.dev/config/
10
+ export default defineConfig(({ command }) => {
11
  let define = {};
12
  return {
13
  plugins: [react()],
14
  define: define,
15
+ server: {
16
+ proxy: {
17
+ '/ws': {
18
+ target: 'ws://localhost:7860',
19
+ ws: true
20
+ }
21
+ },
22
+ },
23
+ }
24
  });