-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9912ae1
commit c4eb2e9
Showing
1 changed file
with
22 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |