feature: text to speech with button response and keboard response #143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Extending the two plugins
html-button-response
andhtml-keyboard-response
as two new pluginstext-to-speech-button-response
andtext-to-speech-keyboard-response
using the SpeechSynthesisUtterance API to read a string that is displayed to the participant.The Google Chrome browser comes with some voices. If using another browser it's most likely necessary to install voices locally. The voice can be set using
lang: fr-Fr
for example. Default is set tolang: en-US
.These two plugins take a string rather than html as stimulus but otherwise act the same way as the two plugins they extend.
Testing
They pass Jest testing except in one case (and the similar one for the keyboard response:
I think it might be related to the
clickTarget
function from the test-utils. I tried implementing my own by awaiting anew Promise
withsetTimeout
after invokingjest.useRealTimers()
and then invokingjest.useFakeTimers()
but couldn't get it to work. Any ideas on this would be greatly appreciated!I've also included Jest mock functions to test the
SpeechSynthesisUtterence
in the.spec.ts
files.If there is interest it would be cool to incorporate it into the main jsPsych repo. I'd be happy to work on anything else that is required for incorporating into the main repo.
minimal working examples
MWE can be found in the docs but are provided here for convience:
Best,
Cian