react-say-fork
Version:
# Goal and TODOs * Add Typescript support * Make compononents style-customizable
23 lines (22 loc) • 907 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
const Context_1 = __importDefault(require("./Context"));
const createNativeUtterance_1 = __importDefault(require("./createNativeUtterance"));
function useSynthesize() {
const { ponyfill, synthesize } = (0, react_1.useContext)(Context_1.default);
return (utteranceOrText, progressFn) => {
if (typeof utteranceOrText === 'string') {
utteranceOrText = (0, createNativeUtterance_1.default)(ponyfill, {
text: utteranceOrText,
});
}
return synthesize(ponyfill, utteranceOrText, {
onStart: progressFn && (() => progressFn()),
});
};
}
exports.default = useSynthesize;