ideasman42 / nerd-dictation

Simple, hackable offline speech to text - using the VOSK-API.
GNU General Public License v3.0
1.21k stars 104 forks source link

'write() failed: Broken pipe' error #102

Open Josef-Ouano opened 1 year ago

Josef-Ouano commented 1 year ago

Hello, I am trying to run nerd-dictation on a Wayland machine. But I keep getting this error:

Traceback (most recent call last): File "/home/ubuntu/Documents/test/./nerd-dictation", line 1952, in main() File "/home/ubuntu/Documents/test/./nerd-dictation", line 1948, in main args.func(args) File "/home/ubuntu/Documents/test/./nerd-dictation", line 1813, in func=lambda args: main_begin( File "/home/ubuntu/Documents/test/./nerd-dictation", line 1416, in main_begin found_any = text_from_vosk_pipe( File "/home/ubuntu/Documents/test/./nerd-dictation", line 1207, in text_from_vosk_pipe json_text, json_text_partial_prev = rec_handle_fn_wrapper_from_partial_result(json_text_partial_prev) File "/home/ubuntu/Documents/test/./nerd-dictation", line 1073, in rec_handle_fn_wrapper_from_partial_result handle_fn_wrapper(text, True) File "/home/ubuntu/Documents/test/./nerd-dictation", line 1031, in handle_fn_wrapper handle_fn(len(text_prev) - match, text_curr[match:]) File "/home/ubuntu/Documents/test/./nerd-dictation", line 198, in simulate_typing_with_ydotool run_command_or_exit_on_failure( File "/home/ubuntu/Documents/test/./nerd-dictation", line 50, in run_command_or_exit_on_failure subprocess.check_output(cmd) File "/usr/lib/python3.10/subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.10/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ydotool', 'type', '--next-delay', '5', '--', 'just']' returned non-zero exit status 2. write() failed: Broken pipe

I assume vosk is working properly, but its when it comes to ydotool that the error occurs. The Command I used is the ff: ./nerd-dictation begin --simulate-input-tool=YDOTOOL --vosk-model-dir=./lib/language_models/model_en

I've cloned ydotool from the link: https://github.com/ReimuNotMoe/ydotool

I have no idea why this happens, I've never been able to make it work

salimZenzouni commented 12 months ago

Hello! I've got the same issue on Wayland!

./nerd-dictation begin --simulate-input-tool=YDOTOOL --vosk-model-dir=./model ydotool: notice: ydotoold backend unavailable (may have latency+delay issues) terminate called after throwing an instance of 'std::runtime_error' what(): failed to open uinput device Traceback (most recent call last): File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1974, in main() File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1970, in main args.func(args) File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1835, in func=lambda args: main_begin( File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1437, in main_begin found_any = text_from_vosk_pipe( File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1225, in text_from_vosk_pipe json_text, json_text_partial_prev = rec_handle_fn_wrapper_from_partial_result(json_text_partial_prev) File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1084, in rec_handle_fn_wrapper_from_partial_result handle_fn_wrapper(text, True) File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 1042, in handle_fn_wrapper handle_fn(len(text_prev) - match, text_curr[match:]) File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 199, in simulate_typing_with_ydotool run_command_or_exit_on_failure( File "/home/salim/.config/nerd-dictation/./nerd-dictation", line 50, in run_command_or_exit_on_failure subprocess.check_output(cmd) File "/usr/lib/python3.10/subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.10/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ydotool', 'type', '--next-delay', '5', '--', 'hello']' died with <Signals.SIGABRT: 6>. write() failed: Broken pipe

salimZenzouni commented 12 months ago

I asked chatgpt 4 about the issue and here it's reply:

My Question: act as an linux expert, and give tell me why nerd-dictation doesn't work in wayland ubutnu even if I use it with ydotool?

ChatGPT's answer:

EDIT: REMOVED ChatGPT generated misinformation. ~ideasman42

ideasman42 commented 12 months ago

@sal-zen ChatGPT's answer was obviously wrong with minimal research. ydotool doesn't depend on X11.

salimZenzouni commented 12 months ago

@ideasman42 : Thanks for your clarification. Do you have any general hypothesis on why I got the error? I can further explore them and share what I'll find here to solve the problem. Thank you for your collab.

ideasman42 commented 12 months ago

@sal-zen can you get ydotool to work in the command line? If so, it shouldn't be a problem to run it from nerd-dictation.

In general try to troubleshoot issues with input simulation outside nerd-dication.

salimZenzouni commented 12 months ago

@ideasman42 I was able to spot the error and now it works fine for me. I needed to to do these:

  1. lunch ydotoold before lunching ydotool in a seperate terminal window. To do this run : sudo ydotoold
  2. run nerd-dictation using the command : ./nerd-dictation begin --timeout 5 --simulate-input-tool STDOUT --vosk-model-dir=./model

Now it works fine for me! Thank you @ideasman42 for you reactivity and your willingness to help. I appreciate it :)