Skip to content

Commit

Permalink
anyhowやめた
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty2501 committed May 10, 2022
1 parent c54282c commit 3c677b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
1 change: 0 additions & 1 deletion voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
anyhow = "1.0.57"
derive-getters = "0.2.0"
derive-new = "0.5.9"
thiserror = "1.0.31"
Expand Down
19 changes: 7 additions & 12 deletions voicevox_core/src/c_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ impl<T> From<Result<T>> for VoicevoxResultCode {
if let Some(err) = result.err() {
eprintln!("{}", err);
dbg!(&err);
if let Ok(err) = err.downcast::<Error>() {
match err {
Error::NotLoadedOpenjtalkDict => {
VoicevoxResultCode::VOICEVOX_RESULT_NOT_LOADED_OPENJTALK_DICT
}
match err {
Error::NotLoadedOpenjtalkDict => {
VoicevoxResultCode::VOICEVOX_RESULT_NOT_LOADED_OPENJTALK_DICT
}
} else {
panic!()
}
} else {
VoicevoxResultCode::VOICEVOX_RESULT_SUCCEED
Expand Down Expand Up @@ -98,7 +94,7 @@ pub extern "C" fn yukarin_s_forward(
speaker_id: *const i64,
output: *mut f32,
) -> bool {
let result = internal::yukarin_s_forward(length, phoneme_list, speaker_id, output);
let result = internal::yukarin_s_forward(length, phoneme_list, &unsafe { *speaker_id }, output);
if let Some(err) = result.err() {
unsafe {
ERROR_MESSAGE = format!("{}\0", err);
Expand Down Expand Up @@ -164,16 +160,15 @@ pub extern "C" fn decode_forward(

#[no_mangle]
pub extern "C" fn voicevox_load_openjtalk_dict(dict_path: *const c_char) -> VoicevoxResultCode {
let dict_path = unsafe { CStr::from_ptr(dict_path).to_str().unwrap() };
internal::voicevox_load_openjtalk_dict(dict_path).into()
internal::voicevox_load_openjtalk_dict(unsafe { CStr::from_ptr(dict_path) }).into()
}

#[no_mangle]
pub extern "C" fn voicevox_tts(
text: *const c_char,
speaker_id: i64,
output_binary_size: *mut usize,
output_wav: *const *mut u8,
output_wav: *mut *mut u8,
) -> VoicevoxResultCode {
internal::voicevox_tts(
unsafe { CStr::from_ptr(text) },
Expand All @@ -189,7 +184,7 @@ pub extern "C" fn voicevox_tts_from_kana(
text: *const c_char,
speaker_id: i64,
output_binary_size: *mut usize,
output_wav: *const *mut u8,
output_wav: *mut *mut u8,
) -> VoicevoxResultCode {
internal::voicevox_tts_from_kana(
unsafe { CStr::from_ptr(text) },
Expand Down
4 changes: 2 additions & 2 deletions voicevox_core/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn supported_devices() -> &'static CStr {
pub fn yukarin_s_forward(
length: i64,
phoneme_list: *const i64,
speaker_id: *const i64,
speaker_id: &i64,
output: *mut f32,
) -> Result<()> {
unimplemented!()
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn decode_forward(
unimplemented!()
}

pub fn voicevox_load_openjtalk_dict(dict_path: impl AsRef<Path>) -> Result<()> {
pub fn voicevox_load_openjtalk_dict(dict_path: &CStr) -> Result<()> {
unimplemented!()
}
pub fn voicevox_tts(
Expand Down
4 changes: 2 additions & 2 deletions voicevox_core/src/result.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub use anyhow::Context as _;
pub use anyhow::Result;
use super::*;
pub type Result<T> = std::result::Result<T, Error>;

0 comments on commit 3c677b6

Please sign in to comment.