Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-say

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-say - npm Package Compare versions

Comparing version 0.0.1-master.f9fa4b6 to 1.0.0

2

CHANGELOG.md

@@ -8,3 +8,5 @@ # Changelog

## [Unreleased]
## [1.0.0] - 2018-07-09
### Added
- Initial release

@@ -32,9 +32,40 @@ 'use strict';

function Say() {
function Say(props) {
_classCallCheck(this, Say);
return _possibleConstructorReturn(this, (Say.__proto__ || Object.getPrototypeOf(Say)).apply(this, arguments));
var _this = _possibleConstructorReturn(this, (Say.__proto__ || Object.getPrototypeOf(Say)).call(this, props));
_this.handleBoundary = _this.handleBoundary.bind(_this);
_this.handleEnd = _this.handleEnd.bind(_this);
_this.handleError = _this.handleError.bind(_this);
_this.handleStart = _this.handleStart.bind(_this);
return _this;
}
_createClass(Say, [{
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.unmounted = true;
}
}, {
key: 'handleBoundary',
value: function handleBoundary(event) {
!this.unmounted && this.props.onBoundary && this.props.onBoundary(event);
}
}, {
key: 'handleEnd',
value: function handleEnd(event) {
!this.unmounted && this.props.onEnd && this.props.onEnd(event);
}
}, {
key: 'handleError',
value: function handleError(event) {
!this.unmounted && this.props.onError && this.props.onError(event);
}
}, {
key: 'handleStart',
value: function handleStart(event) {
!this.unmounted && this.props.onStart && this.props.onStart(event);
}
}, {
key: 'shouldComponentUpdate',

@@ -47,8 +78,6 @@ value: function shouldComponentUpdate(nextProps) {

value: function render() {
var _this2 = this;
var _props = this.props,
lang = _props.lang,
onBoundary = _props.onBoundary,
onEnd = _props.onEnd,
onError = _props.onError,
onStart = _props.onStart,
pitch = _props.pitch,

@@ -65,3 +94,14 @@ rate = _props.rate,

function (context) {
return context.speak({ lang: lang, onBoundary: onBoundary, onEnd: onEnd, onError: onError, onStart: onStart, pitch: pitch, rate: rate, text: text, voice: voice, volume: volume });
return context.speak({
lang: lang,
onBoundary: _this2.handleBoundary,
onEnd: _this2.handleEnd,
onError: _this2.handleError,
onStart: _this2.handleStart,
pitch: pitch,
rate: rate,
text: text,
voice: voice,
volume: volume
});
}

@@ -90,2 +130,2 @@ );

};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9TYXlQcmltaXRpdmUuanMiXSwibmFtZXMiOlsiU2F5IiwibmV4dFByb3BzIiwic3BlYWsiLCJwcm9wcyIsImxhbmciLCJvbkJvdW5kYXJ5Iiwib25FbmQiLCJvbkVycm9yIiwib25TdGFydCIsInBpdGNoIiwicmF0ZSIsInRleHQiLCJ2b2ljZSIsInZvbHVtZSIsImNvbnRleHQiLCJSZWFjdCIsIkNvbXBvbmVudCIsInByb3BUeXBlcyIsIlByb3BUeXBlcyIsInN0cmluZyIsIm51bWJlciIsImZ1bmMiLCJvbmVPZlR5cGUiLCJhbnkiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBQUE7Ozs7QUFDQTs7OztBQUVBOzs7Ozs7Ozs7Ozs7SUFFcUJBLEc7Ozs7Ozs7Ozs7OzBDQUNHQyxTLEVBQVc7QUFDL0IsYUFBT0EsVUFBVUMsS0FBVixLQUFvQixLQUFLQyxLQUFMLENBQVdELEtBQXRDO0FBQ0Q7Ozs2QkFFUTtBQUFBLG1CQUN3RixLQUFLQyxLQUQ3RjtBQUFBLFVBQ0NDLElBREQsVUFDQ0EsSUFERDtBQUFBLFVBQ09DLFVBRFAsVUFDT0EsVUFEUDtBQUFBLFVBQ21CQyxLQURuQixVQUNtQkEsS0FEbkI7QUFBQSxVQUMwQkMsT0FEMUIsVUFDMEJBLE9BRDFCO0FBQUEsVUFDbUNDLE9BRG5DLFVBQ21DQSxPQURuQztBQUFBLFVBQzRDQyxLQUQ1QyxVQUM0Q0EsS0FENUM7QUFBQSxVQUNtREMsSUFEbk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LFxuICBzcGVhazogUHJvcFR5cGVzLnN0cmluZyxcbiAgdm9pY2U6IFByb3BUeXBlcy5vbmVPZlR5cGUoW1Byb3BUeXBlcy5hbnksIFByb3BUeXBlcy5mdW5jXSksXG4gIHZvbHVtZTogUHJvcFR5cGVzLm51bWJlclxufTtcbiJdfQ==

2

package.json
{
"name": "react-say",
"version": "0.0.1-master.f9fa4b6",
"version": "1.0.0",
"description": "A React component that synthesis text into speech using Web Speech API",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -78,2 +78,35 @@ # react-say

## Bring your own `SpeechSynthesis`
You can bring your own `window.speechSynthesis` and `window.speechSynthesisUtterance` for custom speech synthesis. For example, you can bring Azure Cognitive Services thru [`web-speech-cognitive-services`](https://npmjs.com/package/web-speech-cognitive-services) package.
```jsx
import Say from 'react-say';
import { speechSynthesis, SpeechSynthesisUtterance, SubscriptionKey } from 'web-speech-cognitive-services';
// You will need to wait until the speech token has been exchanged
// The part has been omitted for code clarity
speechSynthesis.speechToken = new SubscriptionKey('your subscription key');
export default props =>
<Say
speak="A quick brown fox jumped over the lazy dogs."
speechSynthesis={ speechSynthesis }
speechSynthesisUtterance={ SpeechSynthesisUtterance }
/>
```
> Note: `speechSynthesis` is camel-casing because it is an instance.
# Caveats
* If `<Say>` or `<SayButton>` is unmounted, the utterance will continue to speak
* Web Speech does not support stopping or dequeueing a pending utterance, only to cancel all utterances at once
* Since the utterance is already queued, speaking, or spoken, we cannot stop it and not cancelling other "innocent" utterance
* We decided to let it continue but not firing any events after unmount
# Roadmap
* [ ] Prettify playground page
# Contributions

@@ -80,0 +113,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc