ferrazzipietro commited on
Commit
73cbe81
·
1 Parent(s): 8a8c049

-refactor room

Browse files
Dockerfile CHANGED
@@ -3,8 +3,6 @@ FROM node:20-alpine AS frontend
3
  RUN apk add --no-cache libc6-compat
4
  WORKDIR /app
5
 
6
- ARG DUMMY_ARG=1
7
-
8
  COPY streaming-react-app .
9
  RUN \
10
  if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
@@ -47,55 +45,21 @@ RUN apt-get update && \
47
  # gradio dependencies \
48
  ffmpeg \
49
  # fairseq2 dependencies \
 
 
50
  libsndfile-dev && \
51
  apt-get clean && \
52
  rm -rf /var/lib/apt/lists/*
53
 
54
-
55
- # RUN apt-get install zlib1g-dev &&\
56
- # wget https://sourceforge.net/projects/libpng/files/libpng15/1.5.30/libpng-1.5.30.tar.gz &&\
57
- # tar -xzvf libpng-1.5.30.tar.gz &&\
58
- # cd libpng-1.5.30 &&\
59
- # ./configure --prefix=/usr/local/libpng &&\
60
- # make &&\
61
- # make install &&\
62
- # echo "Contents of /usr/local/lib:" && ls /usr/local/lib && \
63
- # echo "Contents of /usr/local/libpng/lib:" && ls /usr/local/libpng/lib && \
64
- # # ls /usr/local/lib/libpng* &&\
65
- # ldconfig &&\
66
- # cd ..
67
- # ENV LD_LIBRARY_PATH=/usr/local/libpng/lib:
68
-
69
- # RUN wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz &&\
70
- # tar -xzvf jpegsrc.v9a.tar.gz &&\
71
- # cd jpeg-9a &&\
72
- # ./configure --prefix=/usr/local/libjpeg &&\
73
- # make &&\
74
- # make install
75
- # RUN cd .. &&\
76
- # echo "Contents of /usr/local/lib :" && ls /usr/local && \
77
- # echo "Contents of /usr/local/libjpeg/lib :" && ls /usr/local/libjpeg/lib && \
78
- # ls /usr/local/lib/libpng* &&\
79
- # ldconfig
80
- # # ENV LD_LIBRARY_PATH=/usr/local/libpng/lib:
81
-
82
- # RUN wget libjpeg62-turbo_2.0.6-4_amd64.deb &&\
83
- # tar -xzvf jpegsrc.v9a.tar.gz &&\
84
- # cd jpeg-9a &&\
85
- # ./configure --prefix=/usr/local/libjpeg &&\
86
- # make &&\
87
- # make install
88
- # RUN cd .. &&\
89
- # echo "Contents of /usr/local/lib :" && ls /usr/local && \
90
- # echo "Contents of /usr/local/libjpeg/lib :" && ls /usr/local/libjpeg/lib && \
91
- # ls /usr/local/lib/libpng* &&\
92
- # ldconfig
93
- # ENV LD_LIBRARY_PATH=/usr/local/libpng/lib:
94
-
95
- # RUN apt-get update &&\
96
- # apt-get -y install libjpeg62-turbo-dev &&\
97
- # apt-get install libjpeg8 libbodfile1
98
-
99
  RUN useradd -m -u 1000 user
100
  USER user
101
  ENV HOME=/home/user \
@@ -113,8 +77,7 @@ RUN pyenv install $PYTHON_VERSION && \
113
  COPY --chown=user:user ./seamless_server ./seamless_server
114
  # change dir since pip needs to seed whl folder
115
  RUN cd seamless_server && \
116
- pip install fairseq2 &&\
117
- # pip install fairseq2 --pre --extra-index-url https://fair.pkg.atmeta.com/fairseq2/whl/nightly/pt2.1.1/cu118 && \
118
  pip install --no-cache-dir --upgrade -r requirements.txt
119
  COPY --from=frontend /app/dist ./streaming-react-app/dist
120
 
@@ -124,10 +87,7 @@ RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=false \
124
  huggingface-cli download meta-private/SeamlessExpressive pretssel_melhifigan_wm-final.pt --local-dir ./models/Seamless/ || echo "HF_TOKEN error" && \
125
  ln -s $(readlink -f models/Seamless/pretssel_melhifigan_wm-final.pt) models/Seamless/pretssel_melhifigan_wm.pt || true;
126
 
127
- USER root
128
- RUN ln -s /usr/lib/x86_64-linux-gnu/libsox.so.3 /usr/lib/x86_64-linux-gnu/libsox.so
129
  USER user
130
  RUN ["chmod", "+x", "./run_docker.sh"]
131
  CMD ./run_docker.sh
132
 
133
-
 
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; \
 
45
  # gradio dependencies \
46
  ffmpeg \
47
  # fairseq2 dependencies \
48
+ libjpeg8-dev \
49
+ libpng-dev \
50
  libsndfile-dev && \
51
  apt-get clean && \
52
  rm -rf /var/lib/apt/lists/*
53
 
54
+ USER root
55
+ RUN ln -s /usr/lib/x86_64-linux-gnu/libsox.so.3 /usr/lib/x86_64-linux-gnu/libsox.so
56
+ # install older versions libjpeg62-turbo and libpng15
57
+ RUN wget http://ftp.us.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_2.1.5-2_amd64.deb && \
58
+ dpkg -i libjpeg62-turbo_2.1.5-2_amd64.deb && \
59
+ rm libjpeg62-turbo_2.1.5-2_amd64.deb
60
+ RUN wget https://master.dl.sourceforge.net/project/libpng/libpng15/1.5.30/libpng-1.5.30.tar.gz && \
61
+ tar -xvf libpng-1.5.30.tar.gz && cd libpng-1.5.30 && ./configure && make && make install && cd .. && rm -rf libpng-1.5.30.tar.gz libpng-1.5.30
62
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  RUN useradd -m -u 1000 user
64
  USER user
65
  ENV HOME=/home/user \
 
77
  COPY --chown=user:user ./seamless_server ./seamless_server
78
  # change dir since pip needs to seed whl folder
79
  RUN cd seamless_server && \
80
+ pip install fairseq2 --pre --extra-index-url https://fair.pkg.atmeta.com/fairseq2/whl/nightly/pt2.1.1/cu118 && \
 
81
  pip install --no-cache-dir --upgrade -r requirements.txt
82
  COPY --from=frontend /app/dist ./streaming-react-app/dist
83
 
 
87
  huggingface-cli download meta-private/SeamlessExpressive pretssel_melhifigan_wm-final.pt --local-dir ./models/Seamless/ || echo "HF_TOKEN error" && \
88
  ln -s $(readlink -f models/Seamless/pretssel_melhifigan_wm-final.pt) models/Seamless/pretssel_melhifigan_wm.pt || true;
89
 
 
 
90
  USER user
91
  RUN ["chmod", "+x", "./run_docker.sh"]
92
  CMD ./run_docker.sh
93
 
 
README.md CHANGED
@@ -10,10 +10,6 @@ models:
10
  - facebook/seamless-streaming
11
  ---
12
 
13
- # RESOURCES AWS
14
- I use a g4 machine with 35GB of volume. You could delete the volume and create a new one and connect it to the instance when needed. Obv you'd need to re-pull the docker image.
15
- The same is true for the elastic IP. Both the volume and the elastic IP costs me ~0.10$ per day, for an overall of ~0.22$. It does not make sense to keep them if you don't need to use it for a couple of months.
16
-
17
  # Seamless Streaming demo
18
  ## Running on HF spaces
19
  You can simply duplicate the space to run it.
@@ -71,4 +67,4 @@ To enable additional logging from uvicorn pass `--log-level debug` or `--log-lev
71
 
72
  ### Debuging
73
 
74
- If you enable "Server Debug Flag" when starting streaming from the client, this enables extensive debug logging and it saves audio files in /debug folder.
 
10
  - facebook/seamless-streaming
11
  ---
12
 
 
 
 
 
13
  # Seamless Streaming demo
14
  ## Running on HF spaces
15
  You can simply duplicate the space to run it.
 
67
 
68
  ### Debuging
69
 
70
+ If you enable "Server Debug Flag" when starting streaming from the client, this enables extensive debug logging and it saves audio files in /debug folder.
seamless_server/.DS_Store CHANGED
Binary files a/seamless_server/.DS_Store and b/seamless_server/.DS_Store differ
 
seamless_server/models/.DS_Store CHANGED
Binary files a/seamless_server/models/.DS_Store and b/seamless_server/models/.DS_Store differ
 
seamless_server/src/simuleval_transcoder.py CHANGED
@@ -19,8 +19,6 @@ import traceback
19
  import time
20
  import random
21
  import colorlog
22
- import nltk
23
- nltk.download('averaged_perceptron_tagger_eng')
24
 
25
  from .speech_and_text_output import SpeechAndTextOutput
26
 
 
19
  import time
20
  import random
21
  import colorlog
 
 
22
 
23
  from .speech_and_text_output import SpeechAndTextOutput
24
 
seamless_server/whl/seamless_communication-1.0.0-py3-none-any.whl ADDED
Binary file (204 kB). View file
 
streaming-react-app/src/RoomConfig.tsx CHANGED
@@ -87,7 +87,6 @@ export default function RoomConfig({
87
  'join_room',
88
  clientID,
89
  createNewRoom ? null : roomID,
90
- true,
91
  configObject,
92
  (result) => {
93
  console.log('join_room result:', result);
@@ -151,7 +150,7 @@ export default function RoomConfig({
151
  return (
152
  <Stack direction="column" spacing="12px">
153
  <Stack direction="row" spacing="12px" sx={{alignItems: 'center'}}>
154
- {/* <TextField
155
  size="small"
156
  label="Room Code"
157
  variant="outlined"
@@ -168,9 +167,9 @@ export default function RoomConfig({
168
  }
169
  }}
170
  sx={{width: '8em'}}
171
- /> */}
172
 
