Skip to content

Commit c243e1f

Browse files
authored
Update Mix_speech_and_noise.txt
# version 7: update to correct an error in variable names, # and corrected for the situation of different sample rates # in the target and the noise # also added check to make sure speech and noise have the same sampling frequency
1 parent 90a8ad5 commit c243e1f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Mix_speech_and_noise.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
# Praat will convert them to underscores upon loading and saving
5454
# e.g. Sound(copy) becomes Sound_copy_
5555
#
56+
# version 7: update to correct an error in variable names,
57+
# and corrected for the situation of different sample rates
58+
# in the target and the noise
59+
# also added check to make sure speech and noise have the same sampling frequency
5660
#
5761
#
5862
# Maybe other features can be added in the future
@@ -596,6 +600,23 @@ procedure mix_speech_and_noise_check_params
596600
if temp < 0
597601
exit PROBLEM: trail_silence_duration 'trail_silence_duration' cannot be less than zero
598602
endif
603+
604+
# check to make sure speech and noise have the same sampling frequency
605+
selectObject: "Sound 'mix_speech_and_noise.speech$'"
606+
.speech_samplerate = Get sampling frequency
607+
selectObject: "Sound 'mix_speech_and_noise.noise$'"
608+
.noise_samplerate = Get sampling frequency
609+
610+
# if they are not equal, resample the noise
611+
if .noise_samplerate != .speech_samplerate
612+
selectObject: "Sound 'mix_speech_and_noise.noise$'"
613+
Copy... 'mix_speech_and_noise.noise$'_original
614+
Resample... '.speech_samplerate' 30
615+
616+
# re-establish the name that will be called later
617+
Rename... 'mix_speech_and_noise.noise$'
618+
print NOTE: Noise 'mix_speech_and_noise.noise$' was resampled to match the samplerate of the target sound
619+
endif
599620
endproc
600621

601622
procedure check_folder_info

0 commit comments

Comments
 (0)