Skip to content

Commit

Permalink
Revert #503 定数化されたものを関数へ戻します (#557)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryo Yamashita <[email protected]>
Co-authored-by: kasamatsu <[email protected]>
Co-authored-by: shigobu <[email protected]>
  • Loading branch information
4 people authored Aug 13, 2023
1 parent 07ded4e commit 263beb4
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 180 deletions.
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
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 Down Expand Up @@ -31,7 +28,7 @@ impl From<&TtsOptions> for SynthesisOptions {
/// [`Synthesizer::create_accent_phrases`]のオプション。
///
/// [`Synthesizer::create_accent_phrases`]: Synthesizer::create_accent_phrases
#[derive(ConstDefault)]
#[derive(Default)]
pub struct AccentPhrasesOptions {
/// AquesTalk風記法としてテキストを解釈する。
pub kana: bool,
Expand All @@ -40,7 +37,7 @@ pub struct AccentPhrasesOptions {
/// [`Synthesizer::audio_query`]のオプション。
///
/// [`Synthesizer::audio_query`]: Synthesizer::audio_query
#[derive(ConstDefault)]
#[derive(Default)]
pub struct AudioQueryOptions {
/// AquesTalk風記法としてテキストを解釈する。
pub kana: bool,
Expand All @@ -67,52 +64,37 @@ 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"に設定する。
Cpu,
/// ハードウェアアクセラレーションモードを"GPU"に設定する。
Gpu,
}

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

/// [`Synthesizer::new_with_initialize`]のオプション。
///
/// [`Synthesizer::new_with_initialize`]: Synthesizer::new_with_initialize
#[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
84 changes: 63 additions & 21 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

0 comments on commit 263beb4

Please sign in to comment.