How do I calculate the compression ratio of my LPC code.

1 visualización (últimos 30 días)
Mert Sari
Mert Sari el 20 de En. de 2024
Comentada: Mert Sari el 22 de En. de 2024
%MAIN BODY
clear all;
clc;
%TAKING INPUT WAVEFILE,
inpfilenm = 'a1.wav';
[y, Fs] =audioread(inpfilenm);
% x=wavrecord(,);
%LENGTH (IN SEC) OF INPUT WAVEFILE,
t=length(y)./Fs;
sprintf('Processing the wavefile "%s"', inpfilenm)
sprintf('The wavefile is %3.2f seconds long', t)
%THE ALGORITHM STARTS HERE,
M=10; %prediction order
[aCoeff, pitch_plot, voiced, gain] = f_ENCODER(y, Fs, M); %pitch_plot is pitch periods
synth_speech = f_DECODER (aCoeff, pitch_plot, voiced, gain);

Respuesta aceptada

Shubh
Shubh el 22 de En. de 2024
Hi,
The compression ratio is a measure of how much the data has been reduced in size after applying a compression algorithm. In this case, I assumed a simple compression model where the original signal is represented by LPC (Linear Predictive Coding) coefficients. Here's the complete code:
%MAIN BODY
clear all;
clc;
% TAKING INPUT WAVEFILE
inpfilenm = 'a1.wav';
[y, Fs] = audioread(inpfilenm);
% LENGTH (IN SEC) OF INPUT WAVEFILE
t = length(y) / Fs;
sprintf('Processing the wavefile "%s"', inpfilenm)
sprintf('The wavefile is %3.2f seconds long', t)
% THE ALGORITHM STARTS HERE
M = 10; % prediction order
[aCoeff, pitch_plot, voiced, gain] = f_ENCODER(y, Fs, M); % pitch_plot is pitch periods
synth_speech = f_DECODER(aCoeff, pitch_plot, voiced, gain);
% CALCULATING COMPRESSION RATIO
original_size = numel(y) * 2 * 8; % 16 bits per sample
encoded_size = numel(aCoeff) * 8; % assuming each coefficient is 64 bits
compression_ratio = original_size / encoded_size;
disp(['Compression Ratio: ', num2str(compression_ratio)]);
The compression ratio is then displayed using "disp(['Compression Ratio: ', num2str(compression_ratio)]);".
Hope this helps!

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by