You are on page 1of 8

AML CT2 4 MARKS

1) Read and plot the audio signal


Audio files are digi zed versions of actual audio signals. Actual audio signals
are complex con nuous-valued waves. In order to save a digital version, we
sample the signal and convert it into numbers. For example, speech is
commonly sampled at 44100 Hz. This means that each second of the signal is
broken down into 44100 parts, and the values at these mestamps are stored.
In other words, you store a value every 1/44100 seconds. As the sampling rate
is high, we feel that the signal is con nuous when we listen to it on our media
players.
2) Compute the applica on of Fourier transform signal and plo er

Fourier Transforms
The Fourier transform is a mathematical formula that transforms a signal sampled
in time or space to the same signal sampled in temporal or spatial frequency. In
signal processing, the Fourier transform can reveal important characteristics of a
signal, namely, its frequency components.
The Fourier transform is defined for a vector x with n uniformly sampled points by

yk+1= ∑ ωjkxj+1.
n−1 j=0

ω=e−2πi/n is one of the n complex roots of unity where i is the imaginary unit.
For x and y, the indices j and k range from 0 to n−1

APPLICATION IN SIGNAL PROCESSING:


For example, in audio processing, the Fourier Transform helps identify the various
frequencies present in an audio signal, enabling tasks like speech recognition, music
classification, and noise reduction.
For example, in audio processing, the Fourier Transform helps identify the various
frequencies present in an audio signal, enabling tasks like speech recognition, music
classification, and noise reduction.
APPLICATIONS IN ML:
Time series analysis
NLP
Feature engineering
Convolutional Neural Networks
Data Augmentation

3) Construct audio sample. Explain amplitude and frequency.


Constructing audio samples in applied machine learning typically involves
generating or loading audio data in a format suitable for training machine learning
models, especially for tasks like audio classification, speech recognition, or sound
generation. Here's a general approach to constructing audio samples:

1. Generate Synthetic Data:


 Sinusoidal Waves: Generate simple sinusoidal waves with specific
frequencies and durations using libraries like NumPy.
 White Noise: Create random white noise samples.
 Combining Signals: Combine multiple sinusoidal waves or noise
samples to create more complex audio signals.
 Signal Processing Techniques: Use signal processing techniques to
modify or transform existing audio samples, such as time-stretching,
pitch-shifting, or adding effects like echo or reverb.
2. Load Audio Files:
 Dataset: Use existing audio datasets available online or from libraries
like TensorFlow Datasets or PyTorch Audio.
 File Formats: Load audio files in common formats like WAV, MP3, or
FLAC using libraries like Librosa or PyDub.
3. Preprocessing:
 Normalization: Scale the audio samples to a common range, typically
between -1 and 1.
 Resampling: Ensure all samples have the same sample rate if they
differ.
 Segmentation: Divide longer audio samples into smaller segments or
frames for processing.
4. Augmentation (Optional):
 Data Augmentation: Apply augmentations such as adding noise, time
stretching, pitch shifting, or altering the volume to increase the
diversity of training samples.
 Dynamic Range Compression: Apply compression techniques to vary
the dynamic range of audio samples.
5. Visualization:
 Waveform Plots: Plot the waveform of audio samples using libraries
like Matplotlib or Seaborn to visually inspect the data.
 Spectrograms: Convert audio samples into spectrograms (frequency
vs. time representations) and visualize them to analyze frequency
content over time.
6. Integration with Machine Learning Pipelines:
 Feature Extraction: Extract relevant features from audio samples, such
as Mel-Frequency Cepstral Coefficients (MFCCs), Spectral Centroid, or
Chroma Features.
 Model Training: Feed the audio samples along with their
corresponding labels into machine learning models for training.
*Amplitude refers to the magnitude of compression and expansion experienced by the
medium the sound wave is travelling through. This amplitude is perceived by our ears as
loudness. High amplitude is equivalent to loud sounds.
*Frequency in a sound wave refers to the rate of the vibration of the sound travelling through
the air. This parameter decides whether a sound is perceived as high pitched or low pitched.
In sound, the frequency is also known as Pitch. The frequency of the vibrating source of
sound is calculated in cycles per second.

4)Illustrate and plot sliced time series data


The process of slicing refers to dividing the data into various sub-intervals and
extracting relevant information. This is useful when we are working with time series
datasets. Instead of using indices, we will use timestamps to slice our data.

To slice a time series, you use the $project operator to identify the time series and
include a document with a $slice operator to specify the time range of the time series
elements to return. The $slice operator produces the same results as running the
time series Clip or ClipCount functions.

Write 12m python code

5. Convert date to seconds


6)List all audio generation parameters

We can use NumPy to generate audio signals. audio signals are complex mixtures of
sinusoids. Some common parameters and techniques used in audio generation
include:

Sampling Rate: Sampling rate refers to the number of samples of audio carried per
second, measured in Hertz (Hz). Higher sampling rates can result in higher fidelity
audio

Audio Length: This parameter determines the duration of the generated audio in
seconds or milliseconds.

Audio Format: WAV, MP3, FLAC, etc.

Waveform Generation: Techniques for generating waveforms, including sine waves,


square waves, triangle waves, and complex waveforms.

Frequency: Frequency controls the pitch of the audio signal.

Amplitude: Amplitude controls the volume or loudness of the audio signal.

Phase: Phase refers to the position of a point in time within the waveform cycle.

Noise: Adding noise to the generated audio can introduce randomness and realism
to the sound

Pitch Shift: Altering the pitch of the audio signal without changing its duration.

7)Define a function to synthesize a tone based on input parameters.

*Generates a square wave of the specified frequency (and 50% duty cycle) on a
pin.

*A duration can be specified, otherwise the wave continues until a call to


noTone().

*The pin can be connected to a piezo buzzer or other speaker to play tones.

*tone() takes three arguments, pin : the pin on which to generate the tone,
frequency : the frequency of the tone in hertz and duration : the duration of the
tone in milliseconds (a zero value = continuous tone).

The frequency range is from 20Hz to 20kHz. Frequencies outside this range will
not be played.
8)List some examples where time series data can be used

Time series analysis is used for non-stationary data—things that are constantly
fluctuating over time or are affected by time.

Stock market analysis is an excellent example of time series analysis in action,


especially with automated trading algorithms.

 Weather data

 Rainfall measurements

 Temperature readings

 Heart rate monitoring (EKG)

 Brain monitoring (EEG)

 Quarterly sales

 Stock prices

 Automated stock trading

 Industry forecasts
 Interest rates

9)What does rolling mean in extracting statistics from time series data.

Rolling is a way to turn a single time series into multiple time series, each of them
ending one (or n) time step later than the one before.

(or)

The process of shi ing a cut-out window over your data to create smaller me series cut-
outs is called rolling.
In tsfresh, rolling is implemented via the helper
func on tsfresh.utilities.dataframe_functions.roll_time_series() .
*roll_time_series() is a function from the tsfresh library, which is used for feature
extraction from time series data.
This function is specifically designed to convert a single time series into multiple
rolling time series.

The Moving Average (MA) (or) Rolling Mean: The value of MA is calculated by taking
average data of the time-series within k periods. Let's see the types of moving averages:
Simple Moving Average (SMA), Cumulative Moving Average (CMA)

You might also like