Skip to content

Commit

Permalink
Adopt event-target-shim (#72)
Browse files Browse the repository at this point in the history
* Adopt event-target-shim

* Fix ESLint

* Update PR number

* Bump eslint-utils
  • Loading branch information
compulim authored Sep 14, 2019
1 parent 4f86e55 commit 556e2aa
Show file tree
Hide file tree
Showing 9 changed files with 902 additions and 26 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Quirks: in continuous mode, calling `stop` in-between `recognizing` and `recognized` will not emit final `result` event
- Speech recognition: New `audioConfig` option to override the default `AudioConfig.fromDefaultMicrophoneInput`, in PR [#33](https://github.com/compulim/web-speech-cognitive-services/pull/33)
- Speech synthesis: Fix [#32](https://github.com/compulim/web-speech-cognitive-services/issues/32), fetch voices from services, in PR [#35](https://github.com/compulim/web-speech-cognitive-services/pull/35)
- Speech synthesis: Fix [#34](https://github.com/compulim/web-speech-cognitive-services/issues/34), in PR [#36](https://github.com/compulim/web-speech-cognitive-services/pull/36) and PR [#XXX](https://github.com/compulim/web-speech-cognitive-services/pull/XXX)
- Speech synthesis: Fix [#34](https://github.com/compulim/web-speech-cognitive-services/issues/34), in PR [#36](https://github.com/compulim/web-speech-cognitive-services/pull/36) and PR [#44](https://github.com/compulim/web-speech-cognitive-services/pull/44)
- Support user-controlled `AudioContext` object to be passed as an option named `audioContext`
- If no `audioContext` option is passed, will create a new `AudioContext` object on first synthesis
- Speech synthesis: If an empty utterance is being synthesized, will play an local empty audio clip, in PR [#36](https://github.com/compulim/web-speech-cognitive-services/pull/36)
Expand Down Expand Up @@ -60,6 +60,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added bundle distribution thru https://unpkg.com/web-speech-cognitive-services@latest/umd/, in PR [#21](https://github.com/compulim/web-speech-cognitive-services/pull/21)
- Bumped to [[email protected]](https://www.npmjs.com/package/microsoft-cognitiveservices-speech-sdk), in PR [#22](https://github.com/compulim/web-speech-cognitive-services/pull/22)
- Fix [#55](https://github.com/compulim/web-speech-cognitive-services/issues/55) and [#63](https://github.com/compulim/web-speech-cognitive-services/issues/63). Moves to [WHATWG `EventTarget` interface](https://dom.spec.whatwg.org/#interface-eventtarget), in PR [#56](https://github.com/compulim/web-speech-cognitive-services/pulls/56) and PR [#64](https://github.com/compulim/web-speech-cognitive-services/pulls/64)
- Instead of including `[email protected]`, we are adopting its source code, in PR [#72](https://github.com/compulim/web-speech-cognitive-services/pulls/72)
- This is because the original package requires browser to support rest/spread operators

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions packages/bundle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/component/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/**/*.spec.js
/**/*.test.js
/src/BingSpeech/**/*
/src/external/**/*
6 changes: 3 additions & 3 deletions packages/component/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint no-empty-function: "off" */
/* eslint no-magic-numbers: ["error", { "ignore": [0, 100, 150] }] */

import { defineEventAttribute, EventTarget } from 'event-target-shim';
import { defineEventAttribute, EventTarget } from '../../external/event-target-shim';

import cognitiveServiceEventResultToWebSpeechRecognitionResultList from './cognitiveServiceEventResultToWebSpeechRecognitionResultList';
import createPromiseQueue from '../../Util/createPromiseQueue';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint no-empty: ["error", { "allowEmptyCatch": true }] */

import { defineEventAttribute, EventTarget } from 'event-target-shim';
import { defineEventAttribute, EventTarget } from '../../external/event-target-shim';
import EventAsPromise from 'event-as-promise';

import fetchSpeechData from './fetchSpeechData';
import SpeechSynthesisEvent from './SpeechSynthesisEvent';
import SpeechSynthesisVoice from './SpeechSynthesisVoice';
import subscribeEvent from './subscribeEvent';

function asyncDecodeAudioData(audioContext, arrayBuffer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { defineEventAttribute, EventTarget } from 'event-target-shim';
/* eslint class-methods-use-this: 0 */

import { defineEventAttribute, EventTarget } from '../../external/event-target-shim';
import memoize from 'memoize-one';
import onErrorResumeNext from 'on-error-resume-next';

Expand Down Expand Up @@ -46,20 +48,18 @@ export default ({
)
);

const getAuthorizationToken = async () => {
return (
typeof authorizationToken === 'function' ?
await authorizationToken()
: authorizationToken ?
await authorizationToken
:
await fetchMemoizedAuthorizationToken({
now: Date.now,
region,
subscriptionKey
})
);
};
const getAuthorizationToken = () => (
typeof authorizationToken === 'function' ?
authorizationToken()
: authorizationToken ?
authorizationToken
:
fetchMemoizedAuthorizationToken({
now: Date.now,
region,
subscriptionKey
})
);

class SpeechSynthesis extends EventTarget {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function fetchEndpoint({ deploymentId, region, subscriptionKey }) {
throw new Error('Failed to fetch custom voices');
}

return await res.json();
return res.json();
}

export default async function ({ deploymentId, region, subscriptionKey }) {
Expand Down
Loading

0 comments on commit 556e2aa

Please sign in to comment.