python 声音变速不变调实现

版权声明:https://blog.csdn.net/barry_j https://blog.csdn.net/Barry_J/article/details/84254172
import ctypes
import numpy as np
from numpy.ctypeslib import ndpointer
from scipy.io import wavfile

lib = ctypes.cdll.LoadLibrary   
sonic_lib = lib("lib/sonic-master/libsonic.so")
fs, wav = wavfile.read('orginal.wav')
wav = np.array(wav, dtype='int16')
wav_speech_change = sonic_lib.wavChangeSpeed
wav_speech_change.argtypes = [ndpointer(ctypes.c_short),ndpointer(ctypes.c_short), ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_float]
wav_speech_change.restypes = None
result = np.zeros((int(wav.shape[0]//0.9)), dtype='int16')
wav_speech_change(wav, result, 1, fs, wav.shape[0], 0.9)
librosa.output.write_wav('test1.wav', result, sr=48000)

猜你喜欢

转载自blog.csdn.net/Barry_J/article/details/84254172