Skip to content

haoheliu/voicefixerのONNXエクスポート/推論サンプル

License

Notifications You must be signed in to change notification settings

Kazuhito00/VoiceFixer-ONNX

Repository files navigation

VoiceFixer-ONNX

haoheliu/voicefixerのONNXエクスポート/推論サンプルです。

image

Requirement

  • エクスポート用:requirements_for_export.txt
  • 推論用:requirements_for_inference.txt

Model

モデルファイルは以下の構成で配置してください。

model
 │  voicefixer_restorer.onnx
 │  voicefixer_vocoder.onnx
 └─ckpt
     ├─analysis_module
     │  └─checkpoints
     │       vf.ckpt
     └─synthesis_module
         └─44100
             model.ckpt-1490000_trimed.pt

モデルファイルは以下にアップロードしています。

Export

Warning

ONNX出力のためにモデル構造を一部変更しています。
そのため、推論精度がオリジナルのPyTorchモデルと異なります。

python export_onnx.py

これにより、modelディレクトリに以下のファイルが作成されます:

  • voicefixer_restorer.onnx - ノイズ除去モデル
  • voicefixer_vocoder.onnx - 音声合成モデル

以下のオプション指定が可能です。

# 特定のモデルのみをエクスポート
python export_onnx.py --model restorer    # Restorerのみ
python export_onnx.py --model vocoder     # Vocoderのみ
python export_onnx.py --model all         # 両方(デフォルト)

# 出力ディレクトリを指定
python export_onnx.py -o custom_models/

# ONNXのopsetバージョンを指定
python export_onnx.py --opset 15

# Restorerの固定タイムステップを変更(64の倍数である必要があります)
python export_onnx.py --time_steps 256

Inference

python inference_onnx.py -i input.wav -o output.wav

以下のオプション指定が可能です。

# カスタムモデルパスを指定
python inference_onnx.py -i input.wav -o output.wav \
    --restorer custom_models/voicefixer_restorer.onnx \
    --vocoder custom_models/voicefixer_vocoder.onnx

# GPUアクセラレーションを使用
python inference_onnx.py -i input.wav -o output.wav --cuda

# セグメント長を手動で指定(秒)
python inference_onnx.py -i input.wav -o output.wav --segment-length 2.0

# カスタム固定タイムステップ(エクスポート時と一致させる必要があります)
python inference_onnx.py -i input.wav -o output.wav --fixed_time_steps 256

Reference

Author

高橋かずひと(https://twitter.com/KzhtTkhs)

License

VoiceFixer-ONNX is under MIT License.

About

haoheliu/voicefixerのONNXエクスポート/推論サンプル

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages