Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 51 additions & 72 deletions .github/workflows/dev-daily-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ jobs:
echo "- プラットフォーム: Linux (x86_64, ARM64, ARMv7), Windows (x64), macOS (x64, ARM64)"
} > description.txt

# 説明文を1行に変換して出力
echo "description=$(cat description.txt | tr '\n' ' ' | sed 's/ */ /g')" >> $GITHUB_OUTPUT
# 改行を %0A にエスケープして出力 (GitHub Actions 仕様)
DESCRIPTION_ESCAPED=$(sed ':a;N;$!ba;s/\n/%0A/g' description.txt)
echo "description=$DESCRIPTION_ESCAPED" >> $GITHUB_OUTPUT
fi

- name: Create release
Expand Down Expand Up @@ -159,70 +160,42 @@ jobs:
with:
fetch-depth: 0

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1

- name: Install dependencies
run: |
# 必要なツールのインストール
choco install -y cmake ninja visualstudio2022-workload-vctools

# espeak-ngのビルドとインストール
git clone --depth 1 https://github.com/espeak-ng/espeak-ng.git
cd espeak-ng

# autogenスクリプトの作成
@"
@echo off
setlocal

if not exist "configure" (
echo Running aclocal...
aclocal
if errorlevel 1 goto :error

echo Running autoconf...
autoconf
if errorlevel 1 goto :error

echo Running automake...
automake --add-missing
if errorlevel 1 goto :error
)
# GitHub hosted Windows runners already include VS Build Tools 2022 and MSVC
# Installing the workload again via Chocolatey often hangs at the VS bootstrapper UI.
# Only install CMake and Ninja which are still required.
choco install -y cmake ninja

echo Running configure...
call configure --prefix=C:/espeak-ng
if errorlevel 1 goto :error

goto :end

:error
echo Error occurred
exit /b 1

:end
"@ > autogen.bat

# ビルドとインストール
mkdir build
cd build
cmake .. -G "Ninja" -DCMAKE_INSTALL_PREFIX=C:/espeak-ng -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
cmake --install .
cd ../..

# 環境変数の設定
$env:PATH = "C:\espeak-ng\bin;$env:PATH"
$env:ESPEAK_DATA_PATH = "C:\espeak-ng\share\espeak-ng-data"
[Environment]::SetEnvironmentVariable("PATH", $env:PATH, "Process")
[Environment]::SetEnvironmentVariable("ESPEAK_DATA_PATH", $env:ESPEAK_DATA_PATH, "Process")
# 環境変数 VSINSTALLDIR を設定 (ilammy/msvc-dev-cmd が使用)
$vs = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
if ($vs) {
[Environment]::SetEnvironmentVariable('VSINSTALLDIR', $vs, 'Process')
}

# espeak-ng を Chocolatey でインストール (1.52.0 は 64bit DLL/Binary を含む)
choco install -y espeak-ng

- name: Configure build
run: |
# CMakeの設定
# espeak-ng ルート
$ESPEAK_ROOT = "C:/ProgramData/chocolatey/lib/espeak-ng/tools"
if (Test-Path "$ESPEAK_ROOT\bin") {
$env:PATH = "$ESPEAK_ROOT\bin;$env:PATH"
$env:ESPEAK_DATA_PATH = "$ESPEAK_ROOT\share\espeak-ng-data"
[Environment]::SetEnvironmentVariable("PATH", $env:PATH, "Process")
[Environment]::SetEnvironmentVariable("ESPEAK_DATA_PATH", $env:ESPEAK_DATA_PATH, "Process")
}

# CMake設定
cmake -Bbuild `
-G "Ninja" `
-DCMAKE_INSTALL_PREFIX=_install/piper `
-DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} `
-DESPEAK_NG_ROOT=C:/espeak-ng

-DESPEAK_NG_ROOT=$ESPEAK_ROOT
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake configuration failed"
exit 1
Expand All @@ -238,8 +211,9 @@ jobs:
}

