From 5f3b3e9ed20ca2a39e6ceb4de5ababfd50518eb1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 17 May 2022 09:38:50 +1000 Subject: [PATCH] readme: move information on using sox into it's own file Also minor cleanup to ydotool readme. --- nerd-dictation | 16 ++-------------- readme-sox.rst | 40 ++++++++++++++++++++++++++++++++++++++++ readme-ydotool.rst | 30 +++++++++++++++--------------- readme.rst | 22 ++++++---------------- 4 files changed, 63 insertions(+), 45 deletions(-) create mode 100644 readme-sox.rst diff --git a/nerd-dictation b/nerd-dictation index f251eb0..6945244 100755 --- a/nerd-dictation +++ b/nerd-dictation @@ -1313,19 +1313,7 @@ This creates the directory used to store internal data, so other commands such a "- ``PAREC`` (external command, default)\n" " See --pulse-device-name option to use a specific pulse-audio device.\n" "- ``SOX`` (external command)\n" - " Set environment variable AUDIODEV to use a specific input device.\n" - " Other sox options can be set (such as gain) by setting environment variable SOX_OPTS.\n" - " You can test various devices by::\n" - "\n" - " # List audio devices.\n" - " arecord -l || cat /proc/asound/cards || cat /dev/sndstat \n" - "\n" - " # Example, use card 2, subdevice 0.\n" - " # Record 10 seconds and playback to default output.\n" - " AUDIODEV='hw:2,0' \\\n" - " sox -d --buffer 1000 -r 16000 -b 16 -e signed-integer \\\n" - " -c 1 -t wav -L test.wav trim 0 10\n" - " sox test.wav -d\n" + " For help on setting up ydotool, see ``readme-sox.rst`` in the nerd-dictation repository.\n" ), required=False, ) @@ -1357,7 +1345,7 @@ This creates the directory used to store internal data, so other commands such a "\n" "- ``XDOTOOL`` Compatible with the X server only (default).\n" "- ``YDOTOOL`` Compatible with all Linux distributions and Wayland but requires some setup.\n" - " For help on setting up ydotool, see our guide readme-ydotool.rst in the nerd-dictation repository.\n" + " For help on setting up ydotool, see ``readme-ydotool.rst`` in the nerd-dictation repository.\n" ), required=False, ) diff --git a/readme-sox.rst b/readme-sox.rst new file mode 100644 index 0000000..c5972ab --- /dev/null +++ b/readme-sox.rst @@ -0,0 +1,40 @@ +################################# +Using ``sox`` with nerd-dictation +################################# + +This guide explains how to configure ``sox`` for recording audio with ``nerd-dictation``. + + +When should I use ``sox``? +========================== + +You may wish to configure ``sox`` if you are using a system without pulse-audio support (such as FreeBSD). + + +Configuring ``sox`` +=================== + +Set environment variable ``AUDIODEV`` to use a specific input device. +Other sox options can be set (such as gain) by setting environment variable ``SOX_OPTS``. + +You can test various devices by + +.. code-block:: sh + + # List audio devices. + arecord -l || cat /proc/asound/cards || cat /dev/sndstat + + # Example, use card 2, subdevice 0. + # Record 10 seconds and playback to default output. + AUDIODEV='hw:2,0' sox -d --buffer 1000 -r 16000 -b 16 -e signed-integer -c 1 -t wav -L test.wav trim 0 10 + sox test.wav -d + + +Running nerd dictation with ``sox`` +=================================== + +To run ``nerd-dictation`` with ``sox``, use the ``--input`` argument. + +.. code-block:: sh + + nerd-dictation begin --input=SOX diff --git a/readme-ydotool.rst b/readme-ydotool.rst index a17d916..93475c5 100644 --- a/readme-ydotool.rst +++ b/readme-ydotool.rst @@ -1,21 +1,21 @@ -################################# -Using ydotool with nerd-dictation -################################# +##################################### +Using ``ydotool`` with nerd-dictation +##################################### This guide explains how to get and configure ``ydotool`` to simulate typing with ``nerd-dictation``, which brings support for typing on Wayland and languages other than English. -When should I use ydotool -========================= +When should I use ``ydotool``? +============================== By default, ``nerd-dictation`` uses the ``xdotool`` program to simulate writing with the keyboard. This program has two major limitations: -# It is only compatible with Xorg, not with Wayland. - If you want to use Wayland, the program will not type anything. -# It suffers from considerable slowdowns when writing characters not found in the English language, - temporarily freezing your computer's display. +#. It is only compatible with Xorg, not with Wayland. + If you want to use Wayland, the program will not type anything. +#. It suffers from considerable slowdowns when writing characters not found in the English language, + temporarily freezing your computer's display. There is a program named ``ydotool`` that you can use as an alternative to ``xdotool``. ``ydotool`` does not rely on the X server, so it is compatible with Wayland. @@ -25,8 +25,8 @@ It also offers better performance in languages other than English. The flip side is that it requires some system configuration to use conveniently. Also, it lacks accessible documentation, which is why it is not the default. -Installing ydotool -================== +Installing ``ydotool`` +====================== You will need to download the latest version of the program found on its git repository: https://github.com/ReimuNotMoe/ydotool/releases/ @@ -37,8 +37,8 @@ You should then place them in a place that's available on your ``$PATH`` environ **Warning:** While ``ydotool`` is available on the ``apt`` package manager on Ubuntu 22.04 LTS, the Debian package is outdated. -Configuring ydotool -=================== +Configuring ``ydotool`` +======================= To simulate typing, the program needs access to your ``/dev/uinput`` device. By default, this requires root privileges every time you run ``ydotool``, @@ -82,8 +82,8 @@ for performance reasons. You needs to run ``ydotoold`` before you start using `` To avoid running it every time you start the computer, you can add it to your startup programs. The steps depend on your distribution, so we'll let you look this up. -Running nerd dictation with ydotool -=================================== +Running nerd dictation with ``ydotool`` +======================================= To run ``nerd-dictation`` with ``ydotool``, use the ``--simulate-input-tool`` argument. diff --git a/readme.rst b/readme.rst index 55435f0..47ebc7a 100644 --- a/readme.rst +++ b/readme.rst @@ -69,10 +69,12 @@ Dependencies - Python 3. - The VOSK-API. -- ``parec`` command for recording from pulse-audio (default) or ``sox`` command as alternative. +- ``parec`` command for recording from pulse-audio (default) or + ``sox`` command as alternative. + See the guide: `Using sox with nerd-dictation `_. - ``xdotool`` (default, X11 only) or ``ydotool`` command to simulate keyboard input (supports X11 & Wayland). - See the ``ydotool`` setup guide: `Using ydotool with nerd-dictation `_. + See the setup guide: `Using ydotool with nerd-dictation `_. Install @@ -227,19 +229,7 @@ options: - ``PAREC`` (external command, default) See --pulse-device-name option to use a specific pulse-audio device. - ``SOX`` (external command) - Set environment variable AUDIODEV to use a specific input device. - Other sox options can be set (such as gain) by setting environment variable SOX_OPTS. - You can test various devices by:: - - # List audio devices. - arecord -l || cat /proc/asound/cards || cat /dev/sndstat - - # Example, use card 2, subdevice 0. - # Record 10 seconds and playback to default output. - AUDIODEV='hw:2,0' \ - sox -d --buffer 1000 -r 16000 -b 16 -e signed-integer \ - -c 1 -t wav -L test.wav trim 0 10 - sox test.wav -d + For help on setting up ydotool, see ``readme-sox.rst`` in the nerd-dictation repository. --output OUTPUT_METHOD Method used to at put the result of speech to text. @@ -252,7 +242,7 @@ options: - ``XDOTOOL`` Compatible with the X server only (default). - ``YDOTOOL`` Compatible with all Linux distributions and Wayland but requires some setup. - For help on setting up ydotool, see our guide readme-ydotool.rst in the nerd-dictation repository. + For help on setting up ydotool, see ``readme-ydotool.rst`` in the nerd-dictation repository. ``-`` ... End argument parsing. This can be used for user defined arguments which configuration scripts may read from the ``sys.argv``.