<commit_before>'use strict';
var assign = require('object-assign');
var msgs = require('./messages.js');
var hasOwnDeep = require('has-own-deep');
var getValue = require('get-value');
var say = require('say');

module.exports = function (opts) {
	var defaults = {
		voice: null,
		messages: msgs,
		filters: false
	};
	var options = assign({}, defaults, opts);
	var messages = [];

	if (typeof options.messages === 'string') {
		messages.push(options.messages);
	} else if (Array.isArray(options.messages) || (options.messages instanceof Object)) {
		messages = [options.messages];
	} else {
		throw new TypeError('Expected a string an Array or an Object');
	}

	// filter and populate messages[]
	if (options.filters) {
		var filters = options.filters;
		if (typeof filters === 'string' && options.messages.hasOwnProperty(filters)) {
			messages = options.messages[filters];
		} else {
			messages = [];
			for (var i in filters) {
				if ({}.hasOwnProperty.call(filters, i) && hasOwnDeep(options.messages, filters[i])) {
					messages.push(getValue(options.messages, filters[i]));
				}<commit_msg>Add option to pass a string instead of an array of options<commit_after>'use strict';
var assign = require('object-assign');
var msgs = require('./messages.js');
var hasOwnDeep = require('has-own-deep');
var getValue = require('get-value');
var say = require('say');

module.exports = function (opts) {
	var defaults = {
		voice: null,
		messages: msgs,
		filters: false
	};

	if (typeof opts === 'string') {
		defaults.messages = opts;
	}

	var options = assign({}, defaults, opts);
	var messages = [];

	if (typeof options.messages === 'string') {
		messages.push(options.messages);
	} else if (Array.isArray(options.messages) || (options.messages instanceof Object)) {
		messages = [options.messages];
	} else {
		throw new TypeError('Expected a string an Array or an Object');
	}

	// filter and populate messages[]
	if (options.filters) {
		var filters = options.filters;
		if (typeof filters === 'string' && options.messages.hasOwnProperty(filters)) {
			messages = options.messages[filters];
		} else {
			messages = [];
			for (var i in filters) {
				if ({}.hasOwnProperty.call(filters, i) && hasOwnDeep(options.messages, filters[i])) {
					messages.push(getValue(options.messages, filters[i]));
				}
{'fraction_non_alphanumeric': 0.15837299870186067, 'fraction_numerical': 0.0, 'mean_word_length': 4.266514806378132, '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': '3445118', 'n_tokens_mistral': 741, 'n_tokens_neox': 686, 'n_words': 195}