diff --git a/Cargo.toml b/Cargo.toml index 9a6c0335f..1b6b15b68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ chrono = { version = "0.4.26", default-features = false } clap = "4.0.10" color-eyre = "0.6.2" colorchoice = "1.0.0" -cstr = "0.2.11" +cstr = "0.2.11" # https://github.com/dtolnay/syn/issues/1502 derive-getters = "0.2.0" derive-new = "0.5.9" derive_more = "0.99.17" diff --git a/crates/voicevox_core/src/engine/full_context_label.rs b/crates/voicevox_core/src/engine/full_context_label.rs index 06cfdd0fd..8b87048e5 100644 --- a/crates/voicevox_core/src/engine/full_context_label.rs +++ b/crates/voicevox_core/src/engine/full_context_label.rs @@ -177,108 +177,6 @@ pub fn mora_to_text(consonant: Option<&str>, vowel: &str) -> String { engine::mora2text(&mora_text).to_string() } -// FIXME: Rust 1.77の新機能導入と共にこれを消す -#[allow(unused_imports)] -mod chunk_by { - // Implementations in this module were copied from - // [Rust](https://github.com/rust-lang/rust/blob/746a58d4359786e4aebb372a30829706fa5a968f/library/core/src/slice/iter.rs). - - // MIT License Notice - - // Permission is hereby granted, free of charge, to any - // person obtaining a copy of this software and associated - // documentation files (the "Software"), to deal in the - // Software without restriction, including without - // limitation the rights to use, copy, modify, merge, - // publish, distribute, sublicense, and/or sell copies of - // the Software, and to permit persons to whom the Software - // is furnished to do so, subject to the following - // conditions: - // - // The above copyright notice and this permission notice - // shall be included in all copies or substantial portions - // of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF - // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED - // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT - // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR - // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - // DEALINGS IN THE SOFTWARE. - - pub struct ChunkBy<'a, T, P> { - slice: &'a [T], - predicate: P, - } - impl<'a, T, P> ChunkBy<'a, T, P> { - pub(super) fn new(slice: &'a [T], predicate: P) -> Self { - ChunkBy { slice, predicate } - } - } - impl<'a, T, P> Iterator for ChunkBy<'a, T, P> - where - P: FnMut(&T, &T) -> bool, - { - type Item = &'a [T]; - - #[inline] - fn next(&mut self) -> Option { - if self.slice.is_empty() { - None - } else { - let mut len = 1; - let mut iter = self.slice.windows(2); - while let Some([l, r]) = iter.next() { - if (self.predicate)(l, r) { - len += 1 - } else { - break; - } - } - let (head, tail) = self.slice.split_at(len); - self.slice = tail; - Some(head) - } - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - if self.slice.is_empty() { - (0, Some(0)) - } else { - (1, Some(self.slice.len())) - } - } - } - - #[easy_ext::ext(TChunkBy)] - impl [T] { - pub fn chunk_by(&self, pred: F) -> ChunkBy<'_, T, F> - where - F: FnMut(&T, &T) -> bool, - { - ChunkBy::new(self, pred) - } - } - - #[cfg(test)] - mod tests { - use super::TChunkBy; - - #[test] - fn chunk_by() { - let mut split = [0, 0, 1, 1, 1, -5].chunk_by(|a, b| a == b); - assert_eq!(split.next(), Some([0, 0].as_slice())); - assert_eq!(split.next(), Some([1, 1, 1].as_slice())); - assert_eq!(split.next(), Some([-5].as_slice())); - assert_eq!(split.next(), None); - } - } -} - #[cfg(test)] mod tests { use rstest_reuse::*; diff --git a/crates/voicevox_core/src/lib.rs b/crates/voicevox_core/src/lib.rs index bd1b438f4..49b3571c8 100644 --- a/crates/voicevox_core/src/lib.rs +++ b/crates/voicevox_core/src/lib.rs @@ -8,7 +8,6 @@ mod infer; mod macros; mod manifest; mod metas; -mod numerics; mod result; mod synthesizer; mod task; diff --git a/crates/voicevox_core/src/numerics.rs b/crates/voicevox_core/src/numerics.rs deleted file mode 100644 index b01c4d6a5..000000000 --- a/crates/voicevox_core/src/numerics.rs +++ /dev/null @@ -1,17 +0,0 @@ -use easy_ext::ext; - -#[ext(F32Ext)] -pub(crate) impl f32 { - /// 偶数丸めを行う。 - /// - /// [`round_ties_even` feature]で追加される予定の`f32::round_ties_even`の代用。 - /// - /// [`round_ties_even` feature]: https://github.com/rust-lang/rust/pull/95317 - fn round_ties_even_(self) -> f32 { - let mut rounded = self.round(); - if (self - rounded).abs() == 0.5 { - rounded = 2. * (self / 2.).round(); - } - rounded - } -} diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index 6b5a5f775..c62eccc2f 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -99,7 +99,6 @@ pub(crate) mod blocking { status::Status, InferenceSessionOptions, }, - numerics::F32Ext as _, text_analyzer::{KanaAnalyzer, OpenJTalkAnalyzer, TextAnalyzer}, AccentPhraseModel, AudioQueryModel, FullcontextExtractor, Result, StyleId, SupportedDevices, SynthesisOptions, VoiceModelId, VoiceModelMeta, @@ -343,8 +342,8 @@ pub(crate) mod blocking { // VOICEVOX ENGINEと挙動を合わせるため、四捨五入ではなく偶数丸めをする // // https://github.com/VOICEVOX/voicevox_engine/issues/552 - let phoneme_length = ((*phoneme_length * RATE).round_ties_even_() / speed_scale) - .round_ties_even_() as usize; + let phoneme_length = ((*phoneme_length * RATE).round_ties_even() / speed_scale) + .round_ties_even() as usize; let phoneme_id = phoneme_data_list[i].phoneme_id(); for _ in 0..phoneme_length {