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)