Main Content

getAugmenterParams

Get parameters of augmentation algorithm

Since R2021a

    Description

    augmenterParams = getAugmenterParams(aug,algorithmName) returns parameters of the augmentation algorithm associated with the audioDataAugmenter object.

    example

    augmenterParams = getAugmenterParams(aug) returns the parameters of all augmentation algorithms associated with the audioDataAugmenter object.

    Examples

    collapse all

    Modify the default parameters of the shiftPitch and stretchAudio augmentation algorithms.

    Read in an audio signal and listen to it.

    [audioIn,fs] = audioread('FemaleSpeech-16-8-mono-3secs.wav');
    soundsc(audioIn,fs)

    Create an audioDataAugmenter object that applies a pitch shift of 3 semitones and a time stretch with a SpeedupFactor of 1.5.

    aug = audioDataAugmenter('AugmentationParameterSource','specify', ...
                             'ApplyPitchShift',true, ...
                             'SemitoneShift',3, ...
                             'ApplyTimeStretch',true, ...
                             'SpeedupFactor',1.5, ...
                             'ApplyVolumeControl',false, ...
                             'ApplyAddNoise',false, ...
                             'ApplyTimeShift',false)
    aug = 
      audioDataAugmenter with properties:
    
                   AugmentationMode: 'sequential'
        AugmentationParameterSource: 'specify'
                   ApplyTimeStretch: 1
                      SpeedupFactor: 1.5000
                    ApplyPitchShift: 1
                      SemitoneShift: 3
                 ApplyVolumeControl: 0
                      ApplyAddNoise: 0
                     ApplyTimeShift: 0
    
    

    Call setAugmenterParams to set the LockPhase and PreserveFormants parameters of the shiftPitch augmentation algorithm to false. Set the LockPhase parameter of the stretchAudio augmentation algorithm to false. Set the CepstralOrder parameter of the shiftPitch algorithm to 30.

    Augment the original signal and listen to the result. The resulting file has an audible distortion that sounds unnatural. View the parameters of the augmentation algorithms.

    setAugmenterParams(aug,'shiftPitch','LockPhase',false,'PreserveFormants',false,'CepstralOrder',30);
    setAugmenterParams(aug,'stretchAudio','LockPhase',false);
    data = augment(aug,audioIn,fs);
    
    pause(3)
    
    augmentationPre = data.Audio{1};
    soundsc(augmentationPre,fs)
    
    data.AugmentationInfo(1)
    ans = struct with fields:
        SpeedupFactor: 1.5000
        SemitoneShift: 3
    
    
    augmenterParamsPre = getAugmenterParams(aug);
    augmenterParamsPre.stretchAudio
    ans = struct with fields:
        LockPhase: 0
    
    
    augmenterParamsPre.shiftPitch
    ans = struct with fields:
               LockPhase: 0
        PreserveFormants: 0
           CepstralOrder: 30
    
    

    Plot the time-domain representation of the original and the augmented signals.

    t = (0:(numel(audioIn)-1))/fs;
    taug = (0:(numel(augmentationPre)-1))/fs;
    plot(t,audioIn,taug,augmentationPre)
    legend("Original Audio","Augmented Audio")
    ylabel("Amplitude")
    xlabel("Time (s)")

    Figure contains an axes object. The axes object with xlabel Time (s), ylabel Amplitude contains 2 objects of type line. These objects represent Original Audio, Augmented Audio.

    To partially compensate for the audible distortion and increase the fidelity of the augmentation algorithms, apply formant preservation to the shiftPitch algorithm, apply phase-locking to both algorithms, and change the cepstral order of the shiftPitch algorithm to 25. Listen to the processed audio.

    setAugmenterParams(aug,'shiftPitch','LockPhase',true,'PreserveFormants',true,'CepstralOrder',25);
    setAugmenterParams(aug,'stretchAudio','LockPhase',true);
    data = augment(aug,audioIn,fs);
    
    augmentationPost = data.Audio{1};
    soundsc(augmentationPost,fs)
    
    data.AugmentationInfo(1)
    ans = struct with fields:
        SpeedupFactor: 1.5000
        SemitoneShift: 3
    
    
    augmenterParamsPost = getAugmenterParams(aug);
    augmenterParamsPost.stretchAudio
    ans = struct with fields:
        LockPhase: 1
    
    
    augmenterParamsPost.shiftPitch
    ans = struct with fields:
               LockPhase: 1
        PreserveFormants: 1
           CepstralOrder: 25
    
    

    Plot the original audio as well as the augmented data before and after formant preservation, phase-locking, and cepstral order modification.

    taug = (0:(numel(augmentationPost)-1))/fs;
    plot(t,audioIn,taug,augmentationPre)
    hold on
    plot(taug,augmentationPost,'LineStyle',':')
    legend("Original Audio","Pre Formant Preservation," + ...
        " Phase-Locking, and Cepstral Order", ...
        "Post Formant Preservation, Phase-Locking, and Cepstral Order")
    ylabel("Amplitude")
    xlabel("Time (s)")
    legend('Location','best')

    Figure contains an axes object. The axes object with xlabel Time (s), ylabel Amplitude contains 3 objects of type line. These objects represent Original Audio, Pre Formant Preservation, Phase-Locking, and Cepstral Order, Post Formant Preservation, Phase-Locking, and Cepstral Order.

    Return the augmentation algorithm parameters to their default values. Call getAugmenterParams to display the current parameter values for the audioAugmenter object.

    setAugmenterParams(aug,'shiftPitch')
    setAugmenterParams(aug,'stretchAudio')
    augmenterParamsDefault = getAugmenterParams(aug);
    augmenterParamsDefault.stretchAudio
    ans = struct with fields:
        LockPhase: 0
    
    
    augmenterParamsDefault.shiftPitch
    ans = struct with fields:
               LockPhase: 0
        PreserveFormants: 0
           CepstralOrder: 30
    
    

    Input Arguments

    collapse all

    Audio data augmenter, specified as an audioDataAugmenter object.

    Algorithm name, specified as 'stretchAudio' or 'shiftPitch.

    Data Types: char | string

    Output Arguments

    collapse all

    Audio augmenter parameters, returned as a structure array.

    Data Types: struct

    Version History

    Introduced in R2021a