Skip to content

Commit d29371e

Browse files
author
Your Name
committed
first commit
0 parents  commit d29371e

File tree

2,973 files changed

+2021222
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,973 files changed

+2021222
-0
lines changed

.github/workflows/main.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: main
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
create_release:
11+
name: Create release
12+
runs-on: ubuntu-latest
13+
outputs:
14+
upload_url: ${{ steps.create_release.outputs.upload_url }}
15+
steps:
16+
- name: Create release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ github.token }}
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: ${{ github.ref }}
24+
draft: false
25+
prerelease: false
26+
build_linux:
27+
name: "linux build"
28+
runs-on: ubuntu-latest
29+
needs: create_release # we need to know the upload URL
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: docker/setup-qemu-action@v2
33+
- uses: docker/setup-buildx-action@v2
34+
- name: build
35+
run: |
36+
docker buildx build . --platform linux/amd64,linux/arm64,linux/arm/v7 --output 'type=local,dest=dist'
37+
- name: upload-amd64
38+
uses: actions/upload-release-asset@v1
39+
env:
40+
GITHUB_TOKEN: ${{ github.token }}
41+
with:
42+
upload_url: ${{ needs.create_release.outputs.upload_url }}
43+
asset_path: dist/linux_amd64/piper_amd64.tar.gz
44+
asset_name: piper_linux_x86_64.tar.gz
45+
asset_content_type: application/octet-stream
46+
- name: upload-arm64
47+
uses: actions/upload-release-asset@v1
48+
env:
49+
GITHUB_TOKEN: ${{ github.token }}
50+
with:
51+
upload_url: ${{ needs.create_release.outputs.upload_url }}
52+
asset_path: dist/linux_arm64/piper_arm64.tar.gz
53+
asset_name: piper_linux_aarch64.tar.gz
54+
asset_content_type: application/octet-stream
55+
- name: upload-armv7
56+
uses: actions/upload-release-asset@v1
57+
env:
58+
GITHUB_TOKEN: ${{ github.token }}
59+
with:
60+
upload_url: ${{ needs.create_release.outputs.upload_url }}
61+
asset_path: dist/linux_arm_v7/piper_armv7.tar.gz
62+
asset_name: piper_linux_armv7l.tar.gz
63+
asset_content_type: application/octet-stream
64+
build_windows:
65+
runs-on: windows-latest
66+
name: "windows build: ${{ matrix.arch }}"
67+
needs: create_release # we need to know the upload URL
68+
strategy:
69+
fail-fast: true
70+
matrix:
71+
arch: [x64]
72+
steps:
73+
- uses: actions/checkout@v3
74+
- name: configure
75+
run: |
76+
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=_install/piper
77+
- name: build
78+
run: |
79+
cmake --build build --config Release
80+
- name: install
81+
run: |
82+
cmake --install build
83+
- name: package
84+
run: |
85+
cd _install
86+
Compress-Archive -LiteralPath piper -DestinationPath piper_windows_amd64.zip
87+
- name: upload
88+
uses: actions/upload-release-asset@v1
89+
env:
90+
GITHUB_TOKEN: ${{ github.token }}
91+
with:
92+
upload_url: ${{ needs.create_release.outputs.upload_url }}
93+
asset_path: _install/piper_windows_amd64.zip
94+
asset_name: piper_windows_amd64.zip
95+
asset_content_type: application/zip
96+
build_macos:
97+
name: "macos build: ${{ matrix.arch }}"
98+
runs-on: macos-latest
99+
needs: create_release # we need to know the upload URL
100+
strategy:
101+
fail-fast: true
102+
matrix:
103+
arch: [x64, aarch64]
104+
steps:
105+
- uses: actions/checkout@v3
106+
- name: configure
107+
run: |
108+
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=_install/piper
109+
- name: build
110+
run: |
111+
cmake --build build --config Release
112+
- name: install
113+
run: |
114+
cmake --install build
115+
- name: package
116+
run: |
117+
cd _install && \
118+
tar -czf piper_macos_${{ matrix.arch }}.tar.gz piper/
119+
- name: upload
120+
uses: actions/upload-release-asset@v1
121+
env:
122+
GITHUB_TOKEN: ${{ github.token }}
123+
with:
124+
upload_url: ${{ needs.create_release.outputs.upload_url }}
125+
asset_path: _install/piper_macos_${{ matrix.arch }}.tar.gz
126+
asset_name: piper_macos_${{ matrix.arch }}.tar.gz
127+
asset_content_type: application/octet-stream

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.DS_Store
2+
.idea
3+
*.log
4+
tmp/
5+
6+
*.py[cod]
7+
*.egg
8+
*.egg-info/
9+
build
10+
htmlcov
11+
12+
/data/
13+
/build/
14+
/local/
15+
/dist/
16+
/lib/
17+
/install/
18+
/download/
19+
*.so
20+
21+
.venv/
22+
lightning_logs/