173
- {/* <div>
174
  <Button
175
  variant="contained"
176
  disabled={
@@ -181,7 +180,7 @@ export default function RoomConfig({
181
  onClick={() => onJoinRoom(false)}>
182
  {roomState?.room_id != null ? 'Update Roles' : 'Join Room'}
183
  </Button>
184
- </div> */}
185
 
186
  {roomState?.room_id == null && (
187
  <div>
@@ -193,7 +192,7 @@ export default function RoomConfig({
193
  streamingStatus !== 'stopped'
194
  }
195
  onClick={() => onJoinRoom(true)}>
196
- {'Start translating'}
197
  </Button>
198
  </div>
199
  )}
 
87
  'join_room',
88
  clientID,
89
  createNewRoom ? null : roomID,
 
90
  configObject,
91
  (result) => {
92
  console.log('join_room result:', result);
 
150
  return (
151
  <Stack direction="column" spacing="12px">
152
  <Stack direction="row" spacing="12px" sx={{alignItems: 'center'}}>
153
+ <TextField
154
  size="small"
155
  label="Room Code"
156
  variant="outlined"
 
167
  }
168
  }}
169
  sx={{width: '8em'}}
170
+ />
171
 
172
+ <div>
173
  <Button
174
  variant="contained"
175
  disabled={
 
180
  onClick={() => onJoinRoom(false)}>
181
  {roomState?.room_id != null ? 'Update Roles' : 'Join Room'}
182
  </Button>
183
+ </div>
184
 
185
  {roomState?.room_id == null && (
186
  <div>
 
192
  streamingStatus !== 'stopped'
193
  }
194
  onClick={() => onJoinRoom(true)}>
195
+ {'Create New Room'}
196
  </Button>
197
  </div>
198
  )}
