# Path: telluride_decoding/add_trigger.py
# FLAGS = flags.FLAGS
# def random_times(duration, number, minimum_interval=0.5, include_zero=True):
# def add_events_to_audio(audio_signal, event_times, fs=16000,
#                         pulse_length=0.1, pulse_freq=0):
# def read_audio_wave_file(audio_filename):
# def write_audio_wave_file(audio_filename, audio_signal, fs):
# def main(_):


import os
import google3
import numpy as np
from absl import flags
from absl.testing import absltest
from telluride_decoding import add_trigger
from six.moves import range
    minimum_interval = 0.5
    number = int(audio_seconds)
    include_zero = True
    pulse_length = 0.1
    event_times = add_trigger.random_times(audio_seconds, number,
                                           minimum_interval, include_zero)
    print('Event_times are:', event_times)
    triggered_audio = add_trigger.add_events_to_audio(audio_signal, event_times,
                                                      fs=audio_fs,
                                                      pulse_length=pulse_length)
    self.assertLen(triggered_audio.shape, 2)
    self.assertEqual(triggered_audio.shape[0], 50381)
    self.assertEqual(triggered_audio.shape[1], 2)
    self.assertLen(set(triggered_audio[:, 1]), 2)

    self.assertTrue(np.all(triggered_audio[:, 0] == audio_signal))
    event_start = int(event_times[0]*audio_fs) + 1
    event_end = event_start + int(pulse_length*audio_fs) - 1
    self.assertTrue(np.all(triggered_audio[event_start:event_end, 1] == 32767))

  def test_add_triggers_freq(self):
    audio_file = os.path.join(self._test_data, 'tapestry.wav')
    [audio_fs, audio_signal] = add_trigger.read_audio_wave_file(audio_file)
    audio_seconds = audio_signal.shape[0]/float(audio_fs)

    minimum_interval = 0.5
    number = int(audio_seconds)
    include_zero = True
    pulse_length = 0.1
    tone_freq = 440

# Path: telluride_decoding/add_trigger.py
# FLAGS = flags.FLAGS
# def random_times(duration, number, minimum_interval=0.5, include_zero=True):
# def add_events_to_audio(audio_signal, event_times, fs=16000,
#                         pulse_length=0.1, pulse_freq=0):
# def read_audio_wave_file(audio_filename):
# def write_audio_wave_file(audio_filename, audio_signal, fs):
# def main(_):


# Path: test/add_trigger_test.py
import os
import google3
import numpy as np
from absl import flags
from absl.testing import absltest
from telluride_decoding import add_trigger
from six.moves import range

    minimum_interval = 0.5
    number = int(audio_seconds)
    include_zero = True
    pulse_length = 0.1
    event_times = add_trigger.random_times(audio_seconds, number,
                                           minimum_interval, include_zero)
    print('Event_times are:', event_times)
    triggered_audio = add_trigger.add_events_to_audio(audio_signal, event_times,
                                                      fs=audio_fs,
                                                      pulse_length=pulse_length)
    self.assertLen(triggered_audio.shape, 2)
    self.assertEqual(triggered_audio.shape[0], 50381)
    self.assertEqual(triggered_audio.shape[1], 2)
    self.assertLen(set(triggered_audio[:, 1]), 2)

    self.assertTrue(np.all(triggered_audio[:, 0] == audio_signal))
    event_start = int(event_times[0]*audio_fs) + 1
    event_end = event_start + int(pulse_length*audio_fs) - 1
    self.assertTrue(np.all(triggered_audio[event_start:event_end, 1] == 32767))

  def test_add_triggers_freq(self):
    audio_file = os.path.join(self._test_data, 'tapestry.wav')
    [audio_fs, audio_signal] = add_trigger.read_audio_wave_file(audio_file)
    audio_seconds = audio_signal.shape[0]/float(audio_fs)

    minimum_interval = 0.5
    number = int(audio_seconds)
    include_zero = True
    pulse_length = 0.1
    tone_freq = 440

    event_times = add_trigger.random_times(audio_seconds, number,