der Code hier nimmt sound auf, speichert die Audio Datei, lädt sie erneut und lässt eine KI etwas bestimmen.
Code: Alles auswählen
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1)
sd.wait()
write(filename, fs, myrecording)
audio, sample_rate = librosa.load(filename)
mfcc = librosa.feature.mfcc(y=audio, sr=sample_rate, n_mfcc=40)
mfcc_processed = np.mean(mfcc.T, axis=0)
prediction = model.predict(np.expand_dims(mfcc_processed, axis=0))
Code: Alles auswählen
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1)
sd.wait()
#write(filename, fs, myrecording)
#audio, sample_rate = librosa.load(filename)
mfcc = librosa.feature.mfcc(y=myrecording, sr=fs, n_mfcc=40)
mfcc_processed = np.mean(mfcc.T, axis=0)
prediction = model.predict(np.expand_dims(mfcc_processed, axis=0))
Code: Alles auswählen
Invalid shape for monophonic audio: ndim=2, shape=(88200, 1)