How can I record the sound produced after the LPC Algorithm?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I will prepare slides for my homework and I want to record the sound I get from matlab after the LPC algorithm. And this way I will be able to use it on my slide. I wonder if this is possible? And how can I?
Also, my lpc code is;
%MAIN BODY
clear all;
clc;
%TAKING INPUT WAVEFILE,
inpfilenm = '3853-163249-0002.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);
%RESULTS,
beep;
disp('Press a key to play the original sound!');
pause;
soundsc(y, Fs);
disp('Press a key to play the LPC compressed sound!');
pause;
soundsc(synth_speech, Fs);
s0=snr(y);
disp(" Original audio SNR in dB " + s0)
s1=snr(synth_speech);
disp(" LPC audio SNR in dB " + s1)
% CALCULATING COMPRESSION RATIO
original_size = numel(y) * 2 * 32; % 64 bits per sample
encoded_size = numel(aCoeff) * 2.4; % LPC 2.4k
compression_ratio = original_size / encoded_size;
disp(['Compression Ratio for LPC: ', num2str(compression_ratio)]);
figure;
subplot(2,1,1),
plot(y),
xlabel("Per Samples"),
ylabel("Amplitude"),
title(['Original signal = "', inpfilenm, '"']),
grid on %title('original signal = "%s"', inpfilenm);
subplot(2,1,2),
plot(synth_speech),
xlabel("Per Samples"),
ylabel("Amplitude"),
title(['synthesized speech of "', inpfilenm, '" using LPC algo']),grid on
Also, my homework is speech processing with LPC, CELP and DCT algorithms.
댓글 수: 0
답변 (1개)
Sulaymon Eshkabilov
2024년 1월 22일
If understood correctly, you are trying to record the filtered sounds. If so, audiowrite() can solve the task (to export the filtered data in .wav file that can be embedded in a PPT slide), e.g.:
%MAIN BODY
clearvars
clc
%TAKING INPUT WAVEFILE,
inpfilenm = '3853-163249-0002.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);
%RESULTS,
beep;
disp('Press a key to play the original sound!');
pause;
soundsc(y, Fs);
disp('Press a key to play the LPC compressed sound!');
pause;
soundsc(synth_speech, Fs);
s0=snr(y);
disp(" Original audio SNR in dB " + s0)
s1=snr(synth_speech);
disp(" LPC audio SNR in dB " + s1)
% CALCULATING COMPRESSION RATIO
original_size = numel(y) * 2 * 32; % 64 bits per sample
encoded_size = numel(aCoeff) * 2.4; % LPC 2.4k
compression_ratio = original_size / encoded_size;
disp(['Compression Ratio for LPC: ', num2str(compression_ratio)]);
figure;
subplot(2,1,1),
plot(y),
xlabel("Per Samples"),
ylabel("Amplitude"),
title(['Original signal = "', inpfilenm, '"']),
grid on %title('original signal = "%s"', inpfilenm);
subplot(2,1,2),
plot(synth_speech),
xlabel("Per Samples"),
ylabel("Amplitude"),
title(['synthesized speech of "', inpfilenm, '" using LPC algo']),grid on
% Save the filtered sound signal as a *.WAV file:
File_Name = 'Output_Sound.wav';
audiowrite(File_Name, synth_speech, Fs);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!