Skip to content

Conversation

qryxip
Copy link
Member

@qryxip qryxip commented Jan 4, 2023

内容

include_bytes!しているonnxファイルを実行時に読むようにします。

関連 Issue

Fixes #362.

その他

@qryxip
Copy link
Member Author

qryxip commented Jan 4, 2023

現在次の方針で考えています。

  1. ファイルの内容はlazy_staticで、今まで通りグローバル変数として持つ。Statusには持たせない
    1. root_dirは環境変数VV_MODELS_ROOT_DIRで制御するようにする。デフォルトは$0/model
    2. もしファイルが読めなかったりした場合エラーを出したりせずにpanicする
  2. ファイルのあつまりのことをコード中で何と呼ぶかについては、 voicevox_coreのクラス設計discussion #280 に出ていたVvmとしておく
    • SHAREVOXは"library"と呼んでいたはず

@qryxip qryxip marked this pull request as ready for review January 4, 2023 03:23
@qryxip
Copy link
Member Author

qryxip commented Jan 4, 2023

とりあえず動くようになりました。

@Hiroshiba
Copy link
Member

まだ全部見れてないのですが設計方針もきれいで良さそうに感じました!!
特にビルド周りの書き換えが1行だけなのがきれい。
ありがとうございます・・・!!

Comment on lines +22 to +28
pub(crate) static MODEL_FILE_SET: Lazy<ModelFileSet> = Lazy::new(|| {
let result = ModelFileSet::new();
if let Err(err) = &result {
error!("ファイルを読み込めなかったためクラッシュします: {err}");
}
result.unwrap()
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この「クラッシュ」ですが、run.exeごと巻き込みます (これはLinuxですが、多分Windowsでも同様?)。

./run
Warning: cpu_num_threads is set to 0. ( The library leaves the decision to the synthesis runtime )
2023-01-04T13:24:11.008713Z ERROR voicevox_core::status: ファイルを読み込めなかったためクラッシュします: failed to open file `/home/ryo/src/github.com/VOICEVOX/voicevox_engine/dist/run/model/metas.json`
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: failed to open file `/home/ryo/src/github.com/VOICEVOX/voicevox_engine/dist/run/model/metas.json`

Caused by:
    No such file or directory (os error 2)', crates/voicevox_core/src/status.rs:27:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
zsh: IOT instruction (core dumped)  ./run

use fs_extra::dir::CopyOptions;

fn main() -> anyhow::Result<()> {
fs_extra::dir::copy(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新されてない場合は上書きしないオプションとかあれば便利そうなのですが、なさそうですね・・・!

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

Rustコードの詳しいとこまで見れてないのですが、ロジックは問題なさそうに感じました!
とりあえず今回はstaticに全部置いといて、ゆくゆくは必要になったときに遅延loadする形にしていきたいですね・・・!

Comment on lines +27 to +32
#[error("{} ({}): {source}", base_error_message(VOICEVOX_RESULT_LOAD_MODEL_ERROR), path.display())]
LoadModel {
path: PathBuf,
#[source]
source: anyhow::Error,
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ファイル自体が読めなかった場合:

2023-01-05T01:56:27.988287Z ERROR voicevox_core::status: ファイルを読み込めなかったためクラッシュします: failed to open file `/home/ryo/src/github.com/VOICEVOX/voicevox_core/example/cpp/unix/./voicevox_core/model/predict_duration-0.onnx`
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: failed to open file `/home/ryo/src/github.com/VOICEVOX/voicevox_core/example/cpp/unix/./voicevox_core/model/predict_duration-0.onnx`

Caused by:
    No such file or directory (os error 2)', crates/voicevox_core/src/status.rs:30:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
./run.bash: line 6: 63023 Aborted                 (core dumped) ./build/simple_tts "$1"

ファイルは読めたけどdecryptに失敗した場合:

Error(Display): modelデータ読み込みに失敗しました (/home/ryo/src/github.com/VOICEVOX/voicevox_core/example/cpp/unix/./voicevox_core/model/predict_duration-0.onnx): 不正なモデルファイルです

decryptはできたけどonnxモデルとして正しくなかった場合:

Error(Display): modelデータ読み込みに失敗しました (/home/ryo/src/github.com/VOICEVOX/voicevox_core/example/cpp/unix/./voicevox_core/model/predict_duration-0.onnx): Failed to create session: Error calling ONNX Runtime C function: No graph was found in the protobuf.

@qwerty2501 qwerty2501 merged commit a787f6d into VOICEVOX:main Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

モデルの数が多いとビルドできない
3 participants