1. 声紋認識埋め込みベクトル抽出
参考:
https://aistudio.baidu.com/aistudio/projectdetail/4353348
https://github.com/PaddlePaddle/PaddleSpeech/blob/develop/demos/speaker_verification/README_cn.md
https://aistudio.baidu.com/aistudio/projectdetail/4353348
-
注
1) パドルスピーチのインストールについては、https:
//blog.csdn.net/weixin_42357472/article/details/131269539 ?spm=1001.2014.3001.5502 を参照してください。2) コードの実行中、モデルのダウンロード時にエラーが報告されます。 RuntimeError: https://paddlespeech.bj.bcebos.com/vector からダウンロードします。
プロンプト ダウンロード リンク https://paddlespeech.bj.bcebos.com/vector/voxceleb/sv0_ecapa_tdnn_voxceleb12_ckpt_0_2_0.tar.gz によると、paddlespeech モデルは通常 C:\Users\long の下に配置されており、自分でオフラインでダウンロードできます。 paddlespeech\models; note ここでのモデルのディレクトリ構造は一般的に次のようになり、tar パッケージをまとめる必要があります
使用
** パドルスピーチ抽出ベクトルの次元は 192 です。
1) コマンドラインの使用:
paddlespeech vector --task spk --input zh.wav
paddlespeech vector --task score --input "./85236145389.wav ./123456789.wav"
2) ベクトル抽出コードは以下を使用します。
from paddlespeech.cli.vector import VectorExecutor
vec = VectorExecutor()
result = vec(audio_file="zh.wav")
from paddlespeech.cli.vector import VectorExecutor
vector_executor = VectorExecutor()
audio_emb = vector_executor(
model='ecapatdnn_voxceleb12',
sample_rate=16000,
config=None, # Set `config` and `ckpt_path` to None to use pretrained model.
ckpt_path=None,
audio_file='./85236145389.wav',
device=paddle.get_device())
print('Audio embedding Result: \n{}'.format(audio_emb))
3) 声紋類似度の計算:
import paddle
from paddlespeech.cli.vector import VectorExecutor
vector_executor = VectorExecutor()
audio_emb = vector_executor(
model='ecapatdnn_voxceleb12',
sample_rate=16000,
config=None, # Set `config` and `ckpt_path` to None to use pretrained model.
ckpt_path=None,
audio_file='./85236145389.wav',
device=paddle.get_device())
print(audio_emb.shape)
print('Audio embedding Result: \n{}'.format(audio_emb))
test_emb = vector_executor(
model='ecapatdnn_voxceleb12',
sample_rate=16000,
config=None, # Set `config` and `ckpt_path` to None to use pretrained model.
ckpt_path=None,
audio_file='./123456789.wav',
device=paddle.get_device())
print(test_emb.shape)
print('Test embedding Result: \n{}'.format(test_emb))
# score range [0, 1]
score = vector_executor.get_embeddings_score(audio_emb, test_emb)
print(f"Eembeddings Score: {score}")
CosineSimilarity は基礎となる類似度の計算に使用され、結果が大きいほど優れています。
2. TTS テキスト読み上げ
参考:
https://aistudio.baidu.com/aistudio/projectdetail/5237474
https://www.jianshu.com/p/a7522ca6dec4
https://github.com/PaddlePaddle/PaddleSpeech/blob/develop/demos/text_to_speech/README_cn.md
1) プロセス中にダウンロードする必要がある TTS 音響関連モデル (ネットワークが良好でない場合は、以下のリンクをオフラインでダウンロードできます):
PaddleSpeech支持的声学模型:
['speedyspeech_csmsc-zh', 'fastspeech2_csmsc-zh', 'fastspeech2_canton-canton', 'fastspeech2_ljspeech-en', 'fastspeech2_aishell3-zh', 'fastspeech2_vctk-en', 'fastspeech2_cnndecoder_csmsc-zh', 'fastspeech2_mix-mix', 'fastspeech2_male-zh', 'fastspeech2_male-en', 'fastspeech2_male-mix', 'tacotron2_csmsc-zh', 'tacotron2_ljspeech-en', 'pwgan_csmsc-zh', 'pwgan_ljspeech-en', 'pwgan_aishell3-zh', 'pwgan_vctk-en', 'pwgan_male-zh', 'mb_melgan_csmsc-zh', 'style_melgan_csmsc-zh', 'hifigan_csmsc-zh', 'hifigan_ljspeech-en', 'hifigan_aishell3-zh', 'hifigan_vctk-en', 'hifigan_male-zh', 'wavernn_csmsc-zh', 'fastspeech2_mix-zh', 'fastspeech2_mix-en', 'pwgan_male-en', 'pwgan_male-mix', 'hifigan_male-en', 'hifigan_male-mix']
https://paddlespeech.bj.bcebos.com/Parakeet/published_models/fastspeech2/fastspeech2_nosil_baker_ckpt_0.4.zip
https://paddlespeech.bj.bcebos.com/Parakeet/published_models/hifigan/hifigan_csmsc_ckpt_0.1.1.zip
https://paddlespeech.bj.bcebos.com/Parakeet/published_models/g2p/G2PWModel_1.1.zip
https://paddlespeech.bj.bcebos.com/Parakeet/published_models/fastspeech2/fastspeech2_canton_ckpt_1.4.0.zip ##広東語モデル
fastspeech2_csmsc-zh、hifigan_csmsc-zh これら 2 つのモデルは 1.0 フォルダーに配置する必要があります。パッケージを圧縮することを忘れないでください。これを入力します。G2PWModel はモデル ディレクトリに直接配置されます
*** am='fastspeech2_csmsc', # TTS タスクの音響モデル
voc='hifigan_csmsc', # TTS タスクのボコーダー
G2PWModel は音素モデルです***
2) nl bert 関連パッケージのダウンロードを使用する必要があります。
デフォルトでは、次のアドレスに配置されます:
https://bj.bcebos.com/paddle-hapi/models/bert/bert-base-chinese-vocab.txt
ssl をダウンロードするなどの問題がある場合は、***Lib\site-packages\paddlenlp\utils にある downloader.py を変更し、対応するリクエストの位置 (191 行目と 440 行目) に verify=False を追加します。
request.get('*****'',verify=False)
使用
1) コマンドライン
paddlespeech tts --input "湖北十堰竹山县的桃花摇曳多姿,和蓝天白云一起,构成一幅美丽春景。" --output output1.wav --am fastspeech2_csmsc --voc hifigan_csmsc --lang zh --spk_id 174
2) コード
from paddlespeech.cli.tts import TTSExecutor
tts_executor = TTSExecutor()
wav_file = tts_executor(
text='湖北十堰竹山县的桃花摇曳多姿,和蓝天白云一起,构成一幅美丽春景。',
output='output.wav', # 输出音频的路径
am='fastspeech2_csmsc', # TTS任务的声学模型
voc='hifigan_csmsc', # TTS任务的声码器
lang='zh', # TTS任务的语言
spk_id=174, # 说话人ID
)
広東語合成
from paddlespeech.cli.tts import TTSExecutor
tts_executor = TTSExecutor()
wav_file = tts_executor(
text='湖北十堰竹山县的桃花摇曳多姿,和蓝天白云一起,构成一幅美丽春景。',
output='output5.wav', # 输出音频的路径
# am='fastspeech2_csmsc', # TTS任务的声学模型
am="fastspeech2_canton",
voc='hifigan_csmsc', # TTS任务的声码器
lang='canton', # TTS任务的语言
spk_id=2, # 说话人ID
)