Skip to content

Commit

Permalink
ビルド周りの修正
Browse files Browse the repository at this point in the history
  • Loading branch information
takana-v committed Jan 3, 2022
1 parent d7ee167 commit fcbd80f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 87 deletions.
84 changes: 6 additions & 78 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,33 +174,6 @@ jobs:
ref: ${{ matrix.voicevox_core_source_version }}
path: download/voicevox_core_source

- name: Install dependencies for building VOICEVOX Core Python package
shell: bash
run: |
pip install -r download/voicevox_core_source/requirements.txt
- name: Install VOICEVOX Core Python package
shell: bash
run: |
set -eux
mkdir -p download/voicevox_core_source/core/lib
# Copy VOICEVOX Core dylib to core/lib
cp download/core/${{ matrix.voicevox_core_library_name }} download/voicevox_core_source/core/lib/libcore.dylib
cd download/voicevox_core_source
cp core/src/core.h core/lib/
cd -
# Copy ONNX Runtime dylib
cp download/onnxruntime/lib/libonnxruntime.*.dylib download/voicevox_core_source/core/lib/
# Install VOICEVOX Core Python package with libcore.dylib & libonnxruntime.*.dylib
cd download/voicevox_core_source
NUMPY_INCLUDE=`python -c "import numpy; print(numpy.get_include())"`
CPATH="$NUMPY_INCLUDE:${CPATH:-}" pip install .
- name: Install dependencies for building VOICEVOX engine
shell: bash
run: |
Expand Down Expand Up @@ -250,7 +223,8 @@ jobs:
--include-data-file=../user.dic=./ \
--include-data-file=../download/core/*.bin=./ \
--include-data-file=../download/core/metas.json=./ \
--include-data-file=../download/onnxruntime/lib/libonnxruntime.*.dylib=./ \
--include-data-file=../download/core/libcore_cpu_x64.dylib=./ \
--include-data-file=../download/onnxruntime/lib/libonnxruntime.dylib=./ \
--include-data-file=${{ env.pythonLocation }}/lib/python*/site-packages/scipy/.dylibs/*.dylib=./scipy/.dylibs/ \
--include-data-file=${{ env.pythonLocation }}/lib/python*/site-packages/_soundfile_data/*=./_soundfile_data/ \
--include-data-dir=../speaker_info=./speaker_info \
Expand Down Expand Up @@ -681,49 +655,6 @@ jobs:
unzip download/core.zip -d download/
rm download/core.zip
# Install VOICEVOX Core Python package
- name: Prepare VOICEVOX Core source cache
uses: actions/cache@v2
id: voicevox-core-source-cache
with:
key: ${{ matrix.os }}-voicevox-core-source-${{ matrix.voicevox_core_source_version }}
path: download/voicevox_core_source

- name: Checkout VOICEVOX Core source
if: steps.voicevox-core-source-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: VOICEVOX/voicevox_core
ref: ${{ matrix.voicevox_core_source_version }}
path: download/voicevox_core_source

- name: Install VOICEVOX Core Python package
shell: bash
run: |
set -eux
# Generate VOICEVOX Core LIB from DLL
cp download/core/${{ matrix.voicevox_core_dll_name }} download/voicevox_core_source/example/python/core.dll
cd download/voicevox_core_source/example/python
./makelib.bat core
cd -
# Copy VOICEVOX Core DLL & LIB to core/lib
cd download/voicevox_core_source
mkdir -p core/lib
mv example/python/core.dll core/lib/
mv example/python/core.lib core/lib/
cp core/src/core.h core/lib/
cd -
# Copy ONNX Runtime DLLs
cp download/onnxruntime/lib/*.dll download/voicevox_core_source/core/lib/
# Install VOICEVOX Core Python package with core.dll & onnxruntime*.dll
cd download/voicevox_core_source
pip install .
- name: Generate licenses.json
shell: bash
run: python generate_licenses.py > licenses.json
Expand Down Expand Up @@ -785,17 +716,14 @@ jobs:
run: |
set -eux
# Workaround: Move core.dll to run.dist/core/lib/
# Nuitka copies core.dll to run.dist/core.dll
# but core Python module will load core.dll from run.dist/core/lib/core.dll.
mkdir -p run.dist/core/lib
mv run.dist/core.dll run.dist/core/lib/
mv run.dist/onnxruntime.dll run.dist/core/lib/
# Build artifact directory
mkdir -p artifact
ln -sf "$(pwd)/run.dist"/* artifact/
# Copy DLL of core and onnxruntime
ln -sf "$(pwd)/download/onnxruntime/lib"/onnxruntime.dll artifact/core/lib/
ln -sf "$(pwd)/download/core/${{ matrix.voicevox_core_dll_name }}" artifact/core/lib/
# Copy DLL dependencies
if [ -f "download/onnxruntime/lib/onnxruntime_providers_cuda.dll" ]; then
Expand Down
12 changes: 3 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ RUN <<EOF
mkdir /opt/voicevox_core
mv "./core/${VOICEVOX_CORE_LIBRARY_NAME}" /opt/voicevox_core/

if [ "${VOICEVOX_CORE_LIBRARY_NAME}" != "libcore.so" ]; then
# Create relative symbolic link
cd /opt/voicevox_core
ln -sf "${VOICEVOX_CORE_LIBRARY_NAME}" libcore.so
cd -
fi

# Move Voice Library to /opt/voicevox_core/
mv ./core/*.bin ./core/core.h ./core/metas.json /opt/voicevox_core/

Expand Down Expand Up @@ -287,11 +280,11 @@ exec "\$@"
EOF

ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "gosu", "user", "/opt/python/bin/python3", "./run.py", "--voicelib_dir", "/opt/voicevox_core/", "--host", "0.0.0.0" ]
CMD [ "gosu", "user", "/opt/python/bin/python3", "./run.py", "--voicelib_dir", "/opt/voicevox_core/", "--model_lib_dir", "/opt/onnxruntime/lib", "--host", "0.0.0.0" ]

# Enable use_gpu
FROM runtime-env AS runtime-nvidia-env
CMD [ "gosu", "user", "/opt/python/bin/python3", "./run.py", "--use_gpu", "--voicelib_dir", "/opt/voicevox_core/", "--host", "0.0.0.0" ]
CMD [ "gosu", "user", "/opt/python/bin/python3", "./run.py", "--use_gpu", "--voicelib_dir", "/opt/voicevox_core/", "--model_lib_dir", "/opt/onnxruntime/lib", "--host", "0.0.0.0" ]

# Binary build environment (common to CPU, GPU)
FROM runtime-env AS build-env
Expand Down Expand Up @@ -366,6 +359,7 @@ RUN <<EOF
--include-data-file=/opt/voicevox_engine/user.dic=./ \
--include-data-file=/opt/voicevox_core/*.bin=./ \
--include-data-file=/opt/voicevox_core/metas.json=./ \
--include-data-file=/opt/onnxruntime/lib/libonnxruntime.so=./ \
--include-data-dir=/opt/voicevox_engine/speaker_info=./speaker_info \
--follow-imports \
--no-prefer-source-code \
Expand Down
2 changes: 2 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ def speaker_info(speaker_uuid: str) -> SpeakerInfo:
parser.add_argument("--use_gpu", action="store_true")
parser.add_argument("--voicevox_dir", type=Path, default=None)
parser.add_argument("--voicelib_dir", type=Path, default=None)
parser.add_argument("--model_lib_dir", type=Path, default=None)
parser.add_argument("--enable_cancellable_synthesis", action="store_true")
parser.add_argument("--init_processes", type=int, default=2)
parser.add_argument("--old_voicelib_dir", type=Path, default=None)
Expand Down Expand Up @@ -664,6 +665,7 @@ def speaker_info(speaker_uuid: str) -> SpeakerInfo:
use_gpu=args.use_gpu,
voicelib_dir=voicelib_dir,
voicevox_dir=args.voicevox_dir,
model_lib_dir=args.model_lib_dir,
)
),
host=args.host,
Expand Down

0 comments on commit fcbd80f

Please sign in to comment.