Markdown Cheatsheet

As a new user to Markdown I was looking for a cheatseet. For some reason the meaning of cheatsheet has become diluted to mean a bunch of scrolling text that would print out to multiple pages with inconvenient breaks; the first 5 suggestions from Google were such. Fortunately Jeremy Stretch has produce a sane pdf cheatsheet that can be viewed or printed out as a convenient single page desktop reference.

Image of Jeremy Stretch's Markdown Cheatsheet

Jeremy’s blog PacketLife.net has a whole stack of well formatted IT cheat sheets, mostly networking related, but worth a browse including a single page Mediawiki cheatsheet.

Maryspeak a command line wrapper for MaryTTS

This project and the documentation from my blog is now hosted on GitHub the links in the post have been changed accordingly.

What is Maryspeak

I’ve been inspired by Ken Fallon via Hacker Public Radio to write maryspeak; a small java program  to make the core features of Mary Text To Speech  readily accessible as a shell command. The aim of maryspeak is to reduce the friction for Linux shell users to use MaryTTS. It accepts text input via the command line, via a file or via stdin, processes it using MaryTTS, then outputs speech via sound, to a file, or to stdout. It also allows for the selection of a voice and/or a MaryTTS server.

MaryTTS is written in Java and the UI is not transparently accessible to the Linux command line. maryspeak is a wrapper around the MaryInterface classes used by the MaryTTS Java and http clients. Because its written in Java there is no reason this cannot also be on a Windows system, but the command switches are closer to the GNU conventions.

Installing Maryspeak

This installation assumes Debian but the same principles will apply to other distros.

  • Install MaryTTS (see my previous post Marytts Voice Synthesizer How-To for Debian)
  • Download the maryspeak.jar from here or download the source to build it for yourself here
  • Copy the maryspeak.jar file to the MaryTTS library
    $ sudo cp maryspeak.jar /opt/marytts-5.1/lib
  • Create an alias to provide a nice clean usable command. In Debian add the following line to the .bash_aliases file, create the file if it does not already exist.
    alias maryspeak='java -cp "/opt/marytts-5.1/lib/*" -Dmary.base=/opt/marytts-5.1 maryspeak.Maryspeak'
  • Log out of your session and log back in to pick up the new alias, alternately you can source the .bashrc to refresh the session
    $ source ~/.bashrc

Using Maryspeak

You can use maryspeak standalone or against a MaryTTS server.

  • For the simplest demonstration of maryspeak working, it can speak an internal default phrase by using the –default parameter
  • $ maryspeak --default
  • Say what you want by just appending your text to the command. The full stop at the end is required, else for some reason the speech is too slow.
    $ maryspeak This is a short statement from your computer.
  • If you wish to process the speech on a MaryTTS server use the –host=servername parameter. If your server is on the local machine you can just use –host. It is even possible use the MaryTTS demo server with –host=mary.dfki.de
    $ maryspeak --host You will need to run the MaryTTS Server locally to hear this spoken.
  • Show the full Maryspeak usage instructions with -h or –help
    $ maryspeak --help

Further Exploration/Exploitation of MaryTTS

Maryspeak only offers a subset of the functionality of MaryTTS. Maryspeak is also not using the streaming capabilities of the MaryTTS library, so processes things in series: gather input, process the input, then output audio.

MaryTTS has a rich depth of functionality beyond that used by Maryspeak. For serious use I would recommend investigating this.

MaryTTS can be used directly from command line if required via:

$ java -cp "classpath" [properties] marytts.client.http.MaryHttpClient [inputfile]

Assuming MaryTTS is installed as per my previous post, the instructions for usage of this class can be obtained by compiling and running the following java class:

public class ShowUsage {
    public static void main(String[] args) {
    marytts.client.http.MaryHttpClient.usage();
    }
}

For your convenience I have done this, for MaryTTS version 5.1, this is the output:

usage:
 java [properties] marytts.client.http.MaryHttpClient [inputfile]
Properties are: -Dinput.type=INPUTTYPE
                -Doutput.type=OUTPUTTYPE
                -Dlocale=LOCALE
                -Daudio.type=AUDIOTYPE
                -Dvoice.default=male|female|de1|de2|de3|...
                -Dserver.host=HOSTNAME
                -Dserver.port=PORTNUMBER
 where INPUTTYPE is one of TEXT, RAWMARYXML, TOKENS, WORDS, POS,
 PHONEMES, INTONATION, ALLOPHONES, ACOUSTPARAMS or MBROLA,
 OUTPUTTYPE is one of TOKENS, WORDS, POS, PHONEMES,
 INTONATION, ALLOPHONES, ACOUSTPARAMS, MBROLA, or AUDIO,
 LOCALE is the language and/or the country (e.g., de, en_US);
 and AUDIOTYPE is one of AIFF, AU, WAVE, MP3, and Vorbis.
 The default values for input.type and output.type are TEXT and AUDIO,
 respectively; default locale is en_US; the default audio.type is WAVE.
