2

I'm trying to modulate frequency of input audio file. I used librosa library to analyze and modulate audio file. Below is my code to modulate input audio file.

# Preprocessing female voice
audio_path = '/Users/gayeon/Desktop/voice_gayeon.m4a'
y, sr = librosa.load(audio_path)

cent = librosa.feature.spectral_centroid(y=y, sr=sr)
voice_array = np.array(cent[0])
indexToRemove = []

for index in range(len(voice_array)) :
    if voice_array[index] == 0.0 :
        indexToRemove.append(index)

female = np.delete(voice_array, indexToRemove)
print(female)

newVoice = female
# Modulate female voice
for index in range(len(newVoice)) :
    newVoice[index] = newVoice[index] / 4
print(newVoice)

Throw this code, I've got an new frequency array.

[ 542.99170738  502.45045854  519.22828833  530.9953343   485.2300628
  431.03136717  433.02589125  466.0068074   495.59417527  554.1888108
  585.1687338   574.31147381  534.91519974  583.435123    556.4765193
  529.56489607  574.90657168  622.55341609  645.43081482  727.36757784
  740.63815737  878.34278528 1021.05586161  941.76212849  842.93545914
  748.9847497   713.56066683  738.51855469  733.71236612  673.536676
  679.9331127   762.94424233  510.36917952  338.22221514  333.60990321
  346.66814941  351.20370866  337.02447721  322.65321254  289.35376896
  330.68519694  392.73123559  375.42405851  326.44714128  278.31641982
  241.02721131  222.44000345  225.4944309   236.58690361  258.65343045
  272.14351611  278.57654272  284.82596416  304.12405948  318.70804924
  325.74348929  333.90736183  337.09858139  307.18539384  277.12172123
  269.27941396  533.30985612  348.02458767  193.23971236  177.62760295
  283.23083136  365.543546    376.82645541  368.00938702  359.91801711
  340.93731613  360.67030679  378.89019603  378.98061083  373.66278625
  377.996432    384.11188064  332.34950934  206.43584398  127.45387439
  136.4449187   290.6260386   283.7672955   330.06784147  377.30614197
  396.99838462  400.91136556  727.01651981  774.23321377  707.3548431
  705.52532028  650.83562387  608.18590633  578.96080204  569.33111386
  551.64246553  509.23473264  454.9494144   458.54695536  505.28732458
  494.85882143  390.43933577  376.68108346  454.49020349  454.01296495
  366.13089278  236.60390141  251.27041179  405.20856187  521.70682993
  552.23008895  567.65083114  560.69513865  505.37128554  492.12213015
  458.66869918  437.95586402  437.17929852  410.22211646  372.47936826
  381.05040763  429.58414789  435.09217482  425.64310572  397.86570343
  363.91023265  375.30789488  415.66395509  478.06007755  464.35282975
  406.24001797  446.92950501  489.23992029  494.17732504  491.16399507
  436.91811585  384.79490321  383.85128092  412.53911058  394.60849643
  405.98335085  381.03843907  365.26697826  409.42464286  539.38418231
  641.13797666  643.55945904  680.93602365  763.01878757  834.57465959
  857.48500065  824.72413357  782.18329161  712.62245666  660.00981783
  525.61440989]

I wanna convert this result array to any audio file. Please let me know any library to convert array to audio file in python.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.