@@ -86,6 +86,27 @@ def main(args):
86
86
ppg = torch .FloatTensor (ppg )
87
87
88
88
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
+
89
110
pit = torch .FloatTensor (pit )
90
111
pos = torch .LongTensor (pos )
91
112
@@ -123,6 +144,8 @@ def main(args):
123
144
help = "Path of raw audio." )
124
145
parser .add_argument ('-s' , '--spk' , type = str , required = True ,
125
146
help = "Path of speaker." )
147
+ parser .add_argument ('-t' , '--statics' , type = str ,
148
+ help = "Path of pitch statics." )
126
149
args = parser .parse_args ()
127
150
128
151
main (args )
0 commit comments