streaming-react-app/src/StreamingInterface.tsx CHANGED
@@ -6,7 +6,7 @@ import FormControl from '@mui/material/FormControl';
6
  import Select, {SelectChangeEvent} from '@mui/material/Select';
7
  import MenuItem from '@mui/material/MenuItem';
8
  import Stack from '@mui/material/Stack';
9
- import seamlessLogoUrl from './assets/illy.svg';
10
  import {
11
  AgentCapabilities,
12
  BaseResponse,
@@ -744,44 +744,42 @@ export default function StreamingInterface() {
744
  src={seamlessLogoUrl}
745
  className="header-icon-sra"
746
  alt="Seamless Translation Logo"
747
- height={150}
748
- width={225}
749
  />
750
 
751
  <div>
752
- <Typography variant="h1" sx={{color: '#800020'}}>
753
- Illy's translator
754
- </Typography>
755
- <Typography variant="body2" sx={{color: '#800020'}}>
756
- <span style={{ fontStyle: 'italic' }}>
757
- Natale 2023
758
- </span>
759
  </Typography>
760
  </div>
761
  </div>
762
  <div className="header-container-sra">
763
  <div>
764
  <Typography variant="body2" sx={{color: '#65676B'}}>
765
- Hey <strong style={{ fontWeight: 'bold' }}>Illy</strong>, <strong style={{ fontWeight: 'bold' }}>it's lovely to see you!</strong>
766
- <br/>
767
- You can use this platform to translate from/to Italian and many some other languages.
768
- <br/>
769
  Use headphones if you are both speaker and listener to prevent feedback.
770
  <br/>
 
 
 
771
  <br/>
772
- <a target="_blank" rel="noopener noreferrer" href="https://ai.meta.com/research/seamless-communication/">SeamlessStreaming</a> is
773
- a research model and streaming quality works best if you pause
774
- every couple of sentences. The real-time performance will degrade
775
- if you try streaming multiple speakers at the same time.
776
- <br/>
777
  <br/>
778
- Let's try!
 
 
 
 
 
779
  </Typography>
780
  </div>
781
  </div>
782
  <Stack spacing="22px" direction="column">
783
  <Box>
784
- { <RoomConfig
785
  roomState={roomState}
786
  serverState={serverState}
787
  streamingStatus={streamingStatus}
@@ -790,7 +788,7 @@ export default function StreamingInterface() {
790
  // player to play eagerly, since currently the listener doesn't have any stop/start controls
791
  bufferedSpeechPlayer.start();
792
  }}
793
- /> }
794
 
795
  {isListener && !isSpeaker && (
796
  <Box
@@ -812,9 +810,9 @@ export default function StreamingInterface() {
812
  <Divider />
813
 
814
  <Stack spacing="12px" direction="column">
815
- {/* <FormLabel id="output-modes-radio-group-label">
816
  Model
817
- </FormLabel> */}
818
  <FormControl
819
  disabled={
820
  streamFixedConfigOptionsDisabled ||
@@ -822,10 +820,10 @@ export default function StreamingInterface() {
822
  }
823
  fullWidth
824
  sx={{minWidth: '14em'}}>
825
- {/* <InputLabel id="model-selector-input-label">
826
  Model
827
- </InputLabel> */}
828
- {/* <Select
829
  labelId="model-selector-input-label"
830
  label="Model"
831
  onChange={(e: SelectChangeEvent) => {
@@ -847,14 +845,14 @@ export default function StreamingInterface() {
847
  {agent.name}
848
  </MenuItem>
849
  ))}
850
- </Select> */}
851
  </FormControl>
852
 
853
  </Stack>
854
 
855
  <Stack spacing={0.5}>
856
  <FormLabel id="output-modes-radio-group-label">
857
- Illy, can you please select the target language?
858
  </FormLabel>
859
 
860
  <Box sx={{paddingTop: 2, paddingBottom: 1}}>
@@ -919,7 +917,7 @@ export default function StreamingInterface() {
919
  spacing={1}
920
  alignItems="flex-start"
921
  sx={{flexGrow: 1}}>
922
- {/* {currentAgent?.dynamicParams?.includes(
923
  'expressive',
924
  ) && (
925
  <FormControlLabel
@@ -939,7 +937,7 @@ export default function StreamingInterface() {
939
  }
940
  label="Expressive"
941
  />
942
- )} */}
943
 
944
  {isListener && (
945
  <Box
@@ -963,10 +961,10 @@ export default function StreamingInterface() {
963
  justifyContent="space-between">
964
  <Box sx={{flex: 1}}>
965
  <FormControl disabled={streamFixedConfigOptionsDisabled}>
966
- {/* <FormLabel id="input-source-radio-group-label">
967
  Input Source
968
- </FormLabel> */}
969
- {/* <RadioGroup
970
  aria-labelledby="input-source-radio-group-label"
971
  value={inputSource}
972
  onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
@@ -982,8 +980,8 @@ export default function StreamingInterface() {
982
  control={<Radio />}
983
  label={label}
984
  />
985
- ))} */}
986
- {/* </RadioGroup> */}
987
  </FormControl>
988
  </Box>
989
 
 
6
  import Select, {SelectChangeEvent} from '@mui/material/Select';
7
  import MenuItem from '@mui/material/MenuItem';
8
  import Stack from '@mui/material/Stack';
9
+ import seamlessLogoUrl from './assets/seamless.svg';
10
  import {
11
  AgentCapabilities,
12
  BaseResponse,
 
744
  src={seamlessLogoUrl}
745
  className="header-icon-sra"
746
  alt="Seamless Translation Logo"
747
+ height={24}
748
+ width={24}
749
  />
750
 
751
  <div>
752
+ <Typography variant="h1" sx={{color: '#65676B'}}>
753
+ Seamless Translation
 
 
 
 
 
754
  </Typography>
755
  </div>
756
  </div>
757
  <div className="header-container-sra">
758
  <div>
759
  <Typography variant="body2" sx={{color: '#65676B'}}>
760
+ Welcome! This space is limited to one speaker at a time.
761
+ If using the live HF space, sharing room code to listeners on another
762
+ IP address may not work because it's running on different replicas.
 
763
  Use headphones if you are both speaker and listener to prevent feedback.
764
  <br/>
765
+ If max speakers reached, please duplicate the space <a target="_blank" rel="noopener noreferrer" href="https://huggingface.co/spaces/facebook/seamless-streaming?duplicate=true">here</a>.
766
+ In your duplicated space, join a room as speaker or listener (or both),
767
+ and share the room code to invite listeners.
768
  <br/>
769
+ Check out the seamless_communication <a target="_blank" rel="noopener noreferrer" href="https://github.com/facebookresearch/seamless_communication/tree/main">README</a> for more information.
 
 
 
 
770
  <br/>
771
+ SeamlessStreaming model is a research model and is not released
772
+ for production deployment. It is important to use a microphone with
773
+ noise cancellation (for e.g. a smartphone), otherwise you may see model hallucination on noises.
774
+ It works best if you pause every couple of sentences, or you may wish adjust the VAD threshold
775
+ in the model config. The real-time performance will degrade
776
+ if you try streaming multiple speakers at the same time.
777
  </Typography>
778
  </div>
779
  </div>
780
  <Stack spacing="22px" direction="column">
781
  <Box>
782
+ <RoomConfig
783
  roomState={roomState}
784
  serverState={serverState}
785
  streamingStatus={streamingStatus}
 
788
  // player to play eagerly, since currently the listener doesn't have any stop/start controls
789
  bufferedSpeechPlayer.start();
790
  }}
791
+ />
792
 
793
  {isListener && !isSpeaker && (
794
  <Box
 
810
  <Divider />
811
 
812
  <Stack spacing="12px" direction="column">
813
+ <FormLabel id="output-modes-radio-group-label">
814
  Model
815
+ </FormLabel>
816
  <FormControl
817
  disabled={
818
  streamFixedConfigOptionsDisabled ||
 
820
  }
821
  fullWidth
822
  sx={{minWidth: '14em'}}>
823
+ <InputLabel id="model-selector-input-label">
824
  Model
825
+ </InputLabel>
826
+ <Select
827
  labelId="model-selector-input-label"
828
  label="Model"
829
  onChange={(e: SelectChangeEvent) => {
 
845
  {agent.name}
846
  </MenuItem>
847
  ))}
848
+ </Select>
849
  </FormControl>
850
 
851
  </Stack>
852
 
853
  <Stack spacing={0.5}>
854
  <FormLabel id="output-modes-radio-group-label">
855
+ Output
856
  </FormLabel>
857
 
858
  <Box sx={{paddingTop: 2, paddingBottom: 1}}>
 
917
  spacing={1}
918
  alignItems="flex-start"
919
  sx={{flexGrow: 1}}>
920
+ {currentAgent?.dynamicParams?.includes(
921
  'expressive',
922
  ) && (
923
  <FormControlLabel
 
937
  }
938
  label="Expressive"
939
  />
940
+ )}
941
 
942
  {isListener && (
943
  <Box
 
961
  justifyContent="space-between">
962
  <Box sx={{flex: 1}}>
963
  <FormControl disabled={streamFixedConfigOptionsDisabled}>
964
+ <FormLabel id="input-source-radio-group-label">
965
  Input Source
966
+ </FormLabel>
967
+ <RadioGroup
968
  aria-labelledby="input-source-radio-group-label"
969
  value={inputSource}
970
  onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
 
980
  control={<Radio />}
981
  label={label}
982
  />
983
+ ))}
984
+ </RadioGroup>
985
  </FormControl>
986
  </Box>
987
 
streaming-react-app/src/react-xr/XRDialog.tsx CHANGED
@@ -64,7 +64,7 @@ export default function XRDialog(props: XRConfigProps) {
64
 
65
  return (
66
  <>
67
- {/* <Button variant="contained" onClick={() => setIsDialogOpen(true)}>
68
  Enter AR Experience
69
  </Button>
70
  {isDialogOpen && (
@@ -85,7 +85,7 @@ export default function XRDialog(props: XRConfigProps) {
85
  </IconButton>
86
  <XRContent {...props} />
87
  </Dialog>
88
- )} */}
89
  </>
90
  );
91
  }
 
64
 
65
  return (
66
  <>
67
+ <Button variant="contained" onClick={() => setIsDialogOpen(true)}>
68
  Enter AR Experience
69
  </Button>
70
  {isDialogOpen && (
 
85
  </IconButton>
86
  <XRContent {...props} />
87
  </Dialog>
88
+ )}
89
  </>
90
  );
91
  }
streaming-react-app/src/theme.ts CHANGED
@@ -2,12 +2,12 @@ import {createTheme} from '@mui/material/styles';
2
 
3
  const themeObject = {
4
  palette: {
5
- background: {default: '#999999' },//'#383838'},
6
  primary: {
7
  main: '#465A69',
8
  },
9
  info: {
10
- main: '#9f0000'// '#0064E0',
11
  },
12
  text: {primary: '#1C2A33'},
13
  },
 
2
 
3
  const themeObject = {
4
  palette: {
5
+ background: {default: '#383838'},
6
  primary: {
7
  main: '#465A69',
8
  },
9
  info: {
10
+ main: '#0064E0',
11
  },
12
  text: {primary: '#1C2A33'},
13
  },