Skip to content

Commit

Permalink
Merge branch 'main' into feat-add-supported-features-to-metas
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Jan 11, 2025
2 parents 296b54b + fda1e71 commit d17efa7
Show file tree
Hide file tree
Showing 64 changed files with 1,772 additions and 1,000 deletions.
11 changes: 11 additions & 0 deletions .github/actions/install-cargo-deny/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Install cargo-deny
description: cargo-denyをインストールする。

runs:
using: composite
steps:
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cargo-deny
shell: bash
run: cargo binstall cargo-deny@^0.16 --no-confirm --log-level debug
24 changes: 24 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 依存ライブラリを監査する。
#
# RustSec Advisory Databaseに登録された、あるいは単にヤンクされたクレートを検出する。
# 検出されるものは脆弱性(`vulnerability`)のみとは限らない。
# 依存ライブラリが単に"unmaintained"とされたりヤンクされたりしても反応する。

name: audit

# データベースへの登録とクレートのヤンクはこちらの依存ライブラリの編集と関係なく起きるため、`push`
# と`pull_request`はトリガーにしない。
on:
workflow_dispatch:
schedule:
- cron: '0 15 * * *'

jobs:
audit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install cargo-deny
uses: ./.github/actions/install-cargo-deny
- name: cargo-deny
run: cargo deny --all-features check -s advisories
8 changes: 5 additions & 3 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ jobs:
git fetch private refs/tags/${{ env.PRODUCTION_REPOSITORY_TAG }}
git -c user.name=dummy -c [email protected] merge FETCH_HEAD
) > /dev/null 2>&1
- name: Set up Python 3.8
- name: Set up Python 3.10
if: matrix.python_whl
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
architecture: ${{ contains(matrix.artifact_name,'x86') && 'x86' || 'x64' }}
- name: set up ${{ matrix.target }}
uses: ./.github/actions/rust-toolchain-from-file
Expand Down Expand Up @@ -225,7 +225,9 @@ jobs:
- name: set cargo version
run: |
cargo set-version "$VERSION" --exclude voicevox_core_python_api --exclude downloader --exclude xtask
if ${{ matrix.python_whl }}; then cargo set-version "$VERSION" -p voicevox_core_python_api; fi
if ${{ matrix.python_whl }}; then
sed -i_ 's/version = "\(0\.0\.0\)"/version = "'"$VERSION"'"/' ./crates/voicevox_core_python_api/pyproject.toml
fi
- name: cache target
uses: Swatinem/rust-cache@v2
if: ${{ !inputs.is_production }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy_downloader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:

- name: Rename the binary
run: |
case "$OS" in
case "$RUNNER_OS" in
Windows) exe_suffix=.exe;;
Linux | macOS) exe_suffix=;;
esac
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/cargo-deny.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/generate_document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 依存ライブラリのライセンスを確認する。
#
# `advisories`以外についてcargo-denyを実行する。

name: licenses

# 外部からの貢献者の負担を減らすため、PR時点では不適合になることを許容する。その代わりmainブランチで
# は毎回本ワークフローを実行する。
on:
push:
branches:
- main

jobs:
licenses:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install cargo-deny
uses: ./.github/actions/install-cargo-deny
- name: cargo-deny
run: cargo deny --all-features check -s bans licenses sources
4 changes: 2 additions & 2 deletions .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Install Poetry
run: |
python -m pip install --upgrade poetry
poetry config virtualenvs.create false
- name: Validate poetry.lock
run: |
poetry lock --no-update
poetry lock
git diff --exit-code
- name: Install dependencies
run: poetry install --with test
Expand Down
28 changes: 20 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Install Pyflakes
run: pip install 'pyflakes>3,<4'
- name: actionlint
Expand All @@ -67,10 +67,10 @@ jobs:
uses: ./.github/actions/rust-toolchain-from-file
with:
components: clippy,rustfmt
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -v --tests -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -v -- -D clippy::all -D warnings --no-deps
Expand Down Expand Up @@ -125,10 +125,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -272,10 +272,10 @@ jobs:
working-directory: ./crates/voicevox_core_python_api
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- run: |
Expand All @@ -296,6 +296,18 @@ jobs:
for file in ../../example/python/run{,-asyncio}.py; do
poetry run python "$file" ../test_util/data/model/sample.vvm --dict-dir ../test_util/data/open_jtalk_dic_utf_8-1.11
done
# https://github.com/VOICEVOX/voicevox_core/issues/873 が再発しないかの確認。
#
# Python 3.8においては、プロセスの終了までにFatal Python errorに至らなくても`StopIteration`までは達することが多い。
# #873の要因は依然として不明であるが、`StopIteration`が出ないことの確認をもって#873の解決とすることにする。
#
# TODO: 10回の実行におよそ60秒ほどかかるため、状況の経過を見てやめる。
for _ in {1..10}; do
poetry run python ../../example/python/run-asyncio.py ../test_util/data/model/sample.vvm --dict-dir ../test_util/data/open_jtalk_dic_utf_8-1.11 \
2> >(tee ./stderr.txt >&2)
# shellcheck disable=SC2059
! grep -q StopIteration ./stderr.txt
done
build-and-test-java-api:
strategy:
fail-fast: false
Expand Down
8 changes: 6 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ typetag = "0.2.18"
url = "2.5.4"
uuid = "1.10.0"
voicevox_core = { path = "crates/voicevox_core" }
voicevox_core_macros = { path = "crates/voicevox_core_macros" }
windows = "0.43.0"
zip = "0.6.3"

