<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
===============================================================================
Script 'play-noise.py'
===============================================================================

This script plays noise for headphone calibration purposes.
"""
# @author: drmccloy
# Created on Tue Jul 25 14:35:40 PDT 2017
# License: BSD (3-clause)

import os.path as op
import numpy as np
import sounddevice as sd
import soundfile as sf
from expyfun import ExperimentController, get_keyboard_input
from expyfun.stimuli import read_wav


# load noise file
noise, fs = read_wav('whitenoise_16bit_44100Hz_70dB.wav')
dur = noise.shape[-1] / fs

ec_params = dict(exp_name='test-noise', participant='noise', session=0,
                 audio_controller='pyglet', response_device='keyboard',
                 stim_fs=44100, stim_rms=0.01, check_rms=None, output_dir=None,
                 force_quit=['q'], full_screen=False, window_size=(800, 600),
                 version='dev')

with ExperimentController(**ec_params) as ec:
    quit_key = ec._response_handler.force_quit_keys[0]
    ec.screen_text('press "{}" to quit'.format(quit_key))
    ec.load_buffer(noise)
    ec.identify_trial(ec_id='noise', ttl_id=[])
    ec.start_stimulus()
    ec.wait_secs(dur)
    ec.trial_ok()<commit_msg>fix: missing quotes in ec session kwarg<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
===============================================================================
Script 'play-noise.py'
===============================================================================

This script plays noise for headphone calibration purposes.
"""
# @author: drmccloy
# Created on Tue Jul 25 14:35:40 PDT 2017
# License: BSD (3-clause)

import os.path as op
import numpy as np
import sounddevice as sd
import soundfile as sf
from expyfun import ExperimentController, get_keyboard_input
from expyfun.stimuli import read_wav


# load noise file
noise, fs = read_wav('whitenoise_16bit_44100Hz_70dB.wav')
dur = noise.shape[-1] / fs

ec_params = dict(exp_name='test-noise', participant='noise', session='0',
                 audio_controller='pyglet', response_device='keyboard',
                 stim_fs=44100, stim_rms=0.01, check_rms=None, output_dir=None,
                 force_quit=['q'], full_screen=False, window_size=(800, 600),
                 version='dev')

with ExperimentController(**ec_params) as ec:
    quit_key = ec._response_handler.force_quit_keys[0]
    ec.screen_text('press "{}" to quit'.format(quit_key))
    ec.load_buffer(noise)
    ec.identify_trial(ec_id='noise', ttl_id=[])
    ec.start_stimulus()
    ec.wait_secs(dur)
    ec.trial_ok()
{'fraction_non_alphanumeric': 0.22653362897265336, 'fraction_numerical': 0.030303030303030304, 'mean_word_length': 4.581443298969072, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '292530', 'n_tokens_mistral': 927, 'n_tokens_neox': 818, 'n_words': 187}