txt2cw.pl

Convert a text file to audible morse code (CW).

Version 1.0.3

*** For Windows Only. Linux needs some perl/audio work. ***

An application for converting a text file to morse code (WAV or MP3 file). User input determines the text to convert, speed, tone, file length, timing scheme (standard, Farnsworth, or Wordsworth), etc. There are also features for instant word recognition (IWR), and word suffixes.

From a sentence, to an entire book (Project Gutenberg is a good source), choose material of interest and complexity to your liking and practice needs.

You may specify a second text file with a list of words or suffixes to have the application send at a higher speed and/or a different tone. The intent is to develop an instant word recognition (IWR) of these patterns at the intended on-the-air speed, while still practicing instant character recognition (ICR) for the majority of the text.

The application is currently tested for windows 64 bit (others see note at end of page), and Linux. Since the source code is in PERL, your PC must have a version of the PERL language installed. In addition to PERL, one module Audio::Wav; is required, both are available free on-line (more below).

At the bottom of the page there is a display of the help page (run: txt2cw.pl -help) with some additional information about how responses to menu questions impact the application.

Note that IWR words or suffixes which precede punctuation (or are framed by quotes), as in: "word", 'word', word?, word:, etc. will only have the "word or suffix" sent at the alternate speed, not the punctuation - since the word pattern is what we want instant recognition of.

Quick Demonstration Audio Files

These are short phrase examples.

Each sample uses some different features and options (speeds, tone, WAV/MP3) just for variety (all are up to the user).

IWR, suffix, and emphasis features display reports of matched occurrences after the input is read, but prior to creating the audio files. This is a preview of the IWR/suffixes you are interested in practicing on before listening to the code. This way you can see that you will be hearing the iwr/suffixes you are interested in practicing. Words in the IWR or suffix file that have no matches are not shown.

Find occurrences of IWR words from a list file, and send those words at an increased character speed and a different tone (tone difference is optional) than the rest of the file.
IWR example

Similar to the above, this time a short alert tone introduces the IWR word (the word is the same tone as other text).
IWR with alert example

       IWR Word Report
    IWR Word         Occurrences
 ===============     ==========
 FILE                      2
 IWR                       2

 Total of (4) IWR word occurrences found in (15) words read.

Find occurrences of suffixes, from a list file and send those suffixes at an increased character speed (no tone difference).
Suffix example

         Suffix Report
    Suffix           Occurrences
 ===============     ==========
 ING                       3
 LY                        2
 TION                      1

 Total of (6) suffixes occurrences found in (23) words read.

