Skip to content

Commit

Permalink
Update Wave.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Someoneece authored Jan 8, 2020
1 parent 9912ae1 commit c4eb2e9
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions Wave.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
from pydub import AudioSegment

sound = AudioSegment.from_mp3("test.mp3")

# get raw audio data as a bytestring
raw_data = sound.raw_data
# get the frame rate
sample_rate = sound.frame_rate
# get amount of bytes contained in one sample
sample_size = sound.sample_width
# get channels
channels = sound.channels
import matplotlib.pyplot as plt
from scipy.io import wavfile as wav
from scipy.fftpack import fft
import numpy as np
import wave
import sys

spf = wave.open('/content/file_example_WAV_1MG.wav','r')

#Extract Raw Audio from Wav File
signal = spf.readframes(-1)
signal = np.fromstring(signal, 'Int16')
fs = spf.getframerate()
fft_out = fft(signal)


Time=np.linspace(0, len(signal)/fs, num=len(signal))

plt.figure(1)
plt.title('Signal Wave...')
plt.plot(Time,fft_out)
plt.show()

0 comments on commit c4eb2e9

Please sign in to comment.