You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import os
from micmon.audio import AudioDirectory, AudioPlayer, AudioFile
from micmon.dataset import DatasetWriter
basedir = os.path.expanduser('~/BabyCare')
audio_dir = os.path.join(basedir, 'audio/sample_1')
print(audio_dir) # print just [ ]
datasets_dir = os.path.join(basedir, 'data')
cutoff_frequencies = [250, 7500]
# Scan the base audio_dir for labelled audio samples
audio_dirs = AudioDirectory.scan(audio_dir)
print(audio_dirs)
# Play some audio samples starting from 01:00
for audio_dir in audio_dirs:
with AudioFile(audio_dir, start='01:00', duration=5) as reader, \
AudioPlayer() as player:
for sample in reader:
player.play(sample)
# Plot the audio and spectrum of the audio samples in the first 10 seconds
# of each audio file.
for audio_dir in audio_dirs:
with AudioFile(audio_dir, start=0, duration=10) as reader:
for sample in reader:
sample.plot_audio()
sample.plot_spectrum(low_freq=cutoff_frequencies[0],
high_freq=cutoff_frequencies[1])
# Save the spectrum information and labels of the samples to a
# different compressed file for each audio file.
for audio_dir in audio_dirs:
dataset_file = os.path.join(datasets_dir, os.path.basename(audio_dir.path) + '.npz')
print(f'Processing audio sample {audio_dir.path}')
with AudioFile(audio_dir) as reader, \
DatasetWriter(dataset_file,
low_freq=cutoff_frequencies[0],
high_freq=cutoff_frequencies[1]) as writer:
for sample in reader:
writer += sample
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: