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.
Files changed (50) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +69 -44
  3. package/dist/annyang.cjs +354 -0
  4. package/dist/annyang.cjs.map +1 -0
  5. package/dist/annyang.d.cts +288 -0
  6. package/dist/annyang.d.ts +288 -0
  7. package/dist/annyang.iife.min.js +1 -0
  8. package/dist/annyang.js +296 -670
  9. package/dist/annyang.js.map +1 -1
  10. package/package.json +54 -34
  11. package/.editorconfig +0 -13
  12. package/.github/ISSUE_TEMPLATE.md +0 -32
  13. package/.github/PULL_REQUEST_TEMPLATE.md +0 -29
  14. package/.jshintrc +0 -31
  15. package/.npmignore +0 -6
  16. package/.travis.yml +0 -22
  17. package/CONTRIBUTING.md +0 -74
  18. package/Gruntfile.js +0 -142
  19. package/bower.json +0 -25
  20. package/demo/css/main.css +0 -152
  21. package/demo/css/main.min.css +0 -1
  22. package/demo/images/flickr.png +0 -0
  23. package/demo/images/footer_background.jpg +0 -0
  24. package/demo/images/icon_js.png +0 -0
  25. package/demo/images/icon_speech.png +0 -0
  26. package/demo/images/icon_user.png +0 -0
  27. package/demo/images/mini_icon_say.png +0 -0
  28. package/demo/images/palette.png +0 -0
  29. package/demo/images/tpscover.jpg +0 -0
  30. package/demo/index.html +0 -233
  31. package/demo/vendor/css/default.css +0 -135
  32. package/demo/vendor/css/github.css +0 -127
  33. package/demo/vendor/css/tomorrow.css +0 -49
  34. package/demo/vendor/html/github-btn.html +0 -243
  35. package/demo/vendor/js/highlight.pack.js +0 -1
  36. package/dist/annyang.min.js +0 -7
  37. package/docs/FAQ.md +0 -186
  38. package/docs/README.md +0 -336
  39. package/sites/README.md +0 -6
  40. package/sites/facebook.js +0 -123
  41. package/sites/facebook.min.js +0 -12
  42. package/sites/geektime.js +0 -108
  43. package/sites/geektime.min.js +0 -12
  44. package/src/annyang.js +0 -680
  45. package/test/SpecRunner.html +0 -41
  46. package/test/init_corti.js +0 -1
  47. package/test/spec/.jshintrc +0 -40
  48. package/test/spec/BasicSpec.js +0 -1616
  49. package/test/spec/IssuesSpec.js +0 -41
  50. package/test/vendor/corti.js +0 -202
@@ -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
- }));
@@ -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);