The following example adds tonal emphasis to the double quote character (only one can be chosen; this CAN be used to introduce a new punctuation symbol or Prosign and get a simple alert by its slightly different tone - you MUST listen for tha pattern not just the tone (this is meant as a SHORT term crutch if needed).

Note: this feature will not be given to the user if they have already chosen IWR or Suffixes with a tone change.
Emphasis example

  Emphasized Symbol Report
    Symbol  Occurrences
    ======  ==========
      "         4

The following example shows Wordsworth timing. The entire "word", including its characters and inter-character spacing is sent at the higher character speed; only the intra-word spacing is sent at the slower speed.<
Wordsworth example

The following example shows Farnsworth timing. This example is 15/5wpm. <
Farnsworth example

Zip File For Windows
txt2cw.pl File For Linux

On-line help, for more information.

Below is the display of the "menu" questions in lieu of command line options. A few comments in the form of # comment, have been added.

 Input file name? (./input.txt): tst.txt
    # in addition to the .txt suffix, the file must be a
    # text file, that is characters as typed in an editor like
    # notepad, or vi - NOT a word processor like Microsoft Word.
 Character speed, in wpm? (25):
        Per-file char-speed increment, in wpm? (0.05): 0
        # can be a whole number or decimal
 Farns/words-worth speed, in wpm ( <= 25, 0 = none)? (0):
 Extra dit-widths between words? (0):
 CW tone in hz? (700):
 File length, in minutes? (5):
        # this is an average estimate
 Max number of output files? (8192):
        # The above two together determine the amount of practice
        # material, therefore run time and disk space.
 Optional functions:
        # either of the following can be used for IWR type training
        # will require a second file containing the IWR words or suffixes
        - match IWR words (i)
        - match suffixes (s)
        - Neither (N) ?: i
        IWR word file? (ending in .txt): i.txt
                # file format for IWR or suffixes as follows
                # comments like this line ok
                # completely blank of space lines
                # data lines, may have leading or trailing spaces
                # the word or suffix cannot include spaces
                IWR word speed, in wpm? ( > 25): 30
 A symbol to emphasize, by tone? : "
        # a single character or prosign. sounded by its different tone
        # can use as a TEMPORARY aid in learning a new character
        # You must listen for the pattern, not just the tone!
        Emphasis tone, in Hz, different than CW tone: 700): 750
 Punctuation to ignore? (  []()!;":'_  ):
        # read carefully; options let you accept all, or ignorre all or SOME.
 Sound <X>X> formatted ProSigns? (y/N):
        # If 'y' (default) supports prosigns in the input file, as well as the
        # word or suffix file will be sent as CW. In any other case the all >, and <
        # will be ignored - unsupported prosigns are discarded.
 Silence audible header? (Y/n):
        # info in the form of: file path at XX Char WPM sent in CW
        # if answer is 'N'
 Output as WAV or MP3 files? (wav):
        # windows env, only seen IF a local lame folder exists

 Below is a sample IWR word file:

 # file created for listening to "Call Of The Wild"

 and
 the
 did
 do
 she
 #wolf  ><== commented out instead of erasing
 73
<SK>   ><== not likely found, note all entries can be upper/lower case
 snow

 Below is a sample suffix file:

 # my first few suffixes
 # case doesn't matter, must be at least 2 in length, only alphas
 ing
 tion
 ed
 ly

 Supported Prosigns:

  ITU prosigns:
    <AR> <AS> <BT> <KA> <KN> <SK> <VA> <SOS> <HH> <SN> <VE>
    <VA> & <SK> same sound different look in text
    <SN> & <VE> same sound different look in text
    + or = in input are sent as the prosign, regardless of prosign option.

  Prosign format in some text, but will be sent as 2 letters:
    <BK> <CL>

  Punctuation sometimes in prosign format, sent as the actual
    punctuation:
    <IMI> (question mark ?) <DU> (hyphen or dash -)

  PC Environment:
    It's recommended that you create a new folder (directory) where you
    will run txt2cw.pl. When run, a new sub-folder will be created with the
    name of the input file less the ".txt" extension. Assuming you
    answer "Y" to create the files or "Y" to overwrite it if it
    already exists, the sub-folder
    will be created to hold the WAV or MP3 audio files.

    The directories are named like: 000-127, to mean this holds up to
    the first 128 files.If the input was large, or you asked for
    short files to be created. This makes it easier for you to manually
    remove unwanted files with Windows File Explorer when they are no longer
    of interest.

    It is best to NOT have Windows File Explorer or your media player sitting
    in the target directory, if a subsequent run is done with the same input file.
Below is the display of the menu questions in lieu of command line options. Comments in the form of "# comment", have been added.
 Input file name? (./input.txt): tst.txt
    # in addition to the .txt suffix, the file must be a simple
    # text file, that is characters as typed in an editor like
    # notepad, or vi - NOT a word processor like Microsoft Word.
 Character speed, in wpm? (25):
        Per-file char-speed increment, in wpm? (0.05): 0
        # can be a whole number or decimal
 Farns/words-worth speed, in wpm ( <= 25, 0 = none)? (0):
 Extra dit-widths between words? (0):
 CW tone in hz? (700):
 File length, in minutes? (5):
        # this is an average estimate
 Max number of output files? (8192):
        # The above two together determine the amount of practice
        # material, therefore run time and disk space.
 Optional functions:
        # either of the following can be used for IWR type training
        # will require a second file containing the IWR words or suffixes
        - match IWR words (i)
        - match suffixes (s)
        - Neither (N) ?: i
        IWR word file? (ending in .txt): i.txt
                # file format for IWR or suffixes as follows
                # comments like this line ok
                # completely blank of space lines
                # data lines, may have leading or trailing spaces
                # the word or suffix cannot include spaces
                IWR word speed, in wpm? ( > 25): 30
 A symbol to emphasize, by tone? : "
        # a single character or prosign. sounded by its different tone
        # can use as a TEMPORARY aid in learning a new character
        # You must listen for the pattern, not just the tone!
        Emphasis tone, in Hz, different than CW tone: 700): 750
 Punctuation to ignore? (  []()!;":'_  ):
        # sevral questions to let you ignore or accept all, or SOME
 Sound <XX> formatted ProSigns? (y/N):
        # If 'y' (default) supported prosigns in the input file, as well as the
        # word or suffix file will be sent as CW. In any other case the all >, and <
        # will be ignored - unsupported prosigns are discarded.
 Silence audible header? (Y/n):
        # info in the form of: file path at XX Char WPM sent in CW
        # if answer is 'N'
 Output as WAV or MP3 files? (wav):
        # MP3 only seen IF a local lame folder exists

 Below is a sample IWR word file:

 # file created for listening to "Call Of The Wild"

 and
 the
 did
 do
 she
 #wolf  <== commented out instead of erasing
 73
 <S>>   <== not likely to be found, note all entries can be upper/lower case
 snow

PC Environment

(many notes only apply to Windows). This is a command line application. You should create a new folder (directory) where you will run txt2cw.pl. When run, a new folder will be created with the name of the input file less the ".txt" extension. Assuming you answer "Y" to create the files or "Y" to overwrite it if it already exists, then the input file is copied there and sub folders will be created to hold the WAV or MP3 audio files.

The directories are named like: 000-127, to mean this holds up to the first 128 files (assuming the input was large, or you asked for short files to be created). This makes it easier for you to manually remove unwanted files with Windows Explorer when they are no longer of interest.

It is best to NOT have Windows Explorer or your media player sitting in the target directory, while executing the txt2cw.pl command.

Command Line Execution

There are multiple ways to run command line applications in Windows. Below are some notes that may provide additional help for those not used to cmd line applications.

Open a command window - Press the "windows key", and type "cmd" in the search and hit ENTER.

Does the PC have PERL?

At the prompt, type "perl -version" and ENTER. If you get any message about perl and a version number (it should be at least 5.0) you likely will will still need one optional module, called Audio::Wav (covered below). If you get 'perl' not recognized, it may not be in your PATH environment variable. Use Windows File Explorer and search for "perl.exe" (without quotes). If found, add the directory to your PATH variable (in Settings); if not get one from the internet (I'd recommend Strawberry Perl, its installation is very quick and simple). Once perl is found/installed, move on.

Is the Audio:Wav module installed?

Simple approach is just to try the app.
Type "perl txt2cw.pl" or "perl txt2cw.pl -help". If the module is missing the error message will be clear. Use Google to find the module, instructions will depend on your perl vendor. For Strawberry Perl
  1. Press the Windows Key to list the installed apps
  2. Find the Strawberry Perl Folder, then press the CPAN Client entry
  3. A new window opens, type: install Audio::Wav (enter)
  4. StrawberryPerl is now ready.

If you didn't get an error, then you should be running txt2cw.pl.

Do I have to always have to type "perl" ?

No. If the application works without it, you're done. If it works with perl in the command window but not without it, google "Windows XX How To Associate a File Type", a few steps will link the ".pl" file type or extension to your perl.

Disclaimer

As with the source code which the base was inherited from, no rights are reserved. Feel free to use, share, and extend as you like to continue your morse code journey. Since source code is provided, and the code has been tested only a specific instance of Widows 10, therefore code is given "AS IS" BASIS, WITHOUT ANY WARRANTIES OR CONDITIONS OF ANY KIND, either implied or expressed, including without limitation, and any warranties of TITLE, NON-INFRINGEMENT; MERCHANTABILITY OR FITNESS FOR USE.

Thanks to KY8D - Gan Uesli Starling for making his gus_morse.pl available, which I added IWR/Suffixes/Emphasis/Wordworth, and other personal touches. Please do not complain to Gan about these features. His gus_morse.pl, does other things not mentioned here, and is Linux capable too.

Note: While tested in Windows 64, windows 32 for WAV files should be the same; windows 32 bit and MP3 is unknown. If you try windows 32 and MP3 please email me your findings at [email protected] (SUBJECT txt2cw).

Copyright and Disclaimer
Support QSL.NET click here.