Exemple #1
0
 def test_raw(self):
     sp = periodogram(lh)[0]
     assert_array_almost_equal(sp[1:], lh_spec_raw)
plt.title('DGP')

sdm, wm = mlb.psd(x)
sdm = sdm.ravel()
pm = ndimage.filters.maximum_filter(sdm, footprint=np.ones(5))
maxind = np.nonzero(pm == sdm)

plt.subplot(2,3,2)
if rescale:
    plt.plot(wm,sdm/sdm[0], '-', wm[maxind], sdm[maxind]/sdm[0], 'o')
else:
    plt.plot(wm, sdm, '-', wm[maxind], sdm[maxind], 'o')
plt.title('matplotlib')

if hastalkbox:
    sdp, wp = stbs.periodogram(x)
    plt.subplot(2,3,3)

    if rescale:
        plt.plot(wp,sdp/sdp[0])
    else:
        plt.plot(wp, sdp)
    plt.title('stbs.periodogram')

xacov = acovf(x, unbiased=False)
plt.subplot(2,3,4)
plt.plot(xacov)
plt.title('autocovariance')

nr = len(x)#*2/3
#xacovfft = np.fft.fft(xacov[:nr], 2*nr-1)
Exemple #3
0
import numpy as np
import matplotlib.pyplot as plt
from scikits.talkbox.spectral.basic import periodogram
from scipy.signal import hamming, hanning
fs = 1000
x = np.sin(2 * np.pi * 0.15 * fs * np.linspace(0., 0.3, 0.3 * fs))
x += 0.1 * np.random.randn(x.size)
px1, fx1 = periodogram(x, nfft=16384, fs=fs)
px2, fx2 = periodogram(x * hamming(x.size), nfft=16384, fs=fs)
plt.subplot(2, 1, 1)
plt.plot(fx1, 10 * np.log10(px1))
plt.subplot(2, 1, 2)
plt.plot(fx2, 10 * np.log10(px2))
plt.xlabel('Frequency (Hz)')
plt.ylabel('Amplitude (dB)')
plt.savefig('periodogram_2.png')
Exemple #4
0
plt.title('DGP')

sdm, wm = mlb.psd(x)
sdm = sdm.ravel()
pm = ndimage.filters.maximum_filter(sdm, footprint=np.ones(5))
maxind = np.nonzero(pm == sdm)

plt.subplot(2, 3, 2)
if rescale:
    plt.plot(wm, sdm / sdm[0], '-', wm[maxind], sdm[maxind] / sdm[0], 'o')
else:
    plt.plot(wm, sdm, '-', wm[maxind], sdm[maxind], 'o')
plt.title('matplotlib')

if hastalkbox:
    sdp, wp = stbs.periodogram(x)
    plt.subplot(2, 3, 3)

    if rescale:
        plt.plot(wp, sdp / sdp[0])
    else:
        plt.plot(wp, sdp)
    plt.title('stbs.periodogram')

xacov = acovf(x, unbiased=False)
plt.subplot(2, 3, 4)
plt.plot(xacov)
plt.title('autocovariance')

nr = len(x)  #*2/3
#xacovfft = np.fft.fft(xacov[:nr], 2*nr-1)
Exemple #5
0
import numpy as np
import matplotlib.pyplot as plt
from scikits.talkbox.spectral.basic import periodogram
fs = 1000
x = np.sin(2 * np.pi * 0.15 * fs * np.linspace(0., 0.3, 0.3 * fs))
x += 0.1 * np.random.randn(x.size)
px, fx = periodogram(x, nfft=16384, fs=fs)
plt.plot(fx, 10 * np.log10(px))
plt.xlabel('Frequency (Hz)')
plt.ylabel('Amplitude (dB)')
plt.savefig('periodogram_1.png')
Exemple #6
0
import numpy as np
import matplotlib.pylab as plt

from scikits.audiolab import wavread
from scikits.samplerate import resample

from scikits.talkbox.spectral.basic import periodogram, arspec

a, fs = wavread('voice-womanKP-01.wav')[:2]

fr = 4000.
ra = resample(a, fr / fs)

frame = ra[500:500+256]
px, fx = periodogram(frame, 2048, fr)
plt.grid(True)
plt.plot(fx, 10 * np.log10(px))

apx, afx = arspec(frame, 12, 2048, fr)
plt.plot(afx, 10 * np.log10(apx))
Exemple #7
0
import numpy as np
import matplotlib.pylab as plt

from scikits.audiolab import wavread
from scikits.samplerate import resample

from scikits.talkbox.spectral.basic import periodogram, arspec

a, fs = wavread('voice-womanKP-01.wav')[:2]

fr = 4000.
ra = resample(a, fr / fs)

frame = ra[500:500 + 256]
px, fx = periodogram(frame, 2048, fr)
plt.grid(True)
plt.plot(fx, 10 * np.log10(px))

apx, afx = arspec(frame, 12, 2048, fr)
plt.plot(afx, 10 * np.log10(apx))