(input_filename, output_filename, noise_vol, noise_type)
Add noise to a wav file using sox.

  Args:
    input_filename: Path to the original wav file.
    output_filename: Path to the output wav file that will consist of the input
        file plus noise.
    noise_vol: The volume of the noise to add.
    noise_type: One of "whitenoise", "pinknoise", "brownnoise".

  Raises:
    ValueError: If `noise_type` is not one of "whitenoise", "pinknoise", or
        "brownnoise".
Add noise to a wav file using sox.
Add noise to a wav file using sox .
def add_noise(input_filename, output_filename, noise_vol, noise_type):
  """Add noise to a wav file using sox.

  Args:
    input_filename: Path to the original wav file.
    output_filename: Path to the output wav file that will consist of the input
        file plus noise.
    noise_vol: The volume of the noise to add.
    noise_type: One of "whitenoise", "pinknoise", "brownnoise".

  Raises:
    ValueError: If `noise_type` is not one of "whitenoise", "pinknoise", or
        "brownnoise".
  """
  if noise_type not in ('whitenoise', 'pinknoise', 'brownnoise'):
    raise ValueError('invalid noise type: %s' % noise_type)

  args = ['sox', input_filename, '-p', 'synth', noise_type, 'vol',
          str(noise_vol), '|', 'sox', '-m', input_filename, '-',
          output_filename]
  command = ' '.join(args)
  tf.logging.info('Executing: %s', command)

  process_handle = subprocess.Popen(
      command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  process_handle.communicate()
def add_noise ( input_filename , output_filename , noise_vol , noise_type ) : if noise_type not in ( 'whitenoise' , 'pinknoise' , 'brownnoise' ) : raise ValueError ( 'invalid noise type: %s' % noise_type ) args = [ 'sox' , input_filename , '-p' , 'synth' , noise_type , 'vol' , str ( noise_vol ) , '|' , 'sox' , '-m' , input_filename , '-' , output_filename ] command = ' ' . join ( args ) tf . logging . info ( 'Executing: %s' , command ) process_handle = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = True ) process_handle . communicate ( )