Python sounddevice.rec() Examples
The following are 3
code examples of sounddevice.rec().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sounddevice
, or try the search function
.
Example #1
Source File: classiPi.py From Sound-classification-on-Raspberry-Pi-with-Tensorflow with MIT License | 6 votes |
def extract_features(): X = sounddevice.rec(int(duration * sample_rate), samplerate=sample_rate, channels=1) sounddevice.wait() X= np.squeeze(X) stft = np.abs(librosa.stft(X)) mfccs = np.array(librosa.feature.mfcc(y=X, sr=sample_rate, n_mfcc=8).T) chroma = np.array(librosa.feature.chroma_stft(S=stft, sr=sample_rate).T) mel = np.array(librosa.feature.melspectrogram(X, sr=sample_rate).T) contrast = np.array(librosa.feature.spectral_contrast(S=stft, sr=sample_rate).T) tonnetz = np.array(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=sample_rate).T) ext_features = np.hstack([mfccs,chroma,mel,contrast,tonnetz]) features = np.vstack([features,ext_features]) return features
Example #2
Source File: noise.py From enviroplus-python with MIT License | 6 votes |
def _record(self): return sounddevice.rec( int(self.duration * self.sample_rate), samplerate=self.sample_rate, blocking=True, channels=1, dtype='float64' )
Example #3
Source File: implement_model.py From Build-CNN-or-LSTM-or-CNNLSTM-with-speech-features with MIT License | 5 votes |
def record_sound(sec,message): sr = 16000 print(message+" for {} seconds..".format(sec)) sound = sd.rec(int(sec*sr),samplerate=sr,channels=1) sd.wait() return sound, sr