annyang 2.6.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +69 -44
- package/dist/annyang.cjs +354 -0
- package/dist/annyang.cjs.map +1 -0
- package/dist/annyang.d.cts +288 -0
- package/dist/annyang.d.ts +288 -0
- package/dist/annyang.iife.min.js +1 -0
- package/dist/annyang.js +296 -670
- package/dist/annyang.js.map +1 -1
- package/package.json +54 -34
- package/.editorconfig +0 -13
- package/.github/ISSUE_TEMPLATE.md +0 -32
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -29
- package/.jshintrc +0 -31
- package/.npmignore +0 -6
- package/.travis.yml +0 -22
- package/CONTRIBUTING.md +0 -74
- package/Gruntfile.js +0 -142
- package/bower.json +0 -25
- package/demo/css/main.css +0 -152
- package/demo/css/main.min.css +0 -1
- package/demo/images/flickr.png +0 -0
- package/demo/images/footer_background.jpg +0 -0
- package/demo/images/icon_js.png +0 -0
- package/demo/images/icon_speech.png +0 -0
- package/demo/images/icon_user.png +0 -0
- package/demo/images/mini_icon_say.png +0 -0
- package/demo/images/palette.png +0 -0
- package/demo/images/tpscover.jpg +0 -0
- package/demo/index.html +0 -233
- package/demo/vendor/css/default.css +0 -135
- package/demo/vendor/css/github.css +0 -127
- package/demo/vendor/css/tomorrow.css +0 -49
- package/demo/vendor/html/github-btn.html +0 -243
- package/demo/vendor/js/highlight.pack.js +0 -1
- package/dist/annyang.min.js +0 -7
- package/docs/FAQ.md +0 -186
- package/docs/README.md +0 -336
- package/sites/README.md +0 -6
- package/sites/facebook.js +0 -123
- package/sites/facebook.min.js +0 -12
- package/sites/geektime.js +0 -108
- package/sites/geektime.min.js +0 -12
- package/src/annyang.js +0 -680
- package/test/SpecRunner.html +0 -41
- package/test/init_corti.js +0 -1
- package/test/spec/.jshintrc +0 -40
- package/test/spec/BasicSpec.js +0 -1616
- package/test/spec/IssuesSpec.js +0 -41
- package/test/vendor/corti.js +0 -202
package/test/spec/IssuesSpec.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
(function (root, factory) {
|
|
2
|
-
// jshint strict: false
|
|
3
|
-
if (typeof module === 'object' && module.exports) { // CommonJS
|
|
4
|
-
factory(require('../../dist/annyang.js'));
|
|
5
|
-
} else if (typeof define === 'function' && define.amd) { // AMD
|
|
6
|
-
define(['annyang'], factory);
|
|
7
|
-
} else { // Browser globals
|
|
8
|
-
factory(root.annyang);
|
|
9
|
-
}
|
|
10
|
-
}(typeof window !== 'undefined' ? window : this, function factory(annyang) {
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
// Issue #193 (https://github.com/TalAter/annyang/issues/193)
|
|
14
|
-
describe('Speech recognition aborting while annyang is paused', function() {
|
|
15
|
-
|
|
16
|
-
var recognition;
|
|
17
|
-
|
|
18
|
-
beforeEach(function() {
|
|
19
|
-
recognition = annyang.getSpeechRecognizer();
|
|
20
|
-
jasmine.clock().install();
|
|
21
|
-
annyang.abort();
|
|
22
|
-
annyang.removeCommands();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(function() {
|
|
26
|
-
jasmine.clock().tick(2000);
|
|
27
|
-
jasmine.clock().uninstall();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should not unpause annyang on restart', function() {
|
|
31
|
-
annyang.start({ autoRestart: true, continuous: false });
|
|
32
|
-
annyang.pause();
|
|
33
|
-
recognition.abort();
|
|
34
|
-
expect(annyang.isListening()).toBe(false);
|
|
35
|
-
jasmine.clock().tick(1000);
|
|
36
|
-
expect(annyang.isListening()).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
}));
|
package/test/vendor/corti.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
//! Corti - Replaces the browser's SpeechRecognition with a fake object.
|
|
2
|
-
//! version : 0.4.0
|
|
3
|
-
//! author : Tal Ater @TalAter
|
|
4
|
-
//! license : MIT
|
|
5
|
-
//! https://github.com/TalAter/Corti
|
|
6
|
-
|
|
7
|
-
(function (undefined) {
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
// Save a reference to the global object (window in the browser)
|
|
11
|
-
var _root = this;
|
|
12
|
-
|
|
13
|
-
// Holds the browser's implementation
|
|
14
|
-
var _productionVersion = false;
|
|
15
|
-
|
|
16
|
-
// Patch DOMException
|
|
17
|
-
var DOMException = DOMException || TypeError;
|
|
18
|
-
|
|
19
|
-
// Speech Recognition attributes
|
|
20
|
-
var _maxAlternatives = 1;
|
|
21
|
-
var _lang = '';
|
|
22
|
-
var _continuous = false;
|
|
23
|
-
var _interimResults = false;
|
|
24
|
-
|
|
25
|
-
var newSpeechRecognition = function() {
|
|
26
|
-
var _self = this;
|
|
27
|
-
var _listeners = document.createElement('div');
|
|
28
|
-
_self._started = false;
|
|
29
|
-
_self._soundStarted = false;
|
|
30
|
-
_self.eventListenerTypes = ['start', 'soundstart', 'end', 'result'];
|
|
31
|
-
_self.maxAlternatives = 1;
|
|
32
|
-
|
|
33
|
-
// Add listeners for events registered through attributes (e.g. recognition.onend = function) and not as proper listeners
|
|
34
|
-
_self.eventListenerTypes.forEach(function(eventName) {
|
|
35
|
-
_listeners.addEventListener(eventName, function () {
|
|
36
|
-
if (typeof _self['on'+eventName] === 'function') {
|
|
37
|
-
_self['on'+eventName].apply(_listeners, arguments);
|
|
38
|
-
}
|
|
39
|
-
}, false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
Object.defineProperty(this, 'maxAlternatives', {
|
|
43
|
-
get: function() { return _maxAlternatives; },
|
|
44
|
-
set: function(val) {
|
|
45
|
-
if (typeof val === 'number') {
|
|
46
|
-
_maxAlternatives = Math.floor(val);
|
|
47
|
-
} else {
|
|
48
|
-
_maxAlternatives = 0;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
Object.defineProperty(this, 'lang', {
|
|
54
|
-
get: function() { return _lang; },
|
|
55
|
-
set: function(val) {
|
|
56
|
-
if (val === undefined) {
|
|
57
|
-
val = 'undefined';
|
|
58
|
-
}
|
|
59
|
-
_lang = val.toString();
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
Object.defineProperty(this, 'continuous', {
|
|
64
|
-
get: function() { return _continuous; },
|
|
65
|
-
set: function(val) {
|
|
66
|
-
_continuous = Boolean(val);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
Object.defineProperty(this, 'interimResults', {
|
|
71
|
-
get: function() { return _interimResults; },
|
|
72
|
-
set: function(val) {
|
|
73
|
-
_interimResults = Boolean(val);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
this.start = function() {
|
|
78
|
-
if (_self._started) {
|
|
79
|
-
throw new DOMException('Failed to execute \'start\' on \'SpeechRecognition\': recognition has already started.');
|
|
80
|
-
}
|
|
81
|
-
_self._started = true;
|
|
82
|
-
// Create and dispatch an event
|
|
83
|
-
var event = document.createEvent('CustomEvent');
|
|
84
|
-
event.initCustomEvent('start', false, false, null);
|
|
85
|
-
_listeners.dispatchEvent(event);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
this.abort = function() {
|
|
89
|
-
if (!_self._started) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
_self._started = false;
|
|
93
|
-
_self._soundStarted = false;
|
|
94
|
-
// Create and dispatch an event
|
|
95
|
-
var event = document.createEvent('CustomEvent');
|
|
96
|
-
event.initCustomEvent('end', false, false, null);
|
|
97
|
-
_listeners.dispatchEvent(event);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
this.stop = function() {
|
|
101
|
-
return _self.abort();
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
this.isStarted = function() {
|
|
105
|
-
return _self._started;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
this.say = function(sentence) {
|
|
109
|
-
if (!_self._started) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
// Create some speech alternatives
|
|
113
|
-
var results = [];
|
|
114
|
-
var commandIterator;
|
|
115
|
-
var etcIterator;
|
|
116
|
-
var itemFunction = function(index) {
|
|
117
|
-
if (undefined === index) {
|
|
118
|
-
throw new DOMException('Failed to execute \'item\' on \'SpeechRecognitionResult\': 1 argument required, but only 0 present.');
|
|
119
|
-
}
|
|
120
|
-
index = Number(index);
|
|
121
|
-
if (isNaN(index)) {
|
|
122
|
-
index = 0;
|
|
123
|
-
}
|
|
124
|
-
if (index >= this.length) {
|
|
125
|
-
return null;
|
|
126
|
-
} else {
|
|
127
|
-
return this[index];
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
for (commandIterator = 0; commandIterator<_maxAlternatives; commandIterator++) {
|
|
131
|
-
var etc = '';
|
|
132
|
-
for (etcIterator = 0; etcIterator<commandIterator; etcIterator++) {
|
|
133
|
-
etc += ' and so on';
|
|
134
|
-
}
|
|
135
|
-
results.push(sentence+etc);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Create the start event
|
|
139
|
-
var startEvent = document.createEvent('CustomEvent');
|
|
140
|
-
startEvent.initCustomEvent('result', false, false, {'sentence': sentence});
|
|
141
|
-
startEvent.resultIndex = 0;
|
|
142
|
-
startEvent.results = {
|
|
143
|
-
'item': itemFunction,
|
|
144
|
-
0: {
|
|
145
|
-
'item': itemFunction,
|
|
146
|
-
'final': true
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
for (commandIterator = 0; commandIterator<_maxAlternatives; commandIterator++) {
|
|
150
|
-
startEvent.results[0][commandIterator] = {
|
|
151
|
-
'transcript': results[commandIterator],
|
|
152
|
-
'confidence': Math.max(1-0.01*commandIterator, 0.001)
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
Object.defineProperty(startEvent.results, 'length', {
|
|
156
|
-
get: function() { return 1; }
|
|
157
|
-
});
|
|
158
|
-
Object.defineProperty(startEvent.results[0], 'length', {
|
|
159
|
-
get: function() { return _maxAlternatives; }
|
|
160
|
-
});
|
|
161
|
-
startEvent.interpretation = null;
|
|
162
|
-
startEvent.emma = null;
|
|
163
|
-
_listeners.dispatchEvent(startEvent);
|
|
164
|
-
|
|
165
|
-
// Create soundstart event
|
|
166
|
-
if (!_self._soundStarted) {
|
|
167
|
-
_self._soundStarted = true;
|
|
168
|
-
var soundStartEvent = document.createEvent('CustomEvent');
|
|
169
|
-
soundStartEvent.initCustomEvent('soundstart', false, false, null);
|
|
170
|
-
_listeners.dispatchEvent(soundStartEvent);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
//stop if not set to continuous mode
|
|
174
|
-
if (!_self.continuous) {
|
|
175
|
-
_self.abort();
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
this.addEventListener = function(event, callback) {
|
|
180
|
-
_listeners.addEventListener(event, callback, false);
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// Expose functionality
|
|
185
|
-
_root.Corti = {
|
|
186
|
-
patch: function() {
|
|
187
|
-
if (_productionVersion === false) {
|
|
188
|
-
_productionVersion = _root.SpeechRecognition ||
|
|
189
|
-
_root.webkitSpeechRecognition ||
|
|
190
|
-
_root.mozSpeechRecognition ||
|
|
191
|
-
_root.msSpeechRecognition ||
|
|
192
|
-
_root.oSpeechRecognition;
|
|
193
|
-
}
|
|
194
|
-
_root.SpeechRecognition = newSpeechRecognition;
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
unpatch: function() {
|
|
198
|
-
_root.SpeechRecognition = _productionVersion;
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
}).call(this);
|