Skip to content

Commit

Permalink
Update pesq_mex_vec.m to use system temporary filenames with MATLABs …
Browse files Browse the repository at this point in the history
…tempname().
  • Loading branch information
JacobD10 committed Jun 16, 2016
1 parent 496a15b commit 296cb10
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions pesq_mex_vec.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
function [ res ] = pesq_mex_vec( reference_sig, degraded_sig, Fs, fileNum )
function [ res ] = pesq_mex_vec( reference_sig, degraded_sig, Fs )
%PESQ_MEX_VEC Accepts vectors for a mex compiled version of the objective Perceptual Evaluation of Speech Quality measure
%
% Syntax: [ res ] = pesq_mex_vec( reference_sig, degraded_sig, Fs, fileNum )
% Syntax: [ res ] = pesq_mex_vec( reference_sig, degraded_sig, Fs )
%
% Inputs:
% reference_sig - Reference (clean, talker, sender) speech signal
% degraded_sig - Degraded (noisy, listener, receiver) speech signal
% Fs - Sampling Frequency
% fileNum - An ID number to append to the temporary audio files. Useful
% when several instances are to be run together (in parallel).
%
% Outputs:
% res - MOS-LQO result for wideband
Expand All @@ -18,29 +16,25 @@
% Author: Jacob Donley
% University of Wollongong
% Email: jrd089@uowmail.edu.au
% Copyright: Jacob Donley 2015
% Date: 20 October 2015
% Revision: 0.1
% Copyright: Jacob Donley 2016
% Date: 16 June 2016
% Revision: 0.2
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin < 4
fileNum = 0;
end
temp_path = [pwd filesep '+Miscellaneous\+Temporary\'];
ref_path = [ 'tmp_ref' num2str(fileNum) '.wav'];
deg_path = [ 'tmp_deg' num2str(fileNum) '.wav'];

if ~exist(temp_path,'dir'); mkdir(temp_path); end

max_val = max(abs([reference_sig(:); degraded_sig(:)]));

audiowrite([temp_path ref_path], reference_sig / max_val, Fs);
audiowrite([temp_path deg_path], degraded_sig / max_val, Fs);
tmpref = [tempname '.wav'];
tmpdeg = [tempname '.wav'];

audiowrite( tmpref, reference_sig / max_val, Fs);
audiowrite( tmpdeg, degraded_sig / max_val, Fs);

res = Tools.pesq_mex(['+' num2str(Fs)], ...
'+wb', ...
[temp_path ref_path], ...
[temp_path deg_path]);
tmpref, ...
tmpdeg);

delete( tmpref, tmpdeg );
end

0 comments on commit 296cb10

Please sign in to comment.