Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: InferenceFailedRunModel #823

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/voicevox_core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Error {
ErrorRepr::GetSupportedDevices(_) => ErrorKind::GetSupportedDevices,
ErrorRepr::StyleNotFound { .. } => ErrorKind::StyleNotFound,
ErrorRepr::ModelNotFound { .. } => ErrorKind::ModelNotFound,
ErrorRepr::InferenceFailed { .. } => ErrorKind::InferenceFailed,
ErrorRepr::RunModel { .. } => ErrorKind::RunModel,
ErrorRepr::ExtractFullContextLabel(_) => ErrorKind::ExtractFullContextLabel,
ErrorRepr::ParseKana(_) => ErrorKind::ParseKana,
ErrorRepr::LoadUserDict(_) => ErrorKind::LoadUserDict,
Expand Down Expand Up @@ -97,7 +97,7 @@ pub(crate) enum ErrorRepr {
ModelNotFound { model_id: VoiceModelId },

#[error("推論に失敗しました")]
InferenceFailed(#[source] anyhow::Error),
RunModel(#[source] anyhow::Error),

#[error(transparent)]
ExtractFullContextLabel(#[from] FullContextLabelError),
Expand Down Expand Up @@ -149,7 +149,7 @@ pub enum ErrorKind {
/// 音声モデルIDに対する音声モデルが見つからなかった。
ModelNotFound,
/// 推論に失敗した。
InferenceFailed,
RunModel,
/// コンテキストラベル出力に失敗した。
ExtractFullContextLabel,
/// AquesTalk風記法のテキストの解析に失敗した。
Expand Down
2 changes: 1 addition & 1 deletion crates/voicevox_core/src/infer/session_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<R: InferenceRuntime, I: InferenceInputSignature> InferenceSessionCell<R, I>
) -> crate::Result<<I::Signature as InferenceSignature>::Output> {
let inner = &mut self.inner.lock().unwrap();
(|| R::run(input.make_run_context::<R>(inner)?)?.try_into())()
.map_err(ErrorRepr::InferenceFailed)
.map_err(ErrorRepr::RunModel)
.map_err(Into::into)
}
}
2 changes: 1 addition & 1 deletion 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.

2 changes: 1 addition & 1 deletion crates/voicevox_core_c_api/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) fn into_result_code_with_error(result: CApiResult<()>) -> VoicevoxRes
GetSupportedDevices => VOICEVOX_RESULT_GET_SUPPORTED_DEVICES_ERROR,
StyleNotFound => VOICEVOX_RESULT_STYLE_NOT_FOUND_ERROR,
ModelNotFound => VOICEVOX_RESULT_MODEL_NOT_FOUND_ERROR,
InferenceFailed => VOICEVOX_RESULT_INFERENCE_ERROR,
RunModel => VOICEVOX_RESULT_RUN_MODEL_ERROR,
ExtractFullContextLabel => VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR,
ParseKana => VOICEVOX_RESULT_PARSE_KANA_ERROR,
LoadUserDict => VOICEVOX_RESULT_LOAD_USER_DICT_ERROR,
Expand Down
4 changes: 2 additions & 2 deletions crates/voicevox_core_c_api/src/result_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum VoicevoxResultCode {
/// 音声モデルIDに対する音声モデルが見つからなかった
VOICEVOX_RESULT_MODEL_NOT_FOUND_ERROR = 7,
/// 推論に失敗した
VOICEVOX_RESULT_INFERENCE_ERROR = 8,
VOICEVOX_RESULT_RUN_MODEL_ERROR = 8,
/// コンテキストラベル出力に失敗した
VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR = 11,
/// 無効なutf8文字列が入力された
Expand Down Expand Up @@ -83,7 +83,7 @@ pub(crate) const fn error_result_to_message(result_code: VoicevoxResultCode) ->
"指定されたIDに対する音声モデルが見つかりませんでした。読み込まれていないか、読み込み\
が既に解除されています"
),
VOICEVOX_RESULT_INFERENCE_ERROR => cstr!("推論に失敗しました"),
VOICEVOX_RESULT_RUN_MODEL_ERROR => cstr!("推論に失敗しました"),
VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR => {
cstr!("入力テキストからのフルコンテキストラベル抽出に失敗しました")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl assert_cdylib::TestCase for TestCase {
c_api::VoicevoxResultCode_VOICEVOX_RESULT_GPU_SUPPORT_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_STYLE_NOT_FOUND_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_MODEL_NOT_FOUND_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_INFERENCE_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_RUN_MODEL_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_INVALID_UTF8_INPUT_ERROR,
c_api::VoicevoxResultCode_VOICEVOX_RESULT_PARSE_KANA_ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import jp.hiroshiba.voicevoxcore.exceptions.InferenceFailedException;
import jp.hiroshiba.voicevoxcore.exceptions.InvalidModelDataException;
import jp.hiroshiba.voicevoxcore.exceptions.RunModelException;

/**
* 音声シンセサイザ。
Expand Down Expand Up @@ -99,11 +99,10 @@ public boolean isLoadedVoiceModel(UUID voiceModelId) {
* @param kana AquesTalk風記法。
* @param styleId スタイルID。
* @return {@link AudioQuery}。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public AudioQuery createAudioQueryFromKana(String kana, int styleId)
throws InferenceFailedException {
public AudioQuery createAudioQueryFromKana(String kana, int styleId) throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand All @@ -123,10 +122,10 @@ public AudioQuery createAudioQueryFromKana(String kana, int styleId)
* @param text 日本語のテキスト。
* @param styleId スタイルID。
* @return {@link AudioQuery}。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public AudioQuery createAudioQuery(String text, int styleId) throws InferenceFailedException {
public AudioQuery createAudioQuery(String text, int styleId) throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand All @@ -146,11 +145,11 @@ public AudioQuery createAudioQuery(String text, int styleId) throws InferenceFai
* @param kana AquesTalk風記法。
* @param styleId スタイルID。
* @return {@link AccentPhrase} のリスト。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public List<AccentPhrase> createAccentPhrasesFromKana(String kana, int styleId)
throws InferenceFailedException {
throws RunModelException {
String accentPhrasesJson = rsAccentPhrasesFromKana(kana, styleId);
Gson gson = new Gson();
AccentPhrase[] rawAccentPhrases = gson.fromJson(accentPhrasesJson, AccentPhrase[].class);
Expand All @@ -166,11 +165,10 @@ public List<AccentPhrase> createAccentPhrasesFromKana(String kana, int styleId)
* @param text 日本語のテキスト。
* @param styleId スタイルID。
* @return {@link AccentPhrase} のリスト。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public List<AccentPhrase> createAccentPhrases(String text, int styleId)
throws InferenceFailedException {
public List<AccentPhrase> createAccentPhrases(String text, int styleId) throws RunModelException {
String accentPhrasesJson = rsAccentPhrases(text, styleId);
Gson gson = new Gson();
AccentPhrase[] rawAccentPhrases = gson.fromJson(accentPhrasesJson, AccentPhrase[].class);
Expand All @@ -186,11 +184,11 @@ public List<AccentPhrase> createAccentPhrases(String text, int styleId)
* @param accentPhrases 変更元のアクセント句の配列。
* @param styleId スタイルID。
* @return 変更後のアクセント句の配列。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public List<AccentPhrase> replaceMoraData(List<AccentPhrase> accentPhrases, int styleId)
throws InferenceFailedException {
throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand All @@ -206,11 +204,11 @@ public List<AccentPhrase> replaceMoraData(List<AccentPhrase> accentPhrases, int
* @param accentPhrases 変更元のアクセント句の配列。
* @param styleId スタイルID。
* @return 変更後のアクセント句の配列。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public List<AccentPhrase> replacePhonemeLength(List<AccentPhrase> accentPhrases, int styleId)
throws InferenceFailedException {
throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand All @@ -226,11 +224,11 @@ public List<AccentPhrase> replacePhonemeLength(List<AccentPhrase> accentPhrases,
* @param accentPhrases 変更元のアクセント句の配列。
* @param styleId スタイルID。
* @return 変更後のアクセント句の配列。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public List<AccentPhrase> replaceMoraPitch(List<AccentPhrase> accentPhrases, int styleId)
throws InferenceFailedException {
throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand Down Expand Up @@ -293,43 +291,40 @@ public TtsConfigurator tts(String text, int styleId) {
private native boolean rsIsLoadedVoiceModel(UUID voiceModelId);

@Nonnull
private native String rsAudioQueryFromKana(String kana, int styleId)
throws InferenceFailedException;
private native String rsAudioQueryFromKana(String kana, int styleId) throws RunModelException;

@Nonnull
private native String rsAudioQuery(String text, int styleId) throws InferenceFailedException;
private native String rsAudioQuery(String text, int styleId) throws RunModelException;

@Nonnull
private native String rsAccentPhrasesFromKana(String kana, int styleId)
throws InferenceFailedException;
private native String rsAccentPhrasesFromKana(String kana, int styleId) throws RunModelException;

@Nonnull
private native String rsAccentPhrases(String text, int styleId) throws InferenceFailedException;
private native String rsAccentPhrases(String text, int styleId) throws RunModelException;

@Nonnull
private native String rsReplaceMoraData(String accentPhrasesJson, int styleId, boolean kana)
throws InferenceFailedException;
throws RunModelException;

@Nonnull
private native String rsReplacePhonemeLength(String accentPhrasesJson, int styleId, boolean kana)
throws InferenceFailedException;
throws RunModelException;

@Nonnull
private native String rsReplaceMoraPitch(String accentPhrasesJson, int styleId, boolean kana)
throws InferenceFailedException;
throws RunModelException;

@Nonnull
private native byte[] rsSynthesis(
String queryJson, int styleId, boolean enableInterrogativeUpspeak)
throws InferenceFailedException;
String queryJson, int styleId, boolean enableInterrogativeUpspeak) throws RunModelException;

@Nonnull
private native byte[] rsTtsFromKana(String kana, int styleId, boolean enableInterrogativeUpspeak)
throws InferenceFailedException;
throws RunModelException;

@Nonnull
private native byte[] rsTts(String text, int styleId, boolean enableInterrogativeUpspeak)
throws InferenceFailedException;
throws RunModelException;

private native void rsDrop();

Expand Down Expand Up @@ -436,10 +431,10 @@ public SynthesisConfigurator interrogativeUpspeak(boolean interrogativeUpspeak)
* {@link AudioQuery} から音声合成する。
*
* @return 音声データ。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public byte[] execute() throws InferenceFailedException {
public byte[] execute() throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand Down Expand Up @@ -481,10 +476,10 @@ public TtsFromKanaConfigurator interrogativeUpspeak(boolean interrogativeUpspeak
* {@link AudioQuery} から音声合成する。
*
* @return 音声データ。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public byte[] execute() throws InferenceFailedException {
public byte[] execute() throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand Down Expand Up @@ -524,10 +519,10 @@ public TtsConfigurator interrogativeUpspeak(boolean interrogativeUpspeak) {
* {@link AudioQuery} から音声合成する。
*
* @return 音声データ。
* @throws InferenceFailedException 推論に失敗した場合。
* @throws RunModelException 推論に失敗した場合。
*/
@Nonnull
public byte[] execute() throws InferenceFailedException {
public byte[] execute() throws RunModelException {
if (!Utils.isU32(styleId)) {
throw new IllegalArgumentException("styleId");
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package jp.hiroshiba.voicevoxcore.exceptions;

import java.io.IOException;

/** 推論に失敗した。 */
public class RunModelException extends IOException {
public RunModelException(String message) {
super(message);
}

public RunModelException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;
import jp.hiroshiba.voicevoxcore.exceptions.InferenceFailedException;
import jp.hiroshiba.voicevoxcore.exceptions.InvalidModelDataException;
import jp.hiroshiba.voicevoxcore.exceptions.RunModelException;
import org.junit.jupiter.api.Test;

class SynthesizerTest extends TestUtils {
Expand Down Expand Up @@ -67,7 +67,7 @@ void checkModel() throws InvalidModelDataException {
}

@Test
void checkAudioQuery() throws InferenceFailedException, InvalidModelDataException {
void checkAudioQuery() throws RunModelException, InvalidModelDataException {
VoiceModel model = loadModel();
Onnxruntime onnxruntime = loadOnnxruntime();
OpenJtalk openJtalk = loadOpenJtalk();
Expand All @@ -79,7 +79,7 @@ void checkAudioQuery() throws InferenceFailedException, InvalidModelDataExceptio
}

@Test
void checkAccentPhrases() throws InferenceFailedException, InvalidModelDataException {
void checkAccentPhrases() throws RunModelException, InvalidModelDataException {
VoiceModel model = loadModel();
OpenJtalk openJtalk = loadOpenJtalk();
Onnxruntime onnxruntime = loadOnnxruntime();
Expand Down Expand Up @@ -110,7 +110,7 @@ void checkAccentPhrases() throws InferenceFailedException, InvalidModelDataExcep
}

@Test
void checkTts() throws InferenceFailedException, InvalidModelDataException {
void checkTts() throws RunModelException, InvalidModelDataException {
VoiceModel model = loadModel();
Onnxruntime onnxruntime = loadOnnxruntime();
OpenJtalk openJtalk = loadOpenJtalk();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

import java.nio.file.Files;
import java.nio.file.Path;
import jp.hiroshiba.voicevoxcore.exceptions.InferenceFailedException;
import jp.hiroshiba.voicevoxcore.exceptions.InvalidModelDataException;
import jp.hiroshiba.voicevoxcore.exceptions.LoadUserDictException;
import jp.hiroshiba.voicevoxcore.exceptions.RunModelException;
import org.junit.jupiter.api.Test;

class UserDictTest extends TestUtils {

// 辞書ロードのテスト。
// 辞書ロード前後でkanaが異なることを確認する
@Test
void checkLoad()
throws InferenceFailedException, InvalidModelDataException, LoadUserDictException {
void checkLoad() throws RunModelException, InvalidModelDataException, LoadUserDictException {
VoiceModel model = loadModel();
Onnxruntime onnxruntime = loadOnnxruntime();
OpenJtalk openJtalk = loadOpenJtalk();
Expand Down
2 changes: 1 addition & 1 deletion crates/voicevox_core_java_api/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
GetSupportedDevices,
StyleNotFound,
ModelNotFound,
InferenceFailed,
RunModel,
ExtractFullContextLabel,
ParseKana,
LoadUserDict,
Expand Down
Loading
Loading