Hecheng0625
commited on
Commit
•
575dc20
1
Parent(s):
31f7849
Update README.md
Browse files
README.md
CHANGED
@@ -108,7 +108,39 @@ with torch.no_grad():
|
|
108 |
sf.write("recon.wav", recon_wav[0][0].cpu().numpy(), 16000)
|
109 |
```
|
110 |
|
111 |
-
FACodec can achieve zero-shot voice conversion with FACodecRedecoder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
```python
|
113 |
from Amphion.models.codec.ns3_codec import FACodecRedecoder
|
114 |
|
|
|
108 |
sf.write("recon.wav", recon_wav[0][0].cpu().numpy(), 16000)
|
109 |
```
|
110 |
|
111 |
+
FACodec can achieve zero-shot voice conversion with FACodecEncoderV2/FACodecDecoderV2 or FACodecRedecoder
|
112 |
+
```python
|
113 |
+
from Amphion.models.codec.ns3_codec import FACodecEncoderV2, FACodecDecoderV2
|
114 |
+
|
115 |
+
# Same parameters as FACodecEncoder/FACodecDecoder
|
116 |
+
fa_encoder_v2 = FACodecEncoderV2(...)
|
117 |
+
fa_decoder_v2 = FACodecDecoderV2(...)
|
118 |
+
|
119 |
+
encoder_v2_ckpt = hf_hub_download(repo_id="amphion/naturalspeech3_facodec", filename="ns3_facodec_encoder_v2.bin")
|
120 |
+
decoder_v2_ckpt = hf_hub_download(repo_id="amphion/naturalspeech3_facodec", filename="ns3_facodec_decoder_v2.bin")
|
121 |
+
|
122 |
+
fa_encoder_v2.load_state_dict(torch.load(encoder_v2_ckpt))
|
123 |
+
fa_decoder_v2.load_state_dict(torch.load(decoder_v2_ckpt))
|
124 |
+
|
125 |
+
with torch.no_grad():
|
126 |
+
enc_out_a = fa_encoder_v2(wav_a)
|
127 |
+
prosody_a = fa_encoder_v2.get_prosody_feature(wav_a)
|
128 |
+
enc_out_b = fa_encoder_v2(wav_b)
|
129 |
+
prosody_b = fa_encoder_v2.get_prosody_feature(wav_b)
|
130 |
+
|
131 |
+
vq_post_emb_a, vq_id_a, _, quantized, spk_embs_a = fa_decoder_v2(
|
132 |
+
enc_out_a, prosody_a, eval_vq=False, vq=True
|
133 |
+
)
|
134 |
+
vq_post_emb_b, vq_id_b, _, quantized, spk_embs_b = fa_decoder_v2(
|
135 |
+
enc_out_b, prosody_b, eval_vq=False, vq=True
|
136 |
+
)
|
137 |
+
|
138 |
+
vq_post_emb_a_to_b = fa_decoder_v2.vq2emb(vq_id_a, use_residual=False)
|
139 |
+
recon_wav_a_to_b = fa_decoder_v2.inference(vq_post_emb_a_to_b, spk_embs_b)
|
140 |
+
```
|
141 |
+
|
142 |
+
or
|
143 |
+
|
144 |
```python
|
145 |
from Amphion.models.codec.ns3_codec import FACodecRedecoder
|
146 |
|