Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. from IPython.display import display, Audio
  2. from scipy.io.wavfile import read
  3.  
  4. len = 50000
  5.  
  6. Fs,y = read('zdanie.wav')
  7. y = y[:len]
  8. t = linspace(0, Fs, len)
  9.  
  10. fig,ax = subplots(5, 2, figsize=(20,20))
  11.  
  12. ax[0,0].plot(t,y)
  13. ax[0,0].set_title('zdanie.wav')
  14.  
  15. Y = fft.rfft(y)
  16.  
  17. f = linspace(0,Fs/2,Y.size)
  18. ax[0,1].plot(f,abs(Y))
  19. ax[0,1].set_title('RFFT')
  20.  
  21. Y1 = Y * (f < 200)
  22. Y2 = Y * (f > 500) * (f < 1000)
  23. Y3 = Y * (f > 2000) * (f < 4000)
  24. Y4 = Y1 + Y2 + Y3
  25.  
  26. ax[1,1].plot(f,abs(Y1))
  27. ax[1,1].set_title('RFFT dla niskich')
  28.  
  29. ax[2,1].plot(f,abs(Y2))
  30. ax[2,1].set_title('RFFT dla średnich')
  31.  
  32. ax[3,1].plot(f,abs(Y3))
  33. ax[3,1].set_title('RFFT dla wysokich')
  34.  
  35. ax[4,1].plot(f,abs(Y4))
  36. ax[4,1].set_title('RFFT dla sumy')
  37.  
  38. y1 = fft.irfft(Y1)
  39. y2 = fft.irfft(Y2)
  40. y3 = fft.irfft(Y3)
  41. y4 = fft.irfft(Y4)
  42.  
  43. # plot(t,y)
  44. ax[1,0].plot(t, y1)
  45. ax[1,0].set_title('IRFFT dla niskich')
  46.  
  47. ax[2,0].plot(t, y2)
  48. ax[2,0].set_title('IRFFT dla średnich')
  49.  
  50. ax[3,0].plot(t, y3)
  51. ax[3,0].set_title('IRFFT dla wysokich')
  52.  
  53. ax[4,0].plot(t, y4)
  54. ax[4,0].set_title('IRFFT dla sumy')
  55.  
  56. print("Tylko niskie")
  57. display(Audio(y1,rate=Fs))
  58.  
  59. print("Tylko średnie")
  60. display(Audio(y2,rate=Fs))
  61.  
  62. print("Tylko wysokie")
  63. display(Audio(y3,rate=Fs))
  64.  
  65. print("Suma")
  66. display(Audio(y4,rate=Fs))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement