Skip to content

Commit

Permalink
VOICEVOX#558 に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Sep 3, 2023
1 parent d4b8b0b commit d6489cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 2 additions & 4 deletions crates/voicevox_core/src/__internal.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// FIXME: 要議論: https://github.com/VOICEVOX/voicevox_core/issues/595

use std::fmt::Display;

pub fn to_zenkaku(surface: &str) -> String {
crate::user_dict::to_zenkaku(surface)
}

pub fn validate_pronunciation(pronunciation: &str) -> std::result::Result<(), impl Display> {
crate::user_dict::validate_pronunciation(pronunciation)
pub fn validate_pronunciation(pronunciation: &str) -> crate::Result<()> {
crate::user_dict::validate_pronunciation(pronunciation).map_err(Into::into)
}
7 changes: 7 additions & 0 deletions crates/voicevox_core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ impl From<E> for Error {
}
}

// FIXME: `ErrorRepr::InvalidWord`を`#[error(transparent)]`にする
impl From<InvalidWordError> for Error {
fn from(err: InvalidWordError) -> Self {
ErrorRepr::InvalidWord(err).into()
}
}

impl Error {
/// 対応する[`ErrorKind`]を返す。
pub fn kind(&self) -> ErrorKind {
Expand Down
4 changes: 2 additions & 2 deletions crates/voicevox_core_java_api/src/user_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ extern "system" fn Java_jp_hiroshiba_voicevoxcore_UserDict_rsToZenkaku<'local>(
let text = env.get_string(&text)?;
let text = text.to_str()?;

let text = voicevox_core::to_zenkaku(text);
let text = voicevox_core::__internal::to_zenkaku(text);

let text = env.new_string(text)?;
Ok(text.into_raw())
Expand All @@ -230,7 +230,7 @@ extern "system" fn Java_jp_hiroshiba_voicevoxcore_UserDict_rsValidatePronunciati
let text = env.get_string(&text)?;
let text = text.to_str()?;

voicevox_core::validate_pronunciation(text)?;
voicevox_core::__internal::validate_pronunciation(text)?;

Ok(())
})
Expand Down

0 comments on commit d6489cc

Please sign in to comment.