本文整理匯總了Python中sounddevice.rec方法的典型用法代碼示例。如果您正苦於以下問題:Python sounddevice.rec方法的具體用法?Python sounddevice.rec怎麽用?Python sounddevice.rec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sounddevice
的用法示例。
在下文中一共展示了sounddevice.rec方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: record_sound
# 需要導入模塊: import sounddevice [as 別名]
# 或者: from sounddevice import rec [as 別名]
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
開發者ID:a-n-rose,項目名稱:Build-CNN-or-LSTM-or-CNNLSTM-with-speech-features,代碼行數:8,代碼來源:implement_model.py
示例2: extract_features
# 需要導入模塊: import sounddevice [as 別名]
# 或者: from sounddevice import rec [as 別名]
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
開發者ID:GianlucaPaolocci,項目名稱:Sound-classification-on-Raspberry-Pi-with-Tensorflow,代碼行數:15,代碼來源:classiPi.py
示例3: _record
# 需要導入模塊: import sounddevice [as 別名]
# 或者: from sounddevice import rec [as 別名]
def _record(self):
return sounddevice.rec(
int(self.duration * self.sample_rate),
samplerate=self.sample_rate,
blocking=True,
channels=1,
dtype='float64'
)