Speech to Text plugin - is a texteditoroperation possible? #5957
-
Hi all, @flancast90 and me were working on a speech-to-text TiddlyWiki5 plugin over the last two weeks (https://github.com/flancast90/Speech-To-Text-in-TW5) We're now discussing how to create a text-editor toolbar button that allows inserting the text recognized by the SpeechRecognition engine at a tiddlers' caret-position For that, we think about a new texteditoroperation that comes with the plugin The text-editor button should not trigger the tm-edit-text-operation message The question now is, if we should build a widget that handles the JS side and if it's possible to insert that widget in the buttons' text-field - or what's the best way to inject the wanted functionality in such a custom text-editor button We would really appreciate if you had some hints for us best wishes |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 20 replies
-
Hi @BurningTreeC the problem here is that text editor messages must do all of their work in a single synchronous function. If they trigger an asynchronous event handler (as I imagine you would be to retrieve the spoken text), then the context originally passed to the action will no longer be valid. Consider a case such as the edit text widget being deleted in between the button click and the completion of the transcription. I wonder if this can be approach generically: a simple JS dæmon that waits for a trigger word and then pipes the transcribed text into whatever text input has the focus. It could run as a startup module. |
Beta Was this translation helpful? Give feedback.
-
Thank you @Jermolene and @saqimtiaz for you help! |
Beta Was this translation helpful? Give feedback.
-
@BurningTreeC, just did some of my own tests. document.getElementsByClassName('tc-edit-texteditor tc-edit-texteditor-body')[1].contentWindow.document.body.getElementsByTagName('textarea')[0].innerHTML; We should then be able to access/change/write new content to the iframe textarea. It may not be the "TW Way", but I think it'll work. |
Beta Was this translation helpful? Give feedback.
-
As of now I'm able to pipe the spoken words into inputs and textareas and the framed texteditor, too. Is there a way to update the editTiddler from within our startup script? |
Beta Was this translation helpful? Give feedback.
Thank you @Jermolene and @saqimtiaz for you help!
But I'm in a dead end now. When I set the inputs' value and save the tiddler, the changes don't get saved