Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #503 定数化されたものを関数へ戻します #557

Merged
Merged
Show file tree
Hide file tree
Changes from 8 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
44 changes: 0 additions & 44 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ members = [
anyhow = "1.0.65"
async_zip = { version = "0.0.11", features = ["full"] }
clap = { version = "4.0.10", features = ["derive"] }
const-default = { version = "1.0.0", features = ["derive"] }
easy-ext = "1.0.1"
fs-err = { version = "2.9.0", features = ["tokio"] }
itertools = "0.10.5"
Expand Down
2 changes: 0 additions & 2 deletions crates/voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ directml = ["onnxruntime/directml"]
anyhow.workspace = true
async_zip.workspace = true
cfg-if = "1.0.0"
const-default.workspace = true
derive-getters.workspace = true
derive-new = "0.5.9"
duplicate = "1.0.0"
easy-ext.workspace = true
fs-err.workspace = true
futures = "0.3.26"
Expand Down
10 changes: 4 additions & 6 deletions crates/voicevox_core/src/version.rs
qryxip marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/// 本クレートの`package.version`。
///
/// C APIやPython API側からこの値が使われるべきではない。
/// 現在はまだRust APIを外部提供していないため、この定数はどこからも参照されていないはずである。
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const fn get_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}

#[cfg(test)]
mod tests {
use super::*;
use crate::*;
#[rstest]
fn get_version_works() {
assert_eq!("0.0.0", VERSION);
assert_eq!("0.0.0", get_version());
}
}
42 changes: 12 additions & 30 deletions crates/voicevox_core/src/voice_synthesizer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use std::sync::Arc;

use const_default::ConstDefault;
use duplicate::duplicate_item;

use crate::engine::{create_kana, parse_kana, AccentPhraseModel, OpenJtalk, SynthesisEngine};

use super::*;
Expand All @@ -25,12 +22,12 @@ impl From<&TtsOptions> for SynthesisOptions {
}
}

#[derive(ConstDefault)]
#[derive(Default)]
pub struct AccentPhrasesOptions {
pub kana: bool,
}

#[derive(ConstDefault)]
#[derive(Default)]
pub struct AudioQueryOptions {
pub kana: bool,
}
Expand All @@ -52,45 +49,30 @@ impl AsRef<TtsOptions> for TtsOptions {
}
}

impl ConstDefault for TtsOptions {
const DEFAULT: Self = Self {
enable_interrogative_upspeak: true,
kana: ConstDefault::DEFAULT,
};
impl Default for TtsOptions {
fn default() -> Self {
Self {
enable_interrogative_upspeak: true,
kana: Default::default(),
}
}
}

#[derive(Debug, PartialEq, Eq)]
#[derive(Default, Debug, PartialEq, Eq)]
pub enum AccelerationMode {
#[default]
Auto,
Cpu,
Gpu,
}

impl ConstDefault for AccelerationMode {
const DEFAULT: Self = Self::Auto;
}

#[derive(ConstDefault)]
#[derive(Default)]
pub struct InitializeOptions {
pub acceleration_mode: AccelerationMode,
pub cpu_num_threads: u16,
pub load_all_models: bool,
}

#[duplicate_item(
T;
[ AccentPhrasesOptions ];
[ AudioQueryOptions ];
[ TtsOptions ];
[ AccelerationMode ];
[ InitializeOptions ];
)]
impl Default for T {
fn default() -> Self {
Self::DEFAULT
}
}

/// 音声シンセサイザ
pub struct Synthesizer {
synthesis_engine: SynthesisEngine,
Expand Down
1 change: 0 additions & 1 deletion crates/voicevox_core_c_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ name = "e2e"
directml = ["voicevox_core/directml"]

[dependencies]
const-default.workspace = true
derive-getters.workspace = true
libc = "0.2.134"
once_cell.workspace = true
Expand Down
80 changes: 61 additions & 19 deletions crates/voicevox_core_c_api/include/voicevox_core.h

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

Loading