# ビルド成果物の確認
if (-not (Test-Path "build\Release\piper.exe")) {
Write-Error "piper.exe not found in build directory"
$exePath = if (Test-Path "build\Release\piper.exe") { "build\Release\piper.exe" } elseif (Test-Path "build\piper.exe") { "build\piper.exe" } else { $null }
if (-not $exePath) {
Write-Error "piper.exe not found"
exit 1
}

Expand All @@ -262,29 +236,34 @@ jobs:
- name: Verify Windows package
run: |
# バイナリの存在確認
if (-not (Test-Path "_install\piper\bin\piper.exe")) {
Write-Error "Windows package is missing piper.exe"
$exePath = if (Test-Path "_install\piper\bin\piper.exe") { "_install\piper\bin\piper.exe" } elseif (Test-Path "build\Release\piper.exe") { "build\Release\piper.exe" } elseif (Test-Path "build\piper.exe") { "build\piper.exe" } else { $null }
if (-not $exePath) {
Write-Error "piper.exe not found"
exit 1
}

# 簡単なテスト実行
Write-Output "Testing piper binary..." | .\_install\piper\bin\piper.exe --help
if ($LASTEXITCODE -ne 0) {
Write-Error "piper.exe test failed"

# 簡単なテスト実行 (ヘルプ表示)
& $exePath --help | Out-Null
# exit code 0 or 1 は許容する。その他は失敗扱い。
if ($LASTEXITCODE -gt 1) {
Write-Error "piper.exe test failed ($LASTEXITCODE)"
exit 1
}
exit 0

- name: Create archive
run: |
# アーカイブの作成
Compress-Archive -Path "_install\piper\*" -DestinationPath "piper_windows_amd64.zip" -Force
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create archive"
$srcDir = if (Test-Path "_install\piper") { "_install\piper" } elseif (Test-Path "build\_install\piper") { "build\_install\piper" } elseif (Test-Path "build\Release") { "build\Release" } else { $null }
if (-not $srcDir) { Write-Error "No directory to archive"; exit 1 }
$dest = "_install\piper_windows_amd64.zip"
try {
Compress-Archive -Path "$srcDir\*" -DestinationPath $dest -Force
} catch {
Write-Error "Compress-Archive failed: $_"
exit 1
}

# アーカイブの確認
if (-not (Test-Path "piper_windows_amd64.zip")) {

if (-not (Test-Path $dest)) {
Write-Error "Archive not created"
exit 1
}
Expand Down
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(MSVC)
add_definitions(-D_WIN32_WINNT=0x0601) # Windows 7 or later

# ONNX Runtimeのヘッダーファイルの問題を解決
add_definitions(-D_Frees_ptr_opt_=__declspec(dllexport))
add_definitions(-D_Frees_ptr_opt_=)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DWIN32)
Expand All @@ -40,7 +40,7 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /RTC1")

# コンパイルオプションの修正
add_compile_options(/W4 /WX /wd4100 /wd4505 /wd4996)
add_compile_options(/W4 /WX /wd4100 /wd4505 /wd4996 /wd4005)
add_compile_options(/permissive) # /permissive-を/permissiveに変更
add_compile_options(/Zc:__cplusplus)
add_compile_options(/Zc:inline)
Expand Down Expand Up @@ -129,7 +129,11 @@ if(NOT DEFINED PIPER_PHONEMIZE_DIR)
piper_phonemize_external
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/p"
URL "https://github.com/rhasspy/piper-phonemize/archive/refs/heads/master.zip"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR}
$<$<BOOL:MSVC>:-G;${CMAKE_GENERATOR}>
$<$<BOOL:MSVC>:-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}>
$<$<BOOL:MSVC>:-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}>
)
add_dependencies(piper piper_phonemize_external)
add_dependencies(test_piper piper_phonemize_external)
Expand All @@ -141,12 +145,12 @@ if((NOT MSVC) AND (NOT APPLE))
# Linux flags
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
target_link_libraries(piper -static-libgcc -static-libstdc++)
target_link_options(piper PRIVATE -static-libgcc -static-libstdc++)

set(PIPER_EXTRA_LIBRARIES "pthread")
endif()

