66** Description:** Introducing the ` STFTSpectrogram ` layer to extract spectrograms for audio classification.
77
88
9+ <div class =' example_version_banner keras_3 ' >ⓘ This example uses Keras 3</div >
910<img class =" k-inline-icon " src =" https://colab.research.google.com/img/colab_favicon.ico " /> [ ** View in Colab** ] ( https://colab.research.google.com/github/keras-team/keras-io/blob/master/examples/audio/ipynb/stft.ipynb ) <span class =" k-dot " >•</span ><img class =" k-inline-icon " src =" https://github.com/favicon.ico " /> [ ** GitHub source** ] ( https://github.com/keras-team/keras-io/blob/master/examples/audio/stft.py )
1011
1112
@@ -52,7 +53,6 @@ import scipy.io.wavfile
5253from keras import layers
5354from scipy.signal import resample
5455
55- np.random.seed(41 )
5656keras.utils.set_random_seed(41 )
5757```
5858
@@ -606,7 +606,7 @@ plt.show()
606606
607607
608608
609- ![ png] ( https://github.com/mostafa-mahmoud /keras-io/blob/master/examples/audio/img/stft/raw_audio.png )
609+ ![ png] ( https://github.com/keras-team /keras-io/blob/master/examples/audio/img/stft/raw_audio.png )
610610
611611
612612
@@ -619,7 +619,7 @@ plot_single_spectrogram(sample_wav_data)
619619
620620
621621
622- ![ png] ( https://github.com/mostafa-mahmoud /keras-io/blob/master/examples/audio/img/stft/spectrogram.png )
622+ ![ png] ( https://github.com/keras-team /keras-io/blob/master/examples/audio/img/stft/spectrogram.png )
623623
624624
625625
@@ -632,7 +632,7 @@ plot_multi_bandwidth_spectrogram(sample_wav_data)
632632
633633
634634
635- ![ png] ( https://github.com/mostafa-mahmoud /keras-io/blob/master/examples/audio/img/stft/multiband_spectrogram.png )
635+ ![ png] ( https://github.com/keras-team /keras-io/blob/master/examples/audio/img/stft/multiband_spectrogram.png )
636636
637637
638638
@@ -644,9 +644,7 @@ def read_dataset(df, folds):
644644 msk = df[" fold" ].isin(folds)
645645 filenames = df[" filename" ][msk]
646646 targets = df[" target" ][msk].values
647- waves = np.array(
648- [read_wav_file(fil) for fil in filenames], dtype = np.float32
649- )
647+ waves = np.array([read_wav_file(fil) for fil in filenames], dtype = np.float32)
650648 return waves, targets
651649```
652650
@@ -1791,7 +1789,7 @@ plt.show()
17911789
17921790
17931791
1794- ![ png] ( https://github.com/mostafa-mahmoud /keras-io/blob/master/examples/audio/img/stft/training.png )
1792+ ![ png] ( https://github.com/keras-team /keras-io/blob/master/examples/audio/img/stft/training.png )
17951793
17961794
17971795
@@ -1803,9 +1801,7 @@ Running the models on the test set.
18031801
18041802``` python
18051803_, test_acc = model1d.evaluate(test_x, test_y)
1806- print (
1807- f " 1D model wit non-trainable STFT -> Test Accuracy: { test_acc * 100 :.2f } % "
1808- )
1804+ print (f " 1D model wit non-trainable STFT -> Test Accuracy: { test_acc * 100 :.2f } % " )
18091805```
18101806
18111807 [1m3/3[0m [32m━━━━━━━━━━━━━━━━━━━━[0m[37m[0m [1m3s[0m 307ms/step - accuracy: 0.8148 - loss: 0.6244
0 commit comments