CMakeLists.txt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(PronunciationHelper C CXX)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
if(MSVC)
9+
# Force compiler to use UTF-8 for IPA constants
10+
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
11+
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
12+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /W0")
13+
# Set CMake flag to use static runtime library
14+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
15+
16+
# Alternatively, set compiler flags to explicitly specify /MT and /MTd
17+
# Set /MT, /MTd for all targets
18+
foreach(flag_var
19+
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
20+
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
21+
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
22+
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
23+
if(${flag_var} MATCHES "/MD")
24+
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
25+
endif(${flag_var} MATCHES "/MD")
26+
endforeach(flag_var)
27+
elseif(NOT APPLE)
28+
# Linux flags
29+
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
30+
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
31+
endif()
32+
33+
find_package(wxWidgets COMPONENTS core base REQUIRED)
34+
set(PROJ_SOURCES src/main.cpp src/MainFrame.cpp src/PiperWrapper.cpp)
35+
if(WIN32)
36+
set(PROJ_SOURCES ${PROJ_SOURCES} icons/logo.rc)
37+
elseif(APPLE)
38+
set(MACOSX_BUNDLE_ICON_FILE icons/app_icon.icns)
39+
endif()
40+
add_executable(${PROJECT_NAME} ${PROJ_SOURCES})
41+
include_directories(${wxWidgets_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/src")
42+
43+
include(ExternalProject)
44+
45+
# ---- piper-phonemize ----
46+
set(PIPER_PHONEMIZE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pi")
47+
ExternalProject_Add(
48+
pp_ext
49+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/piper-phonemize"
50+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR}
51+
)
52+
add_dependencies(${PROJECT_NAME} pp_ext)
53+
54+
set(PORTAUDIO_DIR "${CMAKE_CURRENT_BINARY_DIR}/pa")
55+
ExternalProject_Add(
56+
pa_ext
57+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/portaudio"
58+
CMAKE_ARGS -DPA_BUILD_SHARED_LIBS:BOOL=OFF
59+
CMAKE_ARGS -DPA_DLL_LINK_WITH_STATIC_RUNTIME:BOOL=ON
60+
CMAKE_ARGS -DPA_BUILD_EXAMPLES:BOOL=OFF
61+
CMAKE_ARGS -DPA_BUILD_TESTS:BOOL=OFF
62+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PORTAUDIO_DIR}
63+
)
64+
add_dependencies(${PROJECT_NAME} pp_ext)
65+
66+
# ---- Declare executable link settings ----
67+
if((NOT MSVC) AND (NOT APPLE))
68+
# Linux flags
69+
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
70+
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
71+
target_link_libraries(${PROJECT_NAME} -static-libgcc -static-libstdc++)
72+
73+
set(PIPER_EXTRA_LIBRARIES "pthread")
74+
endif()
75+
76+
target_link_libraries(${PROJECT_NAME}
77+
espeak-ng
78+
piper_phonemize
79+
onnxruntime
80+
portaudio
81+
${wxWidgets_LIBRARIES}
82+
${PIPER_EXTRA_LIBRARIES}
83+
)
84+
85+
target_link_directories(${PROJECT_NAME} PUBLIC
86+
${PIPER_PHONEMIZE_DIR}/lib
87+
${PORTAUDIO_DIR}/lib
88+
)
89+
90+
target_include_directories(${PROJECT_NAME} PUBLIC
91+
${PIPER_PHONEMIZE_DIR}/include
92+
${PORTAUDIO_DIR}/include
93+
)
94+
95+
if(WIN32)
96+
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE ON)
97+
endif()
98+
99+
# ---- Declare install targets ----
100+
install(
101+
TARGETS ${PROJECT_NAME}
102+
DESTINATION ${CMAKE_INSTALL_PREFIX}
103+
)
104+
105+
# Install dependent dynamic libraries and data files
106+
install(
107+
DIRECTORY ${PIPER_PHONEMIZE_DIR}/bin/
108+
DESTINATION ${CMAKE_INSTALL_PREFIX}
109+
USE_SOURCE_PERMISSIONS # Preserve executable permissions
110+
FILES_MATCHING
111+
PATTERN "espeak-ng"
112+
PATTERN "*.dll"
113+
)
114+
115+
install(
116+
DIRECTORY ${PIPER_PHONEMIZE_DIR}/lib/
117+
DESTINATION ${CMAKE_INSTALL_PREFIX}
118+
FILES_MATCHING
119+
PATTERN "*.dll"
120+
PATTERN "*.so*"
121+
)
122+
123+
install(
124+
DIRECTORY ${PIPER_PHONEMIZE_DIR}/share/espeak-ng-data
125+
DESTINATION ${CMAKE_INSTALL_PREFIX}
126+
)
127+
128+
install(
129+
FILES ${PIPER_PHONEMIZE_DIR}/share/libtashkeel_model.ort
130+
DESTINATION ${CMAKE_INSTALL_PREFIX}
131+
)

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Michael Hansen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)