-
Notifications
You must be signed in to change notification settings - Fork 128
実行時にモデルを読む #365
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
実行時にモデルを読む #365
Conversation
現在次の方針で考えています。
|
とりあえず動くようになりました。 |
まだ全部見れてないのですが設計方針もきれいで良さそうに感じました!! |
pub(crate) static MODEL_FILE_SET: Lazy<ModelFileSet> = Lazy::new(|| { | ||
let result = ModelFileSet::new(); | ||
if let Err(err) = &result { | ||
error!("ファイルを読み込めなかったためクラッシュします: {err}"); | ||
} | ||
result.unwrap() | ||
}); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
更新されてない場合は上書きしないオプションとかあれば便利そうなのですが、なさそうですね・・・!
There was a problem hiding this 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する形にしていきたいですね・・・!
Co-authored-by: Hiroshiba <hihokaruta@gmail.com>
#[error("{} ({}): {source}", base_error_message(VOICEVOX_RESULT_LOAD_MODEL_ERROR), path.display())] | ||
LoadModel { | ||
path: PathBuf, | ||
#[source] | ||
source: anyhow::Error, | ||
}, |
There was a problem hiding this comment.
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.
内容
今
include_bytes!
しているonnxファイルを実行時に読むようにします。関連 Issue
Fixes #362.
その他