File size: 2,648 Bytes
37d87af
 
7f87add
 
 
 
 
 
3e8c109
9142102
7f87add
 
 
6e83f48
 
 
 
 
0c542b8
 
37d87af
0c542b8
 
e43191e
0c542b8
 
 
 
 
e43191e
37d87af
0c542b8
37d87af
 
 
 
 
 
58914ff
37d87af
 
 
281ee3d
01bcf7b
 
281ee3d
 
6b19e55
281ee3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e83f48
 
 
 
 
7ee1777
37d87af
0c542b8
37d87af
 
0c542b8
37d87af
 
0c542b8
37d87af
58914ff
 
 
37d87af
e43191e
9cdf2c6
37d87af
0c542b8
37d87af
fcd7471
 
 
863d7d2
37d87af
539f348
 
863d7d2
37d87af
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
FROM python:3.9-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    libsndfile1 \
    ffmpeg \
    wget \
    curl \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Set for Numba cache (error from https://github.com/librosa/librosa/issues/1156)
RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

# Copy requirements file
COPY --chown=user  requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -U pip && \
    pip install --no-cache-dir -r requirements.txt

# Clone VERSA repository
RUN git clone https://github.com/wavlab-speech/versa.git && \
    cd versa && \
    pip install -e .

# Install External Packages from VERSA
RUN cd versa/tools && \
    bash install_asvspoof.sh

RUN cd versa/tools && \
    bash install_audiobox-aesthetics.sh

RUN cd versa/tools && \
    bash install_emo2vec.sh

RUN cd versa/tools && \
    bash install_nomad.sh

RUN cd versa/tools && \
    bash install_noresqa.sh

RUN cd versa/tools && \
    bash install_scoreq.sh

RUN cd versa/tools && \
    bash install_pysepm.sh

RUN cd versa/tools && \
    bash install_srmr.sh

RUN cd versa/tools && \
    bash setup_nisqa.sh

RUN cd versa/tools && \
    bash install_warpq.sh

# Create directories with permissive permissions
RUN mkdir -p $HOME/app/.cache  \
    && mkdir -p $HOME/app/.cache/huggingface \
    && mkdir -p $HOME/app/.cache/huggingface/token \
    mkdir -p $HOME/app/data/configs $HOME/app/data/uploads $HOME/app/data/results

# Copy universal metrics YAML file
COPY --chown=user universal_metrics.yaml $HOME/app/data/configs/

# Copy application code
COPY --chown=user app.py .

# Create installation complete indicator
RUN touch $HOME/app/versa/.installation_complete

# Set port
EXPOSE 7860

# Set environment variables
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV NLTK_DATA=$HOME/local/share/nltk_data
ENV PYTHONUNBUFFERED=1
ENV HF_HOME=$HOME/.cache/huggingface

# Pre-download NLTK data
RUN python -c "import nltk; nltk.download('punkt', download_dir='$NLTK_DATA'); nltk.download('stopwords', download_dir='$NLTK_DATA'); nltk.download('wordnet', download_dir='$NLTK_DATA')"


# Run the application
COPY --chown=user app.py $HOME/app/versa
COPY --chown=user test_versa.py $HOME/app/versa
WORKDIR $HOME/app/versa
CMD ["python", "app.py"]