(wav_audio, hparams, pipeline=None)
Transform the contents of a wav file based on hyperparameters.

  Args:
    wav_audio: The contents of a wav file; this will be written to a temporary
        file and transformed via SoX.
    hparams: The tf.contrib.training.HParams object to use to construct the
        audio transform pipeline.
    pipeline: A list of pipeline stages, each specified as a tuple of stage
        name (SoX method) and a dictionary of parameters. If None, uses
        `AUDIO_TRANSFORM_PIPELINE`.

  Returns:
    The contents of the wav file that results from applying the audio transform
    pipeline to the input audio.
Transform the contents of a wav file based on hyperparameters.
Transform the contents of a wav file based on hyperparameters .
def transform_wav_audio(wav_audio, hparams, pipeline=None):
  """Transform the contents of a wav file based on hyperparameters.

  Args:
    wav_audio: The contents of a wav file; this will be written to a temporary
        file and transformed via SoX.
    hparams: The tf.contrib.training.HParams object to use to construct the
        audio transform pipeline.
    pipeline: A list of pipeline stages, each specified as a tuple of stage
        name (SoX method) and a dictionary of parameters. If None, uses
        `AUDIO_TRANSFORM_PIPELINE`.

  Returns:
    The contents of the wav file that results from applying the audio transform
    pipeline to the input audio.
  """
  if not hparams.transform_audio:
    return wav_audio

  pipeline = construct_pipeline(
      hparams, pipeline if pipeline is not None else AUDIO_TRANSFORM_PIPELINE)

  with tempfile.NamedTemporaryFile(suffix='.wav') as temp_input_with_noise:
    with tempfile.NamedTemporaryFile(suffix='.wav') as temp_input:
      temp_input.write(wav_audio)
      temp_input.flush()

      # Add noise before all other pipeline steps.
      noise_vol = random.uniform(hparams.audio_transform_min_noise_vol,
                                 hparams.audio_transform_max_noise_vol)
      add_noise(temp_input.name, temp_input_with_noise.name, noise_vol,
                hparams.audio_transform_noise_type)

    with tempfile.NamedTemporaryFile(suffix='.wav') as temp_output:
      run_pipeline(pipeline, temp_input_with_noise.name, temp_output.name)
      return temp_output.read()
def transform_wav_audio ( wav_audio , hparams , pipeline = None ) : if not hparams . transform_audio : return wav_audio pipeline = construct_pipeline ( hparams , pipeline if pipeline is not None else AUDIO_TRANSFORM_PIPELINE ) with tempfile . NamedTemporaryFile ( suffix = '.wav' ) as temp_input_with_noise : with tempfile . NamedTemporaryFile ( suffix = '.wav' ) as temp_input : temp_input . write ( wav_audio ) temp_input . flush ( ) # Add noise before all other pipeline steps. noise_vol = random . uniform ( hparams . audio_transform_min_noise_vol , hparams . audio_transform_max_noise_vol ) add_noise ( temp_input . name , temp_input_with_noise . name , noise_vol , hparams . audio_transform_noise_type ) with tempfile . NamedTemporaryFile ( suffix = '.wav' ) as temp_output : run_pipeline ( pipeline , temp_input_with_noise . name , temp_output . name ) return temp_output . read ( )