From 8d7d7c32652356021b70655f3ccc44463c5ccb47 Mon Sep 17 00:00:00 2001 From: litagin02 Date: Sun, 25 Feb 2024 17:42:50 +0900 Subject: [PATCH] Avoid using pyworld by default --- app.py | 6 +++++- common/tts_model.py | 24 ++++++++++++++++-------- requirements.txt | 8 +++----- scripts/Update-to-Dict-Editor.bat | 4 +--- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app.py b/app.py index d99229b..e17a0a5 100644 --- a/app.py +++ b/app.py @@ -202,7 +202,9 @@ examples = [ initial_md = f""" # Style-Bert-VITS2 ver {LATEST_VERSION} 音声合成 -注意: 初期からある[jvnvのモデル](https://huggingface.co/litagin/style_bert_vits2_jvnv)は、[JVNVコーパス(言語音声と非言語音声を持つ日本語感情音声コーパス)](https://sites.google.com/site/shinnosuketakamichi/research-topics/jvnv_corpus)で学習されたモデルです。ライセンスは[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/deed.ja)です。 +- Ver 2.3で追加されたエディターのほうが実際に読み上げさせるには使いやすいかもしれません。`Editor.bat`か`python server_editor.py`で起動できます。 + +- 初期からある[jvnvのモデル](https://huggingface.co/litagin/style_bert_vits2_jvnv)は、[JVNVコーパス(言語音声と非言語音声を持つ日本語感情音声コーパス)](https://sites.google.com/site/shinnosuketakamichi/research-topics/jvnv_corpus)で学習されたモデルです。ライセンスは[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/deed.ja)です。 """ how_to_md = """ @@ -317,6 +319,7 @@ if __name__ == "__main__": value=1, step=0.05, label="音程(1以外では音質劣化)", + visible=False, # pyworldが必要 ) intonation_scale = gr.Slider( minimum=0, @@ -324,6 +327,7 @@ if __name__ == "__main__": value=1, step=0.1, label="抑揚(1以外では音質劣化)", + visible=False, # pyworldが必要 ) line_split = gr.Checkbox( diff --git a/common/tts_model.py b/common/tts_model.py index 4f3932a..de4e830 100644 --- a/common/tts_model.py +++ b/common/tts_model.py @@ -5,7 +5,7 @@ from typing import Optional, Union import gradio as gr import numpy as np -import pyworld + import torch from gradio.processing_utils import convert_to_16_bit_wav @@ -33,6 +33,13 @@ def adjust_voice(fs, wave, pitch_scale, intonation_scale): # 初期値の場合は、音質劣化を避けるためにそのまま返す return fs, wave + try: + import pyworld + except ImportError: + raise ImportError( + "pyworld is not installed. Please install it by `pip install pyworld`" + ) + # pyworldでf0を加工して合成 # pyworldよりもよいのがあるかもしれないが…… @@ -197,16 +204,17 @@ class Model: audios.append(np.zeros(int(44100 * split_interval))) audio = np.concatenate(audios) logger.info("Audio data generated successfully") - fs, audio = adjust_voice( - fs=self.hps.data.sampling_rate, - wave=audio, - pitch_scale=pitch_scale, - intonation_scale=intonation_scale, - ) + if not (pitch_scale == 1.0 and intonation_scale == 1.0): + _, audio = adjust_voice( + fs=self.hps.data.sampling_rate, + wave=audio, + pitch_scale=pitch_scale, + intonation_scale=intonation_scale, + ) with warnings.catch_warnings(): warnings.simplefilter("ignore") audio = convert_to_16_bit_wav(audio) - return (fs, audio) + return (self.hps.data.sampling_rate, audio) class ModelHolder: diff --git a/requirements.txt b/requirements.txt index b346afc..6bf329f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,14 @@ cmudict cn2an -faster-whisper>=0.10.0,<1.0.0 +faster-whisper==0.10.1 g2p_en GPUtil gradio -jaconv jieba langid librosa==0.9.2 loguru matplotlib -mecab-python3 num2words numba numpy @@ -20,12 +18,12 @@ pyloudnorm # pyopenjtalk-prebuilt # Should be manually uninstalled pyopenjtalk-dict pypinyin -pyworld +# pyworld # Not supported on Windows without Cython... PyYAML requests safetensors scipy tensorboard -torch>=2.1,<2.2 # For users without GPU or colab +torch>=2.1,<2.2 transformers umap-learn diff --git a/scripts/Update-to-Dict-Editor.bat b/scripts/Update-to-Dict-Editor.bat index e10060d..5fde8fc 100644 --- a/scripts/Update-to-Dict-Editor.bat +++ b/scripts/Update-to-Dict-Editor.bat @@ -28,14 +28,12 @@ xcopy /QSY .\Style-Bert-VITS2-dev\ .\Style-Bert-VITS2\ rmdir /s /q Style-Bert-VITS2-dev if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% ) -@REM 仮想環境のpip requirements.txtを更新 +@REM 仮想環境を有効化 echo call .\Style-Bert-VITS2\scripts\activate.bat call .\Style-Bert-VITS2\venv\Scripts\activate.bat if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% ) -pause - @REM pyopenjtalk-prebuiltやpyopenjtalkが入っていたら削除 echo python -m pip uninstall -y pyopenjtalk-prebuilt pyopenjtalk python -m pip uninstall -y pyopenjtalk-prebuilt pyopenjtalk