inputfile must be of type input.type.
 If no inputfile is given, the program will read from standard input.
The output is written to standard output, so redirect or pipe as appropriate.

So for a quick demo try putting some text into a file test.txt (use a full stop at the end of your text or Mary speaks slowly for some reason) then run:

$ java -cp "/opt/marytts-5.1/lib/*" marytts.client.http.MaryHttpClient test.txt | aplay

Note: that the output is piped into aplay which can play back a .wav stream. If you don’t have aplay installed you can > output to a file.wav to play later.

Much more can be done using the full MaryTTS libraries within a Java program.

MaryTTS voice synthesizer How to for Debian

Mary Text To Speech logoMaryTTS is an open-source, multilingual Text-to-Speech Synthesis platform written in Java (homepage http://mary.dfki.de/). I’ve taken an interest in it after it was featured on Hacker Public Radio Episode 1599. As a Java program it should run anywhere, however here is how to get it to work on a Debian Linux machine.

Download the MaryTTS runtime package from the link on the download page:
http://mary.dfki.de/download/index.html

$ cd Downloads
$ wget https://github.com/marytts/marytts/releases/download/v5.1/marytts-5.1.zip

Unzip the application to the /usr/bin directory

$ sudo unzip marytts-5.1.zip -d /opt

At this point it will not run unless the you have already installed Java 1.7 you can determine the current version of Java by executing:

$ java -version

Install the required version of Java (also add openjdk-7-jdk if you intend to do any java development):

$ sudo apt-get install openjdk-7-jre

After installing the new java runtime (jre) it will still not be the default. To set the new jre to your default use:

$ sudo update-alternatives --config java

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode

Press enter to keep the current choice[*], or type selection number: 2

Having selected option 2 the java version should return something similar to:

$ java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.1) (7u65-2.5.1-5~deb7u1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

The runtime package delivers the scripts necessary to run the MaryTTS Server, which can be used via a browser of the client to synthesize speech. The server can be launched with:

$ /opt/marytts-5.1/bin/marytts-server.sh

This can then be used either through a browser or via the MaryTTS Client. The browser address will be:

http://localhost:59125

The MaryTTS Client, which is a Java GUI can be launched with:

$ /opt/marytts-5.1/bin/marytts-client.sh

In addition to the server and client components there is the MaryTTS Component Installer, which can be used to install additional voices and apply any available updates to the voices (the server comes with a single us female voice as a default). To launch the installer:

$ /opt/marytts-5.1/bin/marytts-component-installer.sh

Once the installer is running click [Update] to fetch the latests selection of voices. Buttons are then available to install or remove voices.

The Rosie Project by Graeme Simsion

The Curious Incident of the romantic novel as comedy

Don 39 is somewhere on the autistic spectrum is a moderately successful geneticist, and has decided to find himself a wife using the scientific method; what he has not counted upon is Rosie who has her own emotional challenges. She completely derails the ‘wife project’ and his life. Hilarity ensues.

the-rosie-project-graeme-simsion-1

I decided to pick up something different to read for a change (I mostly read science fiction) and stumbled upon this book in a Stamford book shop.

The story moves apace, I couldn’t put the book down and read through its 330 pages in one sitting. On reflection its perhaps just as well as that didn’t give me time to notice the holes in the plot. For instance despite being capable of giving a lecture on Aspergers Syndrome he appears never to have been formally identified as being on the autistic spectrum, even with past professional help and consultations with his close personal friend Claire who is a clinical psychologist. However despite this reservation I recommend suspending your disbelief and reading this book, its not going to change your life but it is a highly enjoyable way to spend an evening. 7/10

Introduction to Linux course now free online

Tux with a mortar boardThe Linux Foundation ‘Introduction to Linux’ course is now available via the edX online training system.

This course is a version of the classroom based course that has been converted to run on the edX system. This is currently the only Linux foundation course on edX, however they do have other IT courses available supplied by other partner institutions.

Introduction to Linux can be found at https://www.edx.org/course/linuxfoundationx/linuxfoundationx-lfs101x-introduction-1621.

This course is ideal for newcomers to Linux and will help fill a few gaps for those who have dabbled a bit but have not been formally trained. It is truly a beginners course though and those with any experience of linux will find themselves skipping through the earlier parts wondering if its worthwhile. However once past the adverts for Linux in the early part it proves to be useful and covers a breadth of topics giving the learner enough for them to take things further.

The course uses example distros from SUSE Centos and Ubuntu. To get the most value from the course I would recommend creating 3 virtual machines to play with as you proceed, since its useful to appreciate the differences between the distros.

You can take the course for free or you can pay for a validated certificate at the end. You also have the option of signing up for a free ‘honour’ certificate where your identity has not been validated by edX but a certificate is issued anyway.

Do you remember floppy disc head cleaners?

5.25″ floppy drive

Actually floppy disc head cleaners have an interesting story. Back in the late 80’s and early 90’s they were a pretty rubbish product, boring, low tech. and low profit. One company evolved this into a top selling minor triumph of technology.

Back when Floppy discs were the main storage game in town and all PCs ran DOS, the heads of floppy disk drives used to get clagged up and then wouldn’t be able to read the data from the disks. In an industrial environment this might be due to oily residue or other grime, but in those less enlightened times, the worst culprit was tobacco smoke residue; which the fans in the computers used to suck in, or blow out, through the slot in the front of the drives. This required regular cleaning to remove the varnish like layer off the drive’s heads.

The original low tech head cleaners were a disk of stiff cloth in a floppy disk jacket onto which you would decant a few drops of cleaning solvent. On inserting the disk you’d get a very brief period of cleaning whilst the drive tried to find the index track of the disc, then an annoying prompt appeared on the screen announcing a disk error as the PC failed to boot from the disc. They were next to useless; very little real cleaning took place and then the operator (often a secretary, as these machines were generally used as word processors) would get a meaningless and often confusing message about a disk error.

So from a user standpoint the original floppy disc cleaners were almost useless, and from a marketing point of view they weren’t great either, once someone bought one the only re-sale opportunity was if they lost the thing.

Telematic Micro Limited were a company specialising in floppy disc test and maintenance systems which would enable the head alignment to be adjusted and set up on early floppy drives. At several hundreds of pounds a pop, I wasn’t likely to be selling a lot of them. However these guys really understood floppy disc drives. When I pointed out to them the opportunity for a better floppy disc head cleaner they came up with HeadMax the intelligent floppy cleaner for PCs.

They created a floppy disc with a mildly abrasive cleaning surface printed onto the inner 40 tracks and a disc cleaning programme on the outer tracks which was derived from their disc test software. This solved the user experience problem; the disc would boot and load a cleaning program which measured the head signal from a test track, it then applied a cleaning cycle repeatedly until the signal from the head was good and the disk heads were clean. Each cleaning cycle used up one of the 40 cleaning tracks and showed a diagnostic display of the drive. This was the ideal floppy cleaner, it had a good user experience with a nice onscreen display of the cleaning progress, it could be sold for a premium price, it counted down its usage and prompted a repurchase when used up, which was great for repeat sales. This product was an amazing success and did great business. Later versions of the product were produced for Windows 95 called DriClean.

Amazingly the Telematic Micro web site is still online preserved from 1998 at telematic.co.uk where you can see the original products, their marketing blurb, and a brief history of the floppy disc.

Installing or updating VirtualBox Client Additions in Crunchbang

If running Crunchbang in VirtualBox, or any other Linux distro, it’s really useful to add the VirtualBox Additions. This provides access to share directories on the host file system, dynamic desktop resizing, clipboard sharing and access to the USB devices on the host.

Initially it was not obvious how to get this to install in Crunchbang. There were a number of things to overcome. The user account does not have sufficient permission to execute the installer on the disk, also by default the required software to compile the linux kernel modules is not there.

So this is what’s I found to be successful:

  • In the VirtualBox window menu, select Devices -> Insert Guest Additions CD image …
  • In CrunchBang open the File Manager, this will for the CD image to automount
  • Close the File Manager and any accompanying notifications
  • Open the terminal and sudo to a root prompt
    $sudo su - root
  • Update the system to ensure that all the installed packages are up to date
    #apt-get update
    #apt-get upgrade
  • Now add the packages required for the Kernel Module compilation
    #apt-get install build-essential module-assistant
  • Then run the VirtualBox Client Additions installation
    #sh /media/cdrom/VBoxLinuxAdditions.run
  • Having installed the Additions exit root (Ctrl-D) and close the terminal Ctrl-D)

To install the inevitable updates, follow the same process but omit the apt-get install command.

Code presentation in WordPress posts

I have edited my recent post on Removing unwanted pastes from Stikked. I used the <code> tags to delineate the command line interactions from the descriptive text. However I wanted the code to appear more like quoted text in a Mediawiki instance. My first  thought was to hack the css to make the code tag work how I wish, however whilst searching for help on that I discovered that the <pre> tag gave exactly the effect I required, whilst the code tag remains useful where you might wish to use a fixed width terminal style text in line with your content.

The other advantage of the 'pre' tag is that it will not force a line wrap if you have a long line of code

The only thing that I still had to do was reduce the font size for these two fixed width fonts as 13px looked a bit chunky along side the normal text.

P.S Having written this I found this comprehensive page on the WordPress site http://codex.wordpress.org/Writing_Code_in_Your_Posts