[workspace.dependencies.voicevox-ort]
git = "https://github.com/VOICEVOX/ort.git"
rev = "09a9fe1619c1561efafc02f68f0bda4aad879771"
rev = "cecd844162a1c6188de03b4566c81d9d38a28600"

[workspace.dependencies.open_jtalk]
git = "https://github.com/VOICEVOX/open_jtalk-rs.git"
Expand All @@ -114,7 +115,8 @@ rev = "de226a26e8e18edbdb1d6f986afe37bbbf35fbf4"
version = "0.0.0"
edition = "2021"
publish = false
rust-version = "1.81.0"
rust-version = "1.84.0"
license = "MIT"

# min-sized-rustを元にrelease buildのサイズが小さくなるようにした
# https://github.com/johnthagen/min-sized-rust
Expand Down
1 change: 1 addition & 0 deletions crates/downloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "downloader"
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[[bin]]
name = "download"
Expand Down
1 change: 1 addition & 0 deletions crates/test_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "test_util"
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[dependencies]
libloading.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ thiserror.workspace = true
tracing.workspace = true
uuid = { workspace = true, features = ["v4", "serde"] }
voicevox-ort = { workspace = true, features = ["download-binaries", "__init-for-voicevox"] }
voicevox_core_macros = { path = "../voicevox_core_macros" }
voicevox_core_macros.workspace = true

[dev-dependencies]
heck.workspace = true
Expand Down
14 changes: 6 additions & 8 deletions crates/voicevox_core/src/__internal/doctest_fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{ffi::OsString, path::Path};

use camino::Utf8Path;

use crate::{AccelerationMode, InitializeOptions};
use crate::AccelerationMode;

pub use crate::synthesizer::nonblocking::IntoBlocking;

Expand All @@ -13,20 +13,18 @@ pub async fn synthesizer_with_sample_voice_model(
>,
open_jtalk_dic_dir: impl AsRef<Utf8Path>,
) -> anyhow::Result<crate::nonblocking::Synthesizer<crate::nonblocking::OpenJtalk>> {
let syntesizer = crate::nonblocking::Synthesizer::new(
let syntesizer = crate::nonblocking::Synthesizer::builder(
#[cfg(feature = "load-onnxruntime")]
crate::nonblocking::Onnxruntime::load_once()
.filename(onnxruntime_dylib_path)
.exec()
.await?,
#[cfg(feature = "link-onnxruntime")]
crate::nonblocking::Onnxruntime::init_once().await?,
crate::nonblocking::OpenJtalk::new(open_jtalk_dic_dir).await?,
&InitializeOptions {
acceleration_mode: AccelerationMode::Cpu,
..Default::default()
},
)?;
)
.open_jtalk(crate::nonblocking::OpenJtalk::new(open_jtalk_dic_dir).await?)
.acceleration_mode(AccelerationMode::Cpu)
.build()?;

let model = &crate::nonblocking::VoiceModelFile::open(voice_model_path).await?;
syntesizer.load_voice_model(model).await?;
Expand Down
5 changes: 4 additions & 1 deletion crates/voicevox_core/src/__internal/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ pub mod raii;

pub use crate::{
metas::merge as merge_metas,
synthesizer::{blocking::PerformInference, MARGIN},
synthesizer::{
blocking::PerformInference, DEFAULT_CPU_NUM_THREADS, DEFAULT_ENABLE_INTERROGATIVE_UPSPEAK,
MARGIN,
},
};
7 changes: 7 additions & 0 deletions crates/voicevox_core/src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ pub mod onnxruntime {
#[cfg_attr(docsrs, doc(cfg(feature = "load-onnxruntime")))]
pub use crate::infer::runtimes::onnxruntime::blocking::LoadOnce;
}

pub mod synthesizer {
pub use crate::synthesizer::blocking::{Builder, Synthesis, Tts, TtsFromKana};

// TODO: 後で封印する
pub use crate::synthesizer::blocking::PrecomputeRender;
}
3 changes: 3 additions & 0 deletions crates/voicevox_core/src/core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod adjust;

pub(crate) use self::adjust::{ensure_minimum_phoneme_length, pad_decoder_feature};
6 changes: 6 additions & 0 deletions crates/voicevox_core/src/core/adjust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! 推論操作の前処理と後処理。
mod post;
mod pre;

pub(crate) use self::{post::ensure_minimum_phoneme_length, pre::pad_decoder_feature};
12 changes: 12 additions & 0 deletions crates/voicevox_core/src/core/adjust/post.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! 推論の出力の後処理。
pub(crate) fn ensure_minimum_phoneme_length(mut output: Vec<f32>) -> Vec<f32> {
const PHONEME_LENGTH_MINIMAL: f32 = 0.01;

for output_item in output.iter_mut() {
if *output_item < PHONEME_LENGTH_MINIMAL {
*output_item = PHONEME_LENGTH_MINIMAL;
}
}
output
}
Loading

0 comments on commit d17efa7

Please sign in to comment.