Skip to content

Commit

Permalink
Revert "[project-vvm-async-api] いくつかのC関数を定数にする (VOICEVOX#503)"
Browse files Browse the repository at this point in the history
This reverts commit f4b502a.

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	crates/voicevox_core/Cargo.toml
#	crates/voicevox_core_c_api/Cargo.toml
#	crates/voicevox_core_c_api/include/voicevox_core.h
#	crates/voicevox_core_c_api/src/lib.rs
  • Loading branch information
kasamatsu committed Jul 31, 2023
1 parent f1dd63b commit 9e50810
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 266 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: 1 addition & 1 deletion crates/download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ once_cell.workspace = true
platforms = "3.0.2"
rayon = "1.6.1"
reqwest = { version = "0.11.13", default-features = false, features = ["rustls-tls", "stream"] }
strum.workspace = true
strum = { version = "0.24.1", features = ["derive"] }
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
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
4 changes: 1 addition & 3 deletions crates/voicevox_core/src/result_code.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use strum::EnumIter;

/// 処理結果を示す結果コード
#[repr(i32)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, EnumIter)]
#[derive(Debug, PartialEq, Eq)]
#[allow(non_camel_case_types)]
pub enum VoicevoxResultCode {
// C でのenum定義に合わせて大文字で定義している
Expand Down
10 changes: 4 additions & 6 deletions crates/voicevox_core/src/version.rs
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
81 changes: 64 additions & 17 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 9e50810

Please sign in to comment.