|
53 | 53 | # Praat will convert them to underscores upon loading and saving
|
54 | 54 | # e.g. Sound(copy) becomes Sound_copy_
|
55 | 55 | #
|
| 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 |
56 | 60 | #
|
57 | 61 | #
|
58 | 62 | # Maybe other features can be added in the future
|
@@ -596,6 +600,23 @@ procedure mix_speech_and_noise_check_params
|
596 | 600 | if temp < 0
|
597 | 601 | exit PROBLEM: trail_silence_duration 'trail_silence_duration' cannot be less than zero
|
598 | 602 | 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 |
599 | 620 | endproc
|
600 | 621 |
|
601 | 622 | procedure check_folder_info
|
|
0 commit comments