rec = rnorm(5000) # white noise
donor = soundgen() # voiced /a/
whisper = transplantFormants(donor = donor, recipient = rec,
samplingRate = 16000, freqWindow = 300) # whispered /a/
# playme(whisper)
meanSpectrum(whisper, 16000)
if (FALSE) {
# Objective: take formants from one sound and apply them to another
s_orig = soundgen(pitch = 100, formants = 'ai')
recipient = soundgen(
sylLen = 1200,
pitch = c(100, 300, 250, 200),
vibratoFreq = 9, vibratoDep = 1,
formants = NULL,
addSilence = 180,
samplingRate = 16000, # same as donor
invalidArgAction = 'ignore') # force to keep the low samplingRate
playme(recipient, 16000)
spectrogram(recipient, 16000)
s1 = transplantFormants(
donor = s_orig,
recipient = recipient,
samplingRate = 16000)
playme(s1, 16000)
spectrogram(s1, 16000)
# The spectral envelope of s1 will be similar to that of the original on a
# frequency scale determined by freqWindow. Compare the spectra:
par(mfrow = c(1, 2))
meanSpectrum(s_orig, 16000, yScale = 'max0', ylim = c(-50, 0), main = 'Donor')
meanSpectrum(s1, 16000, yScale = 'max0', ylim = c(-50, 0),
main = 'Processed recipient')
par(mfrow = c(1, 1))
# if needed, transplant amplitude envelopes as well:
s2 = transplantEnv(donor = s_orig, recipient = s1,
samplingRateR = 16000, samplingRateD = 16000,
windowLength = 10)
playme(s2, 16000)
spectrogram(s2, 16000)
}
Run the code above in your browser using DataLab