Closed reecpj closed 9 months ago
Does neither
toggle echo:
user.toggle_echo()
toggle echo all:
user.toggle_echo_all()
work for you? I will say as well that I am still in something of a pre-alpha phase so I need to do some work rearranging commands and making everything a bit easier to understand.
If you have any context for your use/workflow that would perhaps be of help, feel free to let me know in one of these issues, wherever you see fit. (I wasn't sure if you use a screen reader)
looking at this again perhaps I misinterpreted you, you're referring to interrupts right? Also let me know what operating system you're on. In my code, Linux currently supports interrupts, so if you are speaking something and then speak something else, it will interrupt the previous TTS.
I support interrupts on windows if you are using NVDA, but I'm still trying to think about ways to allow interrupts on windows without the screen reader. (I might just switch to using multiprocessing instead of threading so I can kill it immediately, since we can't send signals to threads in python)
Pushed support for windows interrupts to latest commit. As such, I am closing this, but let me know if it doesn't work for any reason and I will repopen
Sorry, I am on Mac. I have, in my own code, added the following to core-mac.py:
actions.user.cancel_current_speaker()
# existing code
proc = subprocess.Popen(["say", text])
and made a custom "cancel speech" talon command to call user.cancel_current_speaker()
It might be worth adding that.
@patrickreece2 could you give more context on your use case? Essentially I don't have the cancellation occurring in the TTS function since sometimes we want to "stack" the TTS so to speak and make sure that a user hears both phrases one after another without canceling either.
However, any speech command should cancel current speech. I do not have a command to explicitly cancel speech. That is assuming you copied the callbacks.py file within the core functionality.
I would recommend cloning the entire repository since the settings are deliberately such that it can be used out of the box for sighted people with no modifications and be unintrusive. I have tried to scope the Talon commands as tight as possible and provide lots of ease to use settings to change the verbosity etc.
In general I have not worked much on Mac support since I don't have a Mac and haven't had anyone test but if you use the repository a bit that would help me implement any features you might want.
Sure, this code:
proc = subprocess.Popen(["say", text])
does not queue the text to speech, or stop the previously playing text to speech, but will just spawn a new process to play the speech. So you can have multiple speakers playing over the top of each other, which is very hard to listen to. Stopping the previous speech is a big improvement.
The say command also has optional arguments that could be used, such as rate and voice. Not sure how much support you want to add for it though.
I have cloned the whole repo. I have not really tried using the Mac's voiceover much yet, mostly just 'echo this' etc.
Just curious do you not have user.echo_dictation = true
? Since it should interrupt and kill the phrase if so. I meant moreso on context for how you are qualitatively using the repo. Since I thought most people wanted both.
I will probably change the tts function to have an interrupt argument, defaulting to true if echo is disabled, which should handle your use case if I am understanding right
I do not currently have echo_dictation true, but I have used it - however I don't think it is relevant here. Why do you think echo matters here?
If I select some text and say "echo this"
echo this:
key(ctrl-c)
sleep(0.1)
user.tts(clip.text())
it just calls tts, which does not interrupt any speech, right? So if I decide to cancel the speech and say echo this again, I feel like I should be able to do that automatically. I guess I could cancel it manually, but it seems like voices playing over each other are just hard to listen to to me.
So TTS only gets interrupted by a voice command if the Echo is currently on. Check the on_phrase callback. https://github.com/C-Loftus/sight-free-talon/blob/0ddbc9ded8f931c760461d885e2346bd5327bc66/core/callbacks.py#L4
Most of my users so far have been screen reader users, so I haven't done much for some of these cases where the user is neither using echo dictation nor a screen reader.
We will need to change the function definition for user.tts to have an interrupt argument. All the behavior to interrupt is already done so this is pretty easy, but I don't really have the vision bandwidth at the moment to refactor each function definition, sorry.
Honestly, it would be just adding an interrupt argument that defaults to false for all the contextual implementations. If you create a pull request, I will merge. Otherwise, I will probably get to this sometime in the coming weeks.
Alternatively you could just add the default cancel with actions.user.cancel_current_speaker()
as you did to always interrupt. That is probably fine for the time being. Not sure if that's a good fit longer term just since there are some cases where we don't want interruptions.
@patrickreece2 I pushed an interrupt update for you and changed the tts function definition.
Now user.tts() interrupts by default regardless. You can pass in a boolean to if you want to call the function without interrupting. I hope this is useful. I was going to implement the text a speech rate as well but I'm not exactly sure how to convert between our -10 to 10 rate and WPM that say
uses. If you have any insight on that feel free to open a separate issue because I can't test that myself.
Echo this does not stop until I quit Talon. It would be good to have a command to stop it.