<commit_before>(function () {

var eleven = /[\u4e00-\u9fbf\u3040-\u309f\u30a0-\u30ff]/;

oneeSama.hook('menuOptions', function (info) {
	// TODO use model instead
	var text = $('#' + info.num).find('blockquote').text();
	if (text && eleven.exec(text))
		info.options.push('Speak');
});

menuHandlers.Speak = function ($post) {
	var $audio = $('<audio/>', {
		src: $post.attr('id') + '/voice',
		attr: {autoplay: 'autoplay'},
	});
	$audio.prop({
		onended: $.proxy($audio, 'remove'),
		onerror: function (err) {
			// TODO
			console.error('audio error', err);
		},
	}).appendTo('body');
};

})();<commit_msg>Remove voice audio after play properly<commit_after>(function () {

var eleven = /[\u4e00-\u9fbf\u3040-\u309f\u30a0-\u30ff]/;

oneeSama.hook('menuOptions', function (info) {
	// TODO use model instead
	var text = $('#' + info.num).find('blockquote').text();
	if (text && eleven.exec(text))
		info.options.push('Speak');
});

menuHandlers.Speak = function ($post) {
	var $audio = $('<audio/>', {
		src: $post.attr('id') + '/voice',
		attr: {autoplay: 'autoplay'},
	});
	$audio[0].addEventListener('ended', function () {
		$audio.remove();
	}, false);
	// TODO notify error
	$audio.appendTo('body');
};

})();
{'fraction_non_alphanumeric': 0.24013157894736842, 'fraction_numerical': 0.027138157894736843, 'mean_word_length': 4.156779661016949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '715071', 'n_tokens_mistral': 488, 'n_tokens_neox': 459, 'n_words': 85}