parent
ad82c87712
commit
99e819e8ea
@ -0,0 +1,34 @@
|
||||
[
|
||||
{
|
||||
"type": "noise",
|
||||
"params": {"min_snr_dB": 50,
|
||||
"max_snr_dB": 50,
|
||||
"noise_manifest": "datasets/manifest.noise"},
|
||||
"prob": 0.0
|
||||
},
|
||||
{
|
||||
"type": "speed",
|
||||
"params": {"min_speed_rate": 0.9,
|
||||
"max_speed_rate": 1.1},
|
||||
"prob": 0.0
|
||||
},
|
||||
{
|
||||
"type": "shift",
|
||||
"params": {"min_shift_ms": -5,
|
||||
"max_shift_ms": 5},
|
||||
"prob": 1.0
|
||||
},
|
||||
{
|
||||
"type": "volume",
|
||||
"params": {"min_gain_dBFS": -10,
|
||||
"max_gain_dBFS": 10},
|
||||
"prob": 0.0
|
||||
},
|
||||
{
|
||||
"type": "bayesian_normal",
|
||||
"params": {"target_db": -20,
|
||||
"prior_db": -20,
|
||||
"prior_samples": 100},
|
||||
"prob": 0.0
|
||||
}
|
||||
]
|
@ -0,0 +1,34 @@
|
||||
"""Contains the impulse response augmentation model."""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from data_utils.augmentor.base import AugmentorBase
|
||||
from data_utils import utils
|
||||
from data_utils.audio import AudioSegment
|
||||
|
||||
|
||||
class ImpulseResponseAugmentor(AugmentorBase):
|
||||
"""Augmentation model for adding impulse response effect.
|
||||
|
||||
:param rng: Random generator object.
|
||||
:type rng: random.Random
|
||||
:param impulse_manifest: Manifest path for impulse audio data.
|
||||
:type impulse_manifest: basestring
|
||||
"""
|
||||
|
||||
def __init__(self, rng, impulse_manifest):
|
||||
self._rng = rng
|
||||
self._manifest = utils.read_manifest(manifest_path=impulse_manifest)
|
||||
|
||||
def transform_audio(self, audio_segment):
|
||||
"""Add impulse response effect.
|
||||
|
||||
Note that this is an in-place transformation.
|
||||
|
||||
:param audio_segment: Audio segment to add effects to.
|
||||
:type audio_segment: AudioSegmenet|SpeechSegment
|
||||
"""
|
||||
noise_json = self._rng.sample(self._manifest, 1)[0]
|
||||
noise_segment = AudioSegment.from_file(noise_json['audio_filepath'])
|
||||
audio_segment.convolve(noise_segment, allow_resample=True)
|
Loading…
Reference in new issue