Skip to content

Commit 6050970

Browse files
committed
pitch shift
1 parent 5d8dbe0 commit 6050970

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ https://user-images.githubusercontent.com/16432329/228889388-d7658930-6187-48a8-
8989
**PS.** 本项目集成了音效算法,你可以使用混响等常见音效
9090

9191
啥?生成的音色不太像!
92-
```
93-
待补充~~~
92+
```python
9493
1,发音人音域统计
94+
训练第5步生成:lora_pitch_statics.npy
9595
2,推理音区偏移
96+
指定pitch参数:python svc_inference.py --config config/maxgan.yaml --model maxgan_g.pth --spk ./data_svc/lora_speaker.npy --statics ./data_svc/lora_pitch_statics.npy --wave test.wav
9697
```
9798

9899
## 更好的音质

svc_inference.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,27 @@ def main(args):
8686
ppg = torch.FloatTensor(ppg)
8787

8888
pit = compute_f0_nn(args.wave, device)
89+
if (args.statics == None):
90+
print("don't use pitch shift")
91+
else:
92+
source = pit[pit > 0]
93+
source_ave = source.mean()
94+
source_min = source.min()
95+
source_max = source.max()
96+
print(f"source pitch statics: mean={source_ave:0.1f}, \
97+
min={source_min:0.1f}, max={source_max:0.1f}")
98+
singer_ave, singer_min, singer_max = np.load(args.statics)
99+
print(f"singer pitch statics: mean={singer_ave:0.1f}, \
100+
min={singer_min:0.1f}, max={singer_max:0.1f}")
101+
102+
shift = np.log2(singer_ave/source_ave) * 12
103+
if (singer_ave >= source_ave):
104+
shift = np.floor(shift)
105+
else:
106+
shift = np.ceil(shift)
107+
shift = 2 ** (shift / 12)
108+
pit = pit * shift
109+
89110
pit = torch.FloatTensor(pit)
90111
pos = torch.LongTensor(pos)
91112

@@ -123,6 +144,8 @@ def main(args):
123144
help="Path of raw audio.")
124145
parser.add_argument('-s', '--spk', type=str, required=True,
125146
help="Path of speaker.")
147+
parser.add_argument('-t', '--statics', type=str,
148+
help="Path of pitch statics.")
126149
args = parser.parse_args()
127150

128151
main(args)

0 commit comments

Comments
 (0)