target_link_libraries(piper
target_link_libraries(piper PUBLIC
fmt
spdlog
espeak-ng
Expand Down Expand Up @@ -270,11 +274,11 @@ if(MSVC)
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION "10.0.19041.0")
endif()

# ONNX Runtimeの設定
target_compile_definitions(piper_phonemize PRIVATE
# ONNX Runtime 用定義と SAL マクロ簡易定義
target_compile_definitions(piper PRIVATE
ONNXRUNTIME_DLL
ONNXRUNTIME_STATIC_LIB
_Frees_ptr_opt_=__declspec(dllexport)
_Frees_ptr_opt_=
)
endif()

Expand Down
53 changes: 29 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@ ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive

# パッケージリストの更新とインストールを分離
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
ca-certificates \
curl \
gnupg \
lsb-release && \
# リポジトリの追加(アーキテクチャに依存しない)
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
# パッケージのインストール
apt-get update && \
apt-get install --yes --no-install-recommends \
build-essential \
cmake \
git \
pkg-config \
libicu-dev \
libespeak-ng-dev \
make \
ninja-build \
python3 && \
RUN set -e; \
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries; \
# -- 基本ツール --
for i in 1 2 3; do \
apt-get update && \
apt-get install --yes --no-install-recommends \
ca-certificates curl gnupg lsb-release && break || { echo "apt preinstall failed ($i)"; sleep 5; }; \
done; \
# docker repo key
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null; \
for i in 1 2 3; do \
apt-get update && \
apt-get install --yes --no-install-recommends \
build-essential cmake git pkg-config libicu-dev libespeak-ng-dev make ninja-build python3 ccache && break || { echo "apt core install failed ($i)"; sleep 5; }; \
done; \
# --- クロスコンパイルツール ----
# buildx/QEMU ではビルド用コンテナ自体がターゲットと同じアーキテクチャになる。
# その場合追加ツールは不要で、Debian arm リポジトリには crossbuild-essential-* が存在しない。
Expand All @@ -35,9 +30,13 @@ RUN apt-get update && \
if [ "$HOST_ARCH" = "amd64" ] && [ "$TARGETARCH" = "arm64" ]; then \
apt-get install --yes --no-install-recommends \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu; \
ln -s /usr/bin/ccache /usr/local/bin/aarch64-linux-gnu-gcc; \
ln -s /usr/bin/ccache /usr/local/bin/aarch64-linux-gnu-g++; \
elif [ "$HOST_ARCH" = "amd64" ] && [ "$TARGETARCH" = "arm" ] && [ "$TARGETVARIANT" = "v7" ]; then \
apt-get install --yes --no-install-recommends \
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf; \
ln -s /usr/bin/ccache /usr/local/bin/arm-linux-gnueabihf-gcc; \
ln -s /usr/bin/ccache /usr/local/bin/arm-linux-gnueabihf-g++; \
fi && \
# クリーンアップ
apt-get clean && \
Expand Down Expand Up @@ -76,17 +75,23 @@ COPY ./ ./

# アーキテクチャに応じたビルド設定
RUN if [ "$TARGETARCH" = "amd64" ]; then \
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install && \
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache && \
cmake --build build --config Release && \
cmake --install build; \
elif [ "$TARGETARCH" = "arm64" ]; then \
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_TOOLCHAIN_FILE=cmake/linux-aarch64.cmake && \
-DCMAKE_TOOLCHAIN_FILE=cmake/linux-aarch64.cmake \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache && \
cmake --build build --config Release && \
cmake --install build; \
elif [ "$TARGETARCH" = "arm" ] && [ "$TARGETVARIANT" = "v7" ]; then \
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_TOOLCHAIN_FILE=cmake/linux-armv7.cmake && \
-DCMAKE_TOOLCHAIN_FILE=cmake/linux-armv7.cmake \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache && \
cmake --build build --config Release && \
cmake --install build; \
else \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Piper is used in a [variety of projects](#people-using-piper).
* GitHub Actionsによる以下のプラットフォームのビルドおよびバイナリー配布の自動化
* Linux (amd64, arm64)
* macOS (x64, arm64)
* Windows (x64)

## 関連記事
* [LJSpeechを使って英語のpiperの事前学習モデルを作成する](https://ayousanz.hatenadiary.jp/entry/2025/05/26/230341)
Expand Down