% Experiment with wav files 

[speech, fs]= wavread('sp_truth.wav');
sound(speech, fs)
plot(1:length(speech), speech)
title('Dialog from A Few Good Men')
pause

% Try to find "You can't handle the truth"
disp('Find:  You can''t handle the truth')
pause
sound(speech(50000:end), fs)
figure
plot(50000:length(speech), speech(50000:end))
title('You can''t handle the truth')
pause


% Try to take out "can't"
disp('Edit:  You handle the truth')
pause
lastSen= speech(50000:end);  % last sentence
canHandle= [lastSen(1:3000); lastSen(7700:end)];
sound(canHandle, fs)
figure
plot(1:length(canHandle), canHandle)
title('You handle the truth')
pause


% "the truth"
truth= lastSen(12000:end);

% "Scotty, beam me up"  same fs as afgm
disp('Scotty, beam me up')
pause
[s1, fs1]= wavread('sp_beam.wav');
sound(s1, fs)
figure
plot(1:length(s1), s1)
title('Scotty, beam me up')
pause


close all
% "Scotty, beam me the truth"
disp('Scotty, beam me *the truth*')
pause
beamTruth= [s1(1:9000); truth];
sound(beamTruth,fs)
pause


% But truth is too loud, make it quieter by decreasing the amplitude
disp('But ''truth'' is too loud, make it quieter by decreasing the amplitude')
pause
quietTruth= zeros(length(truth),1);
for k= 1:length(truth)
    quietTruth(k,1)= truth(k)/2;
end
beamTruth= [s1(1:9000); quietTruth];
sound(beamTruth, fs)
pause

