setAugmenterParams
Description
setAugmenterParams(
sets parameters of the augmentation algorithm associated with the aug
,algorithmName
,params
)audioDataAugmenter
object.
setAugmenterParams(
without the aug
,algorithmName
)params
argument restores the
algorithmName
parameters to their default values.
Examples
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)")
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')
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
Audio data augmenter, specified as an audioDataAugmenter
object.
Algorithm name, specified as 'stretchAudio'
or
'shiftPitch
.
Note
Augmentation algorithms must be modified independently using separate calls to
setAugmenterParams
for each algorithm.
Data Types: char
| string
Parameter name, specified as a character vector, string, or structure array.
Parameter values depend on algorithmName
. Specify
params
as one of these:
When you set
algorithmName
to'stretchAudio'
, specifyparams
as'LockPhase'
andtrue
orfalse
.When you set
algorithmName
to'shiftPitch'
, specifyparams
as one or all of these:'LockPhase'
andtrue
orfalse
'PreserveFormants'
andtrue
orfalse
'CepstralOrder'
and a positive integer
Example: setAugmenterParams(aug,'shiftPitch','LockPhase',true,'PreserveFormants',false,'CepstralOrder',15)
enables the LockPhase
parameter, disables the
PreserveFormants
parameter, and sets a cepstral order of 15 for the
shiftPitch
augmentation algorithm.
Data Types: char
| string
| struct
Version History
Introduced in R2021a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)