def METHOD_NAME(seconds, device, freq=455.5):
    def generator():
        player = Player(device)
        with player.changed_volume():
            for chunk in sine(freq, seconds * RATE, PERIOD):
                player.play(chunk)
    plr_thread = threading.Thread(target=generator)
    plr_thread.daemon = True
    plr_thread.start()
    rec = Recorder()
    samples = rec.record(seconds * RATE)
    # fft requires len(samples) to be a  power of 2.
    # let's trim samples to match that
    real_len = 2 ** math.floor(math.floor(math.log2(len(samples))))
    real_seconds = seconds * (real_len / len(samples))
    samples = samples[0:real_len]
    Y = fft(samples)
    freqs = [abs(y) for y in Y[:int(RATE/2)]]
    dominant = freqs.index(max(freqs)) / real_seconds
    print("Dominant frequency is {}, expected {}".format(dominant, freq))
    epsilon = 1.0
    if abs(dominant - freq) < epsilon:
        return 0
    else:
        return 1