@speechly/react-ui
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -75,4 +75,4 @@ "use strict"; | ||
var buttonStateRef = (0, react_1.useRef)({ | ||
holdListening: false, | ||
stopContextTimeout: null, | ||
tapListenActive: false, | ||
tapListenTimeout: null, | ||
}); | ||
@@ -125,3 +125,3 @@ var buttonRef = (0, react_1.useRef)(); | ||
// Automatically start recording if button held | ||
if (!powerOn && (((_a = buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) === null || _a === void 0 ? void 0 : _a.isbuttonpressed()) === true || buttonStateRef.current.holdListening) && speechState === react_client_1.SpeechState.Ready) { | ||
if (!powerOn && (((_a = buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) === null || _a === void 0 ? void 0 : _a.isbuttonpressed()) === true || buttonStateRef.current.tapListenActive) && speechState === react_client_1.SpeechState.Ready) { | ||
toggleRecording().catch(function (err) { return console.error('Error while starting to record', err); }); | ||
@@ -135,5 +135,5 @@ } | ||
setShowHint(false); | ||
if (buttonStateRef.current.stopContextTimeout) { | ||
window.clearTimeout(buttonStateRef.current.stopContextTimeout); | ||
buttonStateRef.current.stopContextTimeout = null; | ||
if (buttonStateRef.current.tapListenTimeout) { | ||
window.clearTimeout(buttonStateRef.current.tapListenTimeout); | ||
buttonStateRef.current.tapListenTimeout = null; | ||
} | ||
@@ -164,3 +164,3 @@ switch (speechStateRef.current) { | ||
// Short press when not recording = schedule "silence based stop" | ||
if (!buttonStateRef.current.holdListening) { | ||
if (!buttonStateRef.current.tapListenActive) { | ||
setStopContextTimeout(tapToTalkTime); | ||
@@ -170,3 +170,3 @@ } | ||
} | ||
if (!buttonStateRef.current.stopContextTimeout) { | ||
if (!buttonStateRef.current.tapListenTimeout) { | ||
stopListening(); | ||
@@ -176,13 +176,15 @@ } | ||
var setStopContextTimeout = function (timeoutMs) { | ||
buttonStateRef.current.holdListening = true; | ||
if (buttonStateRef.current.stopContextTimeout) { | ||
window.clearTimeout(buttonStateRef.current.stopContextTimeout); | ||
if (isStoppable(speechState)) { | ||
buttonStateRef.current.tapListenActive = true; | ||
if (buttonStateRef.current.tapListenTimeout) { | ||
window.clearTimeout(buttonStateRef.current.tapListenTimeout); | ||
} | ||
buttonStateRef.current.tapListenTimeout = window.setTimeout(function () { | ||
buttonStateRef.current.tapListenTimeout = null; | ||
stopListening(); | ||
}, timeoutMs); | ||
} | ||
buttonStateRef.current.stopContextTimeout = window.setTimeout(function () { | ||
buttonStateRef.current.stopContextTimeout = null; | ||
stopListening(); | ||
}, timeoutMs); | ||
}; | ||
var stopListening = function () { | ||
buttonStateRef.current.holdListening = false; | ||
buttonStateRef.current.tapListenActive = false; | ||
if (isStoppable(speechStateRef.current)) { | ||
@@ -197,3 +199,3 @@ toggleRecording().catch(function (err) { return console.error('Error while stopping recording', err); }); | ||
if (segment) { | ||
if (buttonStateRef.current.stopContextTimeout) { | ||
if (buttonStateRef.current.tapListenTimeout) { | ||
setStopContextTimeout(silenceToHangupTime); | ||
@@ -200,0 +202,0 @@ } |
{ | ||
"name": "@speechly/react-ui", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Speechly UI Components", | ||
@@ -33,3 +33,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@speechly/react-client": ">=0.0.23", | ||
"@speechly/react-client": ">=1.1.0", | ||
"@speechly/browser-client": ">=1.0.19", | ||
@@ -55,3 +55,3 @@ "@typescript-eslint/eslint-plugin": "^4.4.0", | ||
"peerDependencies": { | ||
"@speechly/react-client": ">=0.0.20", | ||
"@speechly/react-client": ">=1.1.0", | ||
"react": ">=16.13.1", | ||
@@ -58,0 +58,0 @@ "react-dom": ">=16.13.1" |
<div align="center" markdown="1"> | ||
<a href="https://www.speechly.com/?utm_source=github&utm_medium=browser-client&utm_campaign=header"> | ||
<img src="https://d33wubrfki0l68.cloudfront.net/1e70457a60b0627de6ab966f1e0a40cf56f465f5/b4144/img/logo-speechly-colors.svg" height="48"> | ||
<a href="https://www.speechly.com"> | ||
<img src="https://d33wubrfki0l68.cloudfront.net/f15fc952956e1952d6bd23661b7a7ee6b775faaa/c1b30/img/speechly-logo-duo-black.svg" height="48" /> | ||
</a> | ||
### Speechly is the Fast, Accurate, and Simple Voice Interface API for Web, Mobile and E‑commerce | ||
### The Fast, Accurate, and Simple Voice Interface API | ||
[Website](https://www.speechly.com/?utm_source=github&utm_medium=browser-client&utm_campaign=header) | ||
[Website](https://www.speechly.com/) | ||
 |  | ||
@@ -14,3 +14,3 @@ [Docs](https://docs.speechly.com/) | ||
 |  | ||
[Blog](https://www.speechly.com/blog/?utm_source=github&utm_medium=browser-client&utm_campaign=header) | ||
[Blog](https://www.speechly.com/blog/) | ||
 |  | ||
@@ -22,4 +22,2 @@ [Podcast](https://anchor.fm/the-speechly-podcast) | ||
# Speechly React UI components | ||
![Release build](https://github.com/speechly/react-ui/workflows/Release%20build/badge.svg) | ||
@@ -29,6 +27,8 @@ [![npm version](https://badge.fury.io/js/%40speechly%2Freact-ui.svg)](https://badge.fury.io/js/%40speechly%2Freact-ui) | ||
## Introduction | ||
# Speechly React UI components | ||
`@speechly/react-ui` package is an optional UI component library for speeding up voice-enabled web app development using React and Speechly. | ||
Ready made Speechly [UI components](https://docs.speechly.com/client-libraries/ui-components/) to build a reactive voice interface to a React or Next.js app. | ||
> If you want to build a custom interface for you web app, you may want to check out [react-client](https://github.com/speechly/speechly/tree/main/libraries/react-client) library for direct access to Speechly API. | ||
## Contents | ||
@@ -35,0 +35,0 @@ |
Sorry, the diff of this file is not supported yet
97221
1328