Uncategorized

Playing with speech synthesis

This afternoon, I was pondering about how I might do text-to-speech, but still have the result sound somewhat natural. For what use case? Well, two that come to mind…

The first being for doing “strapper call” announcements at horse endurance rides. A horse endurance ride is where competitors and their horses traverse a long (sometimes as long as 320km) trail through a wilderness area. Usually these rides (particularly the long ones) are broken up into separate stages or “legs”.

Upon arrival back at base, the competitor has a limited amount of time to get the horse’s vital signs into acceptable ranges before they must present to the vet. If the horse has a too-high temperature, or their horse’s heart rate is too high, they are “vetted out”.

When the competitor reaches the final check-point, ideally you want to let that competitor’s support team know they’re on their way back to base so they can be there to meet the competitor and begin their work with the horse.

Historically, this was done over a PA system, however this isn’t always possible for the people at base to achieve. So having an automated mechanism to do this would be great. In recent times, Brisbane WICEN has been developing a public display that people can see real-time results on, and this also doubles as a strapper-call display.

Getting the information to that display is something of a work-in-progress, but it’s recognised that if you miss the message popping up on the display, there’s no repeat. A better solution would be to “read out” the message. Then you don’t have to be watching the screen, you can go about your business. This could be done over a PA system, or at one location there’s an extensive WiFi network there, so streaming via Icecast is possible.

But how do you get the text into speech?

Enter flite

flite is a minimalist speech synthesizer from the Festival project. Out of the box it includes 3 voices, mostly male American voices. (I think the rms one might be Richard M. Stallman, but I could be wrong on that!) There’s a couple of demos there that can be run direct from the command line.

So, for the sake of argument, let’s try something simple, I’ll use the slt voice (a US female voice) and just get the program to read out what might otherwise be read out during a horse ride event:

$ flite_cmu_us_slt -t 'strapper call for the 160 kilometer event competitor numbers 123 and 234' slt-strapper-nopunctuation-digits.wav
slt-strapper-nopunctuation-digits.ogg

Not bad, but not that great either. Specifically, the speech is probably a little quick. The question is, how do you control this? Turns out there’s a bit of hidden functionality.

There is an option marked -ssml which tells flite to interpret the text as SSML. However, if you try it, you may find it does little to improve matters, I don’t think flite actually implements much of it.

Things are improved if we spell everything out. So if you instead replace the digits with words, you do get a better result:

$ flite_cmu_us_slt -t 'strapper call for the one hundred and sixty kilometer event competitor number one two three and two three four' slt-strapper-nopunctuation-words.wav
slt-strapper-nopunctuation-words.ogg

Definitely better. It could use some pauses. Now, we don’t have very fine-grained control over those pauses, but we can introduce some punctuation to have some control nonetheless.

$ flite_cmu_us_slt -t 'strapper call.  for the one hundred and sixty kilometer event.  competitor number one two three and two three four' slt-strapper-punctuation.wav
slt-strapper-punctuation.ogg

Much better. Of course it still sounds somewhat robotic though. I’m not sure how to adjust the cadence on the whole, but presumably we can just feed the text in piece-wise, render those to individual .wav files, then stitch them together with the pauses we want.

How about other changes though? If you look at flite --help, there is feature options which can control the synthesis. There’s no real documentation on what these do, what I’ve found so far was found by grep-ing through the flite source code. Tip: do a grep for feat_set_, and you’ll see a whole heap.

Controlling pitch

There’s two parameters for the pitch… int_f0_target_mean controls the “centre” frequency of the speech in Hertz, and int_f0_target_stddev controls the deviation. For the slt voice, …mean seems to sit around 160Hz and the deviation is about 20Hz.

So we can say, set the frequency to 90Hz and get a lower tone:

$ flite_cmu_us_slt --setf int_f0_target_mean=90 -t 'strapper call' slt-strapper-mean-90.wav
slt-strapper-mean-90.ogg

… or 200Hz for a higher one:

$ flite_cmu_us_slt --setf int_f0_target_mean=200 -t 'strapper call' slt-strapper-mean-200.wav
slt-strapper-mean-200.ogg

… or we can change the variance:

$ flite_cmu_us_slt --setf int_f0_target_stddev=0.0 -t 'strapper call' slt-strapper-stddev-0.wav
$ flite_cmu_us_slt --setf int_f0_target_stddev=70.0 -t 'strapper call' slt-strapper-stddev-70.wav
slt-strapper-stddev-0.ogg
slt-strapper-stddev-70.ogg

We can’t change these values during a block of speech, but presumably we can cut up the text we want to render, render each piece at the frequency/variance we want, then stitch those together.

Controlling rate

So I mentioned we can control the rate, somewhat coarsely using usual punctuation devices. We can also change the rate overall by setting duration_stretch. This basically is a control of how “long” we want to stretch out the pronunciation of words.

$ flite_cmu_us_slt --setf duration_stretch=0.5 -t 'strapper call' slt-strapper-stretch-05.wav
$ flite_cmu_us_slt --setf duration_stretch=0.7 -t 'strapper call' slt-strapper-stretch-07.wav
$ flite_cmu_us_slt --setf duration_stretch=1.0 -t 'strapper call' slt-strapper-stretch-10.wav
$ flite_cmu_us_slt --setf duration_stretch=1.3 -t 'strapper call' slt-strapper-stretch-13.wav
$ flite_cmu_us_slt --setf duration_stretch=2.0 -t 'strapper call' slt-strapper-stretch-20.wav
slt-strapper-stretch-05.ogg
slt-strapper-stretch-07.ogg
slt-strapper-stretch-10.ogg
slt-strapper-stretch-13.ogg
slt-strapper-stretch-20.ogg

Putting it together

So it looks as if all the pieces are there, we just need to stitch them together.

RC=0 stuartl@rikishi /tmp $ flite_cmu_us_slt --setf duration_stretch=1.2 --setf int_f0_target_stddev=50.0 --setf int_f0_target_mean=180.0 -t 'strapper call' slt-strapper-call.wav
RC=0 stuartl@rikishi /tmp $ flite_cmu_us_slt --setf duration_stretch=1.1 --setf int_f0_target_stddev=30.0 --setf int_f0_target_mean=180.0 -t 'for the, one hundred, and sixty kilometer event' slt-160km-event.wav
RC=0 stuartl@rikishi /tmp $ flite_cmu_us_slt --setf duration_stretch=1.4 --setf int_f0_target_stddev=40.0 --setf int_f0_target_mean=180.0 -t 'competitors, one two three, and, two three four' slt-competitors.wav
Above files stitched together in Audacity

Here, I manually imported all three files into Audacity, arranged them, then exported the result, but there’s no reason why the same could not be achieved by a program, I’m just inserting pauses after all.

There are tools for manipulating RIFF waveform files in most languages, and generating silence is not rocket science. The voice itself could be fine-tuned, but that’s simply a matter of tweaking settings. Generating the text is basically a look-up table feeding into snprintf (or its equivalent in your programming language of choice).

It’d be nice to implement a wrapper around flite that took the full SSML or JSML text and rendered it out as speech, but this gets pretty close without writing much code at all. Definitely worth continuing with.

Corona Baby

I’ve had this stuck in my head all day…one sorta has to pronounce “Corona” as “Crona” to make this work… Apologies to John Carter and The First Class…

Do you remember back in olden day, (wo-oh-oh)
when everybody lived a care-free way (wo-oh-oh)
whatever happened to the boy next door,
now sneezing, hiding behind the bathroom wall!

Remember dancing at the high school hop
The dress I ruined with the soda pop?
Quarantine didn’t mean a thing
Hundreds of people getting in the swing!

Corona baby, Corona baby, give me your hand
let me share what I can remember
Life as before we all got caught
in the lock-down.
Corona baby, Corona baby, you can’t understand
why society was so quick to dismember.
Days in the sun, to lyin’ on our bum every day!

VK4MSL/BM Mk3: 18 months later

Well, it’s been a year and a half since I last posted details about the bicycle mobile station.  Shortly after getting the Talon on the road, setting it up with the top box and lighting, and having gotten the bugs worked out of that set-up, I decided to get a second mounting plate and set my daily commuter up the same way, doing away with the flimsy rear basket in place of a mounting plate for the top box.

VK4MSL/BM today after the trip home from work.

VK4MSL/BM today after the trip home from work.

That particular bike people might recognise from earlier posts, it’s my first real serious commuter bike. Now in her 5th year, has done over 10200km since 2012.  (The Talon has done 5643km in that time.) You can add to that probably another 5000km or so done between 2010 and 2012. It’s had a new rear wheel (a custom one, after having a spate of spoke breakages) and the drive chain has been upgraded to 9-speed. The latter upgrade alone gave it a new lease on life.

Both upgrades being money well spent, as was the upgrade to hydraulic brakes early in the bike’s lifetime. I suppose I’ve spent in those upgrades alone close to $1400, but worth it as it has given me quite good service so far.

As for my time with the top box. Some look at it and quiz me about how much weight it adds. The box itself isn’t that heavy, it just looks it. I can carry a fair bit of luggage, and at present, with my gear and tools in it it weighs 12kg. Heavy, but not too heavy for me to manage.

Initially when I first got it, it was great, but then as things flexed over time, I found I was intermittently getting problems with the top box coming off.  This cost me one HF antenna and today, the top box sports a number of battle-scars as a result.

The fix to this?  Pick a spot inside the top box that’s clear of the pannier rack rails and the rear tyre, and drill a 5mm hole through.  Then, when you mount the top box, insert an M5 bolt through the mounting plate and into the bottom of the top box and tighten with a 5mm wing nut.  The box now will not come loose.

vk4msl-bm-2713

Still lit up like a Christmas tree from this morning’s ride.

The lights still work, and now there’s a small rear-view camera.  On the TODO list is to rig up a 5V USB socket to power that camera with so that it isn’t draining the rather small internal battery (good for 4 hours apparently).

The station has had an upgrade, I bought a new LDG Z-100Plus automatic tuner which I’m yet to fully try out.  This replaces the aging Yaesu FC-700 manual tuner which, although very good, is fiddly to use in a mobile set-up and doesn’t tune 6m easily.

One on-going problem now not so much on the Boulder but on the Talon is an issue with pannier racks failing.  This started happening when I bought the pannier bags, essentially on the side I carry my battery pack (2kg), I repeatedly get the pannier rack failing.  The racks I use are made by Topeak and have a built-in spacer to accomodate disc brake calipers.  This seems to be a weak spot, I’ve now had two racks fail at about the same point.

Interestingly on the Boulder which also has disc brakes, I use the standard version of the same rack, and do not get the same failures.  Both are supposedly rated to 25kg, and my total load would be under 16kg. Something is amiss.

A recurring flaw with the Topeak racks

I’m on the look-out for a more rugged rack that will tolerate this kind of usage, although having seen this, I am inspired to try a DIY solution.  Then if a part fails, I can probably get replacement parts in any typical hardware store.  A hack saw and small drill are not heavy items to carry, and I can therefore get myself out of trouble if problems arise.

Shunting reminders and files with UUCP

Unix-to-Unix Copy is a rather old way of sending files between Unix systems.  Before SMTP was invented, it was the de-facto way to shunt email around, and prior to NNTP, was also the backbone of Usenet.

Fast forward to today, we’ve got a lot of options open to us.  So why would I use a crusty old one like UUCP?

UUCP has one big advantage, it doesn’t assume your system is always online.

  • It might be a workstation at your workplace which is behind a corporate firewall.
  • It might be a more powerful desktop computer at home that’s usually in “sleep” mode to save power.

Because the initial connection can be established in either direction, it is ideal for a system that may not be directly reachable, but is able to poll on a regular schedule for instructions.  It’s also useful, since UUCP assumes some steps need to be taken to bring a link up, to perform tasks such as powering on a system using IPMI or Wake-on-LAN, wait for it to come up, perform a task, then have the machine power back down when finished.

UUCP over the Internet

Now, UUCP can and does work directly over the Internet.  in.uucpd runs from inetd, and basically fires up uucico each time someone connects to it. But: it is unencrypted and insecure. It’s not what you want exposed on today’s public Internet.

UUCP does support SSL, and there are ways to make stunnel work with packages like Taylor UUCP. This still requires some significant setup and an additional open port.

There’s another way. Thanks to the OpenBSD community, we have OpenSSH, and it is very trivial to set up a secure UUCP link using public key authentication, to lock down the public key to only be used with uucico, and to effectively secure communications between your hosts.

Generating the SSH key

Since this is going to be used with an automated service, one needs to make it a passwordless key. Go for something secure in terms of the key length and algorithm: I used 4096-bit RSA. To do this, log in as root then:

# su uucp -
$ ssh-keygen -t rsa -b 4096 -N '' -C 'UUCP key'
Generating public/private rsa key pair.
Enter file in which to save the key (/var/spool/uucp/.ssh/id_rsa): 
Your identification has been saved in /var/spool/uucp/.ssh/id_rsa.
Your public key has been saved in /var/spool/uucp/.ssh/id_rsa.
The key fingerprint is:
c3:42:5d:77:a9:c2:3a:da:bd:98:6a:5d:03:62:79:19 UUCP key
The key's randomart image is:
+--[ RSA 4096]----+
|          . . .. |
|       .E. . ..  |
|      ...+   .   |
|     .+.+ o .    |
|     ..oSo .     |
|       .o.o      |
|       + + .     |
|      o oo.      |
|     ...o ..     |
+-----------------+
$

You have a choice. You can either: make a keypair for each host, and set up authorized_keys so the hosts can log into eachother, or you can use the same keypair for all hosts. I went the latter route, as I’m not that paranoid. Whilst still logged in as the UUCP user:

$ echo 'command="/usr/sbin/uucico -l" '$(< .ssh/id_rsa.pub ) > .ssh/authorized_keys

Now, securely transfer the UUCP user’s .ssh directory between your hosts. This will allow uucp to log in.

Populating known_hosts

The easiest way to do this, is to log into each host as the UUCP user, then run a script like this:

$ for h in host1 host2 host3 ; do ssh $host true; done

Check each key carefully, answer yes if you’re satisfied.

UUCP Log-in script

Taylor UUCP, has the ability to define a “port” that runs an arbitrary application. You could put a call to SSH here, but there’s another trick I use. As root:

# cat < /usr/local/bin/uussh
#!/bin/sh
echo -n 'Address: '
read user host wake

if [ -n "${wake}" ]; then
        timeout=60
        until ping6 -c 1 -w 1 -n "${host}" 2>&1 >/dev/null \
                        || ping -c 1 -w 1 -n "${host}" 2>&1 >/dev/null \
                        || [ $timeout -le 0 ]; do
                timeout=$(( ${timeout} - 1 ))
                /usr/bin/wol ${wake} 2>&1 > /dev/null
        done
fi

exec /usr/bin/ssh -x -o StrictHostKeyChecking=no -o batchmode=yes ${user}@${host}
EOF
# chmod 755 /usr/local/bin/uussh

Now we can define one “SSH” port, that will automatically wake a computer if needed, wait for it to become alive, then initiate the SSH link. The chat script will specify the host name.

Taylor UUCP configuration

Now we come to UUCP itself. First, let’s create this special port. Edit /etc/uucp/port and add the following:

port ssh
type pipe
command /usr/local/bin/uussh

Now, we’ll set up login usernames and passwords for each host. The easiest way is to do this from a local shell, then distribute the generated passwords.

$ for src in host1 host2 host3 host4; do
   [ -d $src ] || mkdir $src
   for dest in host1 host2 host3 host4; do
      [ -d $dest ] || mkdir $dest
      if [ $src != $dest ]; then
         passwd=$( dd if=/dev/urandom bs=12 count=1 2>/dev/null | base64 )
         echo "$dest $src $passwd" >> $src/call
         echo "$src $passwd" >> $dest/passwd
      fi
   done
done
$ for h in host1 host2 host3 host4; do scp $h/* root@$h:/etc/uucp/; done

Now we have separate usernames and passwords on each host. We can finish up with the /etc/uucp/sys file:

commands rmail rnews gruntreceive-uucp
chat-timeout 120

These are some initial instructions that apply to all hosts. Here, I give permission to run rnews, rmail and gruntreceive-uucp, and I tell it to wait 2 minutes before giving up.

The following is an example of a host that sleeps and needs to be woken first:

system host1
chat Address: uucp\shost1.local\saa:bb:cc:dd:ee:ff\n\c login: \L Password: \P
port ssh
time any
call-login *
call-password *
protocol t
forward-from ANY
forward-to ANY

The following, is an always-on host.

system host2
chat Address: uucp\shost2.some.domain\n\c login: \L Password: \P
port ssh
time any
call-login *
call-password *
protocol t
forward-from ANY
forward-to ANY

Phoning home and scheduling retries

In the case of satellite systems behind some resticted network, assuming you have a way of tunnelling out of the network, you can “phone home” on a regular basis. You also want to periodically call uucico on all hosts to check if there’s any scheduled work on. This is done via /etc/crontab:

* * * * * uucp /usr/sbin/uucico -r1 -q
0 * * * * uucp /usr/sbin/uucico -r1 -s main_hub -c

The first line is a good idea on all hosts. It checks each minute for work to do, and calls uucico to do it.

The second line is the phone-home bit. In this case, it phones home to a system called main_hub, which in my case, is my public web server. You’ll want this second line on your satellite systems. It basically unconditionally phones home, and checks for instructions.

Great, UUCP works, what now?

Well, now you have a way of sending files between hosts. Two services that run well over UUCP worth investigating:

  • grunt: is a tool for securely running commands on another host. It can work over email or UUCP and uses GnuPG signature verification for authentication.
  • Many MTAs support UUCP as a back-end, such as Postfix. Very handy for sending reminders to yourself in a manner that is guaranteed to be noticed and not get buried in spam.

User interfaces

Well, it seems user interfaces are going around in circles again. Just recently, I’ve been meeting up with the Windows 8.1 style UI. One of my colleagues at work uses this as his main OS, we also have a VM image of Windows Server 2012 R2 (a 180-day evaluation).  One thing I will say, it’s a marginal improvement on Windows 8.  But is it all that new?

win2012r2

Now, the start screen is one of the most divisive aspects of the Windows 8 UI.  Some love it, some hate it.  Me?  Well the first incarnation of it was an utter pigsty, with no categorisation or organisation.  That has improved somewhat now that you can organise tiles into groups.

But hang on, where have I seen that before?

winnt31-1

That looks… familiar… Let me scroll over to the right a bit…

winnt31-2Ohh, how rude of me!  Allow me to introduce you to an old acquaintance…

winnt31-3This, is Windows NT 3.1.  What one might call the first real ancestor of Windows 8.1.  Everything that came before was built on DOS, Windows 8.1 basically calls itself Windows NT 6.3 beneath the UI.  This is the great-great-great-great-great-great-great-great-grandparent of today’s Windows desktop OS.  Yeah, it’s been that many releases: 8.0, 7, Vista, XP, 2000, NT 4, NT 3.51 and NT 3.5 all sit in between.

Now the question comes up, how is it different?  Sure there are similarities, and I will admit I exaggerated these to make a point.  The Program Manager normally looks more like this:

winnt31-4The first thing you’ll notice that the Program manager (the closest you’ll get to the “start screen”) doesn’t normally occupy the full screen, although you can if you ask it to.  In fact, it will share the screen with other things you might have open:

winnt31-5This is good for both novice and power user alike.  The power user is likely wanting to launch some other application and will be thinking about the job at hand.  The novice might have instructions open that they’re trying to follow.  In neither case, do you want to interrupt them with an in-your-face full screen launcher; a desktop computer is not a smartphone.

The shortcoming of the original Program Manager interface in terms of usability was that you were limited to two levels of hierarchy, with the top-level containing only program groups, and the lower level containing only program icons.  The other shortcoming was in switching applications, you either had to know the ALT+TAB shortcut or minimise/restore full-screen applications so you could see the other applications or their icons.  There was no status area either.

Windows 95 improved things in that regard, the start menu could show arbitrary levels and the taskbar provided both a status area and a screen region dedicated to window selection.  As the installer put it, changing applications was “as easy as changing channels on TV”.  (Or words to that effect.  I’ve ran the Windows 95 installer enough times to memorise two OEM keys off-by-heart but not well enough to remember every message word-for-word.)  Windows NT 4.0 inherited this same interface.

This remained largely unchanged until Windows XP, which did re-arrange some aspects of the Start menu.  Windows 2000/ME made some retrograde changes with respect to network browsing (that is, “My Network Places” vs “Network Neighborhood”[sic]) but the general desktop layout was the same.  Windows Vista was the last version to offer the old “classic” menu with it disappearing altogether in Windows 7.  The Vista/7 start menu, rather than opening out across the desktop as you navigated, confined itself to a small corner of the screen.  Windows 8 is the other extreme.

Windows 8, the start screen takes over.  There’s no restore button on this “window”, it’s all or nothing.  Now, before people point me out to be some kind of Microsoft-hater (okay, I do endulge in a bit of Microsoft-bashing, but they ask for it sometimes!) I’d like to point out there are some good points.

The Start screen isn’t a bad initial start point when you first log in, or if you’ve just closed the last application and wish to go someplace else.  It’s a good dashboard, with the ability to display status information.  It’s also good for touch use as the UI elements are well suited to manipulation by even the most chubbiest of digits.

What it is not, is a good launcher whilst you’re in the middle of things.  A more traditional Start menu with an item to open the Start Screen would be better here.  It also does a very poor job of organising applications: something Windows has never been good at.

So I guess you’ve all worked it out by now that I’m no fan of the Windows UIs in general, and this is especially true of Windows 8.1/2012 R2.  Not many UIs have a lower approval rating in my opinion.  The question now of course, is “how would I do things different”?  All very well to have an opinion about what I don’t like, and so far the IT industry has pushed back on Microsoft and said: “We don’t like this”.  The question is, how do they improve.

Contrary to what some might think, my answer is not to roll the UI back to what came in Windows 7.  The following are some mock-ups of some ideas I have decided to share.

Meet a desktop that for now we’ll call the “Skin The Cat” desktop.  The idea is a desktop that provides more than one way to perform typical actions to suit different usage scenarios.  A desktop that follows the mantra… “there’s more than one way to skin a cat”.  (And who hasn’t wanted to go skin one at some point!)  No code has been written, the screenshots here are entirely synthetic, using The Gimp to draw what doesn’t exist.

mockup-desktopSo here, we see the STC desktop, with two text editors going and a web browser (it’s a quiet day for me).  I’ve shown this on a 640×480 screen just for the sake of reducing the amount of pixel art, but this would represent a typical wide-screen form-factor display.

You’ll notice a few things:

  • Rather than having the “task bar” down the bottom, I’ve put it up the left side.
  • The launch bar (as I’ll call it) has two columns, one shows current applications, the other shows that application’s windows.
  • Over on the right, we have our status area, here depicting volume control, WiFi, battery and mail icons, and a clock down the bottom.
  • Bottom left is a virtual desktop pager.  (MacOS X users would call these spaces.)

Why would I break Microsoft tradition and use this sort of layout?  My usual preference is to have the launch bar up the top of the screen rather than down the side, as that’s where your application menus are.  However, monitors are, for better or worse, getting wider rather than taller.  So while there’s plenty of space width-wise, stacking bars horizontally leads to one being forced to peer at their work through the proverbial letter-box slot.  This leaves the full height for the application.

I group the windows by the application that created them.  All windows have a border and title bar, with buttons for maximizing, iconifying (minimising, for you Windows folk) and closing, as well as a window options menu button, which also displays the application’s icon.

So how does this fit the “skin the cat” mantra?  Well the proposal is to support multiple input methods, and to be able to switch between them on the fly.  Thus, icons should be big enough you can get your thumb onto them with reasonable accuracy, most common window operations should be accompanied by keyboard actions, and the controls for a window should be reasonably apparent without needing special guidance.  More importantly, the window management should stay out of the way until the user explicitly requests its attention by means of:

  • clicking on any title bar buttons or panel icons with the mouse
  • tapping on the title bar of a window or on panel icons with one’s finger
  • pressing an assigned key on the keyboard

Tapping on the title bar (which is big enough to get one’s finger on) would enable other gestures momentarily to allow easier manipulation with one’s fingers.  The title bar and borders would be enlarged, and the window manager would respond to flick (close), pinch (restore/iconify or maximise) and slide (move) gestures.

Tapping the assigned keyboard key or keystroke (probably the logo/”Windows”/command key, inference being you wish to do give the window manager a command) would bring up a pop-up menu with common window operations, as well as an option for the launch menu.

Now this is good and well, but how about the launcher?  That was one of my gripes with Windows for many years after all… Well let’s have a look at the launch menu.

mockup-launcherSo here we’ve got a user that uses a few applications a lot.  The launcher provides three views, and the icons are suggestive about what will happen.  What we see is the un-grouped view, which is analogous to the tiles in Windows 8, with the exception that these are just program launchers, no state is indicated here.

The other two views are the category view, and the full-screen view.  These are identical except that the latter occupies the full screen like the present start screen in Windows 8 does.  Optionally the category view (when not full screen) could grow horizontally as the tree is traversed.  Here, we see the full-screen version.  Over on the right is the same list of frequent applications shown earlier.  As you navigate, this would display the program items belonging to that category.

mockup-launcher-fullscrn

Here, we choose the Internet category.  There aren’t any program icons here, but the group does have a few sub-groups.  The “Internet” category name is displayed vertically to indicate where we are.mockup-launcher-fullscrn-inetLooking under Web Browsers, we see this group has no sub-groups, but it does have two program icons belonging to it.  The sub-group, “Web Browsers” is displayed vertically.  Tapping/clicking “Internet” would bring us back up to that level.mockup-launcher-fullscrn-inet-web

In doing this, we avoid a wall of icons, as is so common these days on Android and iOS.  The Back and Home links go up one level, and up to the top respectively.

The launcher would remember what state it was last in for next time you call it up.  So if you might organise specialised groups for given tasks, and have in them the applications you need for that task.  It’d remember you opening that group last time so you’d be able to recall applications as needed.

Window management is another key feature that needs to be addressed.  The traditional GUI desktop has been a cascading one, where dialogue boxes and windows are draw overlapping one another.  Windows 8 was a throw-back to Windows 2.1 in some ways in that the “Modern” (god I hate that name) interface is fundamentally a tiling one.

There are times when this mode of display is the most appropriate, and indeed, I use tiling a lot.  I did try Awesome, an automatic tiling window manager for a while, but found the forced style didn’t suit me.  A user should be able to define divisions on a given desktop and have windows tiled within them.  The model would be similar to how spreadsheet cells are resized and optionally merged.  A user might initiate tiled mode by defining the initial number of rows and columns (which can be added or subtracted from later).  They then can “snap” individual windows to groups of cells, resizing the divisions as required.  Resizing and moving a window would then move in units of one “cell”.

At the request of the user, individual windows can then be “floated” from the cellular layout allowing them to be cascaded.  Multiple windows may also occupy a cell group, with the title bar becoming “tabbed’ (much like in FluxBox) to allow selection of the windows within that cell group.

I haven’t got any code for the above, this is just some ideas I’ve been thinking about for a while, particularly this afternoon.  If I get motivated, we may see a “skin the cat desktop” project come into existence.  For now though, I’ll continue to do battle with what I use now.  If someone (commercial or open-source motivated) wants to try and tackle the above, you’re welcome to.  However, the fact the ideas are documented here means there is prior art (in fact, there is prior art in some of the above), and I’d appreciate a little attribution.

Re: Standardization: How did things go so wrong with clothes?

Patrick Lauer posted a rather lengthy article regarding the issues of clothing sizing.

In essence, it’s his struggle, having known what his sizes were earlier suddenly discovering that the new clothing he buys, with the same size as his existing clothing, does not fit, despite his old clothes fitting just fine. Presumably his old clothes didn’t have a problem, therefore the summation is that the sizing standards have changed.

AMEN TO THAT!

You’ve just hit upon the #1 reason I despise shopping for clothes online or through any sort of “proxy” (i.e. getting someone else to buy you some). You just never know from looking at a size label whether it’ll “fit”. Doesn’t matter what the clothing is: shoes, trousers, shirts, jackets, gloves, hats, helmets … you’ve got to physically go there and try it on if you want to be sure.

Workwear tends to be more consistent, particularly items that companies sell less of. If I buy a pair of overalls, they tend to be consistent. High-vis polo shirts, usually not a problem. But casual stuff? All over the shop!

Add to this, I absolutely despise branded clothing. I’ll even go as far as to remove branding from clothing I buy if possible. One cap I bought had a small metallic logo sewn to it — that disappeared within 5 minutes. Another, had their logo embroidered on the back. Once again, I found myself picking at it to remove it. Both made in China I might add, and neither particularly cheap.

What do I look for? Plain, unbranded. Some might say “boring”. If it’s a shirt, I’ll tend to want something long sleeved, maybe hooded too in some cases: good for when I’m outside since being of fair complexion, a bit of sun exposure and I turn into Caucasian lobster very quickly. (White supremacy my arse!) Hats, I’m fussy: I tend to like styles that are rare, my last two purchases were a gatsby and a spitfire, I also have a stack of coolies.

I’m not fussy where it’s made, although if I see something made in this country, I’ll tend to jump on it. Sure, more expensive, but I’m all too conscious of the ridiculous mark-ups that get put on kit made in Pakistan, and I don’t fancy lining the pockets of people running shoddy factories.

I particularly object to mark-ups when the product is poorly sized, inferior quality, heavily branded and overpriced. Some of the “cheapest” (quality-wise) clothing I’ve seen, comes from “brand” name suppliers, is designed to last until it “goes out of fashion” (3 months) and is approaching triple-figures. I don’t fancy being a walking billboard, especially when I have to pay for the privilege and the product will be in the bin by that time next year.

I have a couple of polo shirts I recall paying quite decent money for. About $60 a piece if I recall. Both have developed tears around the wrist on the sleeves. From another shop I recall buying some hooded polo shirts. They had a logo sewn on to one sleeve (soon gotten rid of). Similar price. I bought three: a white one, a black one and a grey one. The grey one promptly shrank in the wash, it was fine in the shop but now no longer fits me, I’ve only worn it once. The black one developed some strange brownish markings on it.

So I’ve spent effectively $180 for a single shirt, as the other two are no longer in good condition. Made in China. Bugger that!

No, here’s what I’m after: plain, unbranded, will last weekly wear for a period of a few years, and a size label that’s accurate if I’m to purchase online.

Plus, I hate doing this online. I refuse to own a credit/debit card: my bank account is the old-fashioned passbook type because it forces me to be organised with my expenditure. I can only withdraw or transfer money during a bank’s opening hours, demonstrating either knowledge of the account number or holding the passbook, and supplying a signature in front of the cashier. That’s triple-factor authentication: nothing electronic comes close.

This restricts my payment methods somewhat. B-Pay and direct deposit are doable, as is telegraphic wire transfer. PayPal won’t work however, because with no credit card, there’s no ability for them to draw money out of the account. And I don’t trust them either.

I might yet give Bitcoin a try, since this is the sort of transfer that it’s intended for. They’re not meant to be hoarded, they’re meant to be passed around. Seems a good way to just buy just the quantity I need (paying by bank deposit or B-pay), then purchasing the goods I require. Maybe that’ll open up a few more sources.

However, I still then have to wait for a package to arrive. I like the immediacy of just strolling into a shop, seeing something I like, doing a quick check to see if it’ll fit, then walking to the counter, handing some cash over, and walking out with the newly purchased item. No ordering, no payment hassles, no courier, no guesswork on sizing and no post sales spam.

Admittedly, shops are no fun either, I actually dislike going into a shop to buy clothing. Especially since some insist on ghastly music, and have a guard standing at the door insisting on checking your bags, even if you merely take two steps in, look around (in their plain sight), decide you can’t stand the noise and (try to) walk out.

Is it any wonder I tend to frequent charity shops?

OpenERP function fields, and the store= parameter

This is another one of those brain-RAM-to-blog-NVRAM dumps for my own future reference as much as anyone else’s benefit.  One thing I could never quite get my head around was the store= parameter in OpenERP.

OpenERP explains it like this:

store Parameter

It will calculate the field and store the result in the table. The field will be recalculated when certain fields are changed on other objects. It uses the following syntax:

store = {
    'object_name': (
            function_name,
            ['field_name1', 'field_name2'],
            priority)
}

It will call function function_name when any changes are written to fields in the list [‘field1’,’field2’] on object ‘object_name’. The function should have the following signature:

def function_name(self, cr, uid, ids, context=None):

Where ids will be the ids of records in the other object’s table that have changed values in the watched fields. The function should return a list of ids of records in its own table that should have the field recalculated. That list will be sent as a parameter for the main function of the field.

Now note the parameter self. Quite often, these are defined as methods of the object that owns the given function field. self, in the Python vernacular, is similar to the this keyword in C++; it is a reference to the object that owns the method. And here, the use of the name self is misleading.

I had occasion to derive a few timesheet objects so that I could rename a few fields. I didn’t want to change the implementation, just the name. And I wanted to do it in one place, not go do a search and replace on each and every view for the timesheet. The model seemed the most appropriate place for it. Unfortunately, the only way you change a field name in this way, is to copy and paste the definition.

So I tried adding this to my derived model (note, we were able to leave _progress_rate alone, since I had in fact overridden that method in this same object to fix a bug in the original, otherwise I’d use the same lambda trick here):

        'planned_hours': fields.function(
            _progress_rate,
            multi="progress", string='Total Planned Time',
            help=   "Sum of hours planned by the project manager for all "  \
                    "tasks related to this project and its child projects",
            store = {
                'project.project': (
                    lambda self, cr, uid, ids, context=None :               \
                        self._get_project_and_parents(                      \
                            cr, uid, ids, context),
                    ['tasks', 'parent_id', 'child_ids'], 10),
                'project.task': (
                    lambda self, cr, uid, ids, context=None :               \
                        self._get_projects_from_tasks(                      \
                            cr, uid, ids, context),
                    ['planned_hours', 'remaining_hours',
                    'work_ids', 'state'], 20),
            }),

The lambda functions are just a quick way of picking up the functions that would later be inherited by the base class (handled by the osv.osv object).

Imagine my surprise when I get told that there is no attribute called _get_projects_from_tasks. … Hang on, I’m sure that’s what it’s called! I check again, yes, I spelt it correctly. I look closer at the backtrace:

AttributeError: 'project.task' object has no attribute '_get_projects_from_tasks'

I’ve underlined the significant bit I had missed earlier. Despite the fact that this _get_project_from_tasks is in fact, defined as a method in project.project, the argument that’s passed in as self is not a project.project instance, but a project.task.

self is not in fact, self, but another object entirely.

So from now on, I shall no longer call this parameter self, as this will trip regular Python programmers up — it should be called what it is. My field definition now looks like this:

        'planned_hours': fields.function(
            _progress_rate,
            multi="progress", string='Total Planned Time',
            help=   "Sum of hours planned by the project manager for all "  \
                    "tasks related to this project and its child projects",
            store={
                'project.project': (
                    lambda project_obj, cr, uid, ids, context=None: \
                        project_obj._get_project_and_parents(cr, uid, ids, context),
                    ['tasks', 'parent_id', 'child_ids'],
                    10
                ),
                'project.task': (
                    lambda task_obj, cr, uid, ids, context=None:    \
                        task_obj.pool.get('project.project'         \
                            )._get_projects_from_tasks(cr, uid,     \
                                ids, context),
                    ['planned_hours', 'remaining_hours', 'work_ids', 'state'],
                    20
                ),
            }),

Hopefully that should be clear next time I, or anyone else, comes across it.

DIY Project: Gatsby cap

Those who have met me, might notice I have a somewhat unusual taste in clothing. One thing I despise is having clothes that are heavily branded, especially when the local shops then charge top dollar for them.

Where hats are concerned, I’m fussy. I don’t like the boring old varieties that abound $2 shops everywhere. I prefer something unique.

The mugshot of me with my Vietnamese coolie hat is probably the one most people on the web know me by. I was all set to try and make one, and I had an idea how I might achieve it, bought some materials I thought might work, but then I happened to be walking down Brunswick Street in Brisbane’s Fortitude Valley and saw a shop selling them for $5 each.

I bought one and have been wearing it on and off ever since. Or rather, I bought one, it wore out, I was given one as a present, wore that out, got given two more. The one I have today is #4.

I find them quite comfortable, lightweight, and most importantly, they’re cool and keep the sun off well. They are also one of the few full-brim designs that can accommodate wearing a pair of headphones or headset underneath. Being cheap is a bonus. The downside? One is I find they’re very divisive, people either love them or hate them — that said I get more compliments than complaints. The other, is they try to take off with the slightest bit of wind, and are quite bulky and somewhat fragile to stow.

I ride a bicycle to and from work, and so it’s just not practical to transport. Hanging around my neck, I can guarantee it’ll try to break free the moment I exceed 20km/hr… if I try and sit it on top of the helmet, it’ll slide around and generally make a nuisance.

Caps stow much easier. Not as good sun protection, but still can look good.   I’ve got a few baseball caps, but they’re boring and a tad uncomfortable.  I particularly like the old vintage gatsby caps — often worn by the 1930’s working class.  A few years back on my way to uni I happened to stop by a St. Vinnies shop near Brisbane Arcade (sadly, they have closed and moved on) and saw a gatsby-style denim cap going for about $10. I bought it, and people commented that the style suited me. This one was a little big on me, but I was able to tweak it a bit to make it fit.

Fast forward to today, it is worn out — the stitching is good, but there are significant tears on the panelling and the embedded plastic in the peak is broken in several places. I looked around for a replacement, but alas, they’re as rare as hens teeth here in Brisbane, and no, I don’t care for ordering overseas.

Down the road from where I live, I saw the local sports/fitness shop were selling those flat neoprene sun visors for about $10 each.  That gave me an idea — could I buy one of these and use it as the basis of a new cap?

These things basically consist of a peak and headband, attached to a dome consisting of 8 panels.  I took apart the old faithful and traced out the shape of one of the panels.

Now I already had the headband and peak sorted out from the sun visor I bought, these aren’t hard to manufacture from scratch either.  I just needed to cut out some panels from suitable material and stitch them together to make the dome.

There are a couple of parameters one can experiment that changes the visual properties of the cap.  Gatsby caps could be viewed as an early precursor to the modern baseball cap.  The prime difference is the shape of the panels.

Measurements of panel from old cap

The above graphic is also available as a PDF or SVG image.  The key measurements to note are A, which sets the head circumference, C which tweaks the amount of overhang, and D which sets the height of the dome.

The head circumference is calculated as ${panels}×${A} so in the above case, 8 panels, a measurement of 80mm, means a head circumference of 640mm.  Hence why it never quite fitted (58cm is about my size) me.  I figured a measurement of about 75mm would do the trick.

B and C are actually two of three parameters that separates a gatsby from the more modern baseball cap.  The other parameter is the length of the peak.  A baseball cap sets these to make the overall shape much more triangular, increasing B to about half D, and tweaking C to make the shape more spherical.

As for the overhang, I decided I’d increase this a bit, increasing C to about 105mm.  I left measurements B and D alone, making a fairly flattish dome.

For each of these measurements, once you come up with values that you’re happy with, add about 10mm to A, C and D for the actual template measurements to give yourself a fabric margin with which to sew the panels together.

As for material, I didn’t have any denim around, but on my travels I saw an old towel that someone had left by the side of the road — likely an escapee.  These caps back in the day would have been made with whatever material the maker had to hand.  Brushed cotton, denim, suede leather, wool all are common materials.  I figured this would be a cheap way to try the pattern out, and if it worked out, I’d then see about procuring some better material.

Below are the results, click on the images to enlarge.  I found due to the fact that this was my first attempt, and I just roughly cut the panels from a hand-drawn template, the panels didn’t quite meet in the middle.  This is hidden by making a small circular patch where the panels normally meet.  Traditionally a button is sewn here.  I sewed the patch from the underside so as to hide the edges of it.

Hand-made gatsbyHand-made gatsby (Underside)

Not bad for a first try, I note I didn’t quite get the panels aligned at dead centre, the seam between the front two is just slightly off centre by about 15mm.  The design looks alright to my eye, so I might look around for some suede leather and see if I can make a dressier one for more formal occasions.

VK4MSL/BM Part 2: Upgrade of bike… upgrade of set… HF here I come

Well… just this afternoon, I made some steps towards getting HF going on the bicycle mobile station.

I’ve had the station going a while now… and with the new workplace being so close to home, I’m often heard on 2m, usually on three repeaters:

  • Bayside VK4RBS: 146.875MHz FM
  • Mt. Cotton VK4RAX: 147.075MHz FM
  • Mt. Glorious VK4RBN 147.000MHz FM

Usually, it’s VK4RBS in the centre of town unless there’s activity on VK4RAX.  VK4RAX as I get closer to home.  I’d listen to the latter all the way, but pagers clobber the receiver on the poor FT-290R II.  Hearing pagers is bad enough … try it through a headset!  Made worse by the fact that the headset is a semi-homebrew design, embedded inside a motorcycle helmet… so I can’t easily take it off.  Once I’m out of the city however, the pagers aren’t an issue.

Range is pretty good… I use a quarter-wave ground-plane antenna on 2m… actually, the antenna itself is the same as on my previous bicycle-mobile station… a tunable whip antenna.  The antenna is intended for mobile use on a car, so to give it a reasonable counterpoise, I cut a 500mm long piece of aluminium angle, and bolted the antenna mount to that.  I found that alone, wasn’t good enough, and since added a 500mm long piece of copper wire that hangs out the back.  That brings the SWR down nicely into the range where the FT-290R II is happy to work with it.

I have been able to open the squelch of the Toowoomba (VK4RDD) repeater, once waiting at lights at West Ashgrove, and another time, underneath the Goodwill Bridge at the Queensland Maritime Museum near South Bank in Brisbane.  I also can work the Ipswich repeater, VK4RAI while walking up the hill along Cooper’s Camp Road at Bardon… about a distance of 80km out to the repeater’s location (near Marburg).

This is using the FT-290RII with the 25W linear option, and the aforementioned antenna.

This afternoon, I figured out how to interface the electret microphone in the headset to the FT-897D.  The wiring standard I use for my headsets is a customised one… using DB15HD connectors (VGA-like).  A female DB15HD exists on the headset side, this is to prevent some goose trying to plug a headset into a VGA card on a computer.  The following is a rough schematic of a typical headset using this wiring scheme.

Typical headset wiring schematic... looking into female DB15HD connector.

There are three pins that are normally unused… On a couple of my interfaces, +5V and 0V are wired up… it was initally thought I’d use these for power rails … one supplied by the headset (one of my planned “headsets” was a former in-car hands-free kit for a Nokia 3310, and so you’d be able to charge the phone this way), the other supplied by the device (many radios supply a 3.3V or 5V rail).

For the FT-897D, the microphone used is normally the dynamic type… that is, uses a balanced (differential) audio feed.  On the FT-290R II, I tie Mic – to 0V, and just use it single-ended, which works fine… but a better way is to actually convert the single-ended microphone signal to differential.  How does one do this?  Well, the answer came out of the TI TLV320AIC3204 datasheet which I’ve been reading quite a bit lately.

TLV320AIC3204 Typical Circuit Configuration, showing microphone wiring (Source & Copyright: Texas Instruments)

Typical electret microphone configuration (Source: Wikipedia)

I noticed something odd about the way they wired up an electret microphone.  Rather than wiring it up as shown on the left… they instead mirror the positive side; feeding through a resistor to 0V, but tapping off via a series capacitor to the CODEC input (see right; click image to enlarge).  Why were they doing this I wondered?  Then I found it.  Inside the electret capsule is a J-FET which amplifies the weak signal from the microphone itself.  By hooking a resistor on both sides, and using two capacitors, they were creating a phase splitter.  I stumbled across that article on Wikipedia, and it was then I knew what they were doing.

So I’ve done the same thing here… Rather than a single-ended design, I have interfaced the electret microphone to the radio using the phase-splitter technique.  The schematic I use (with DB15HD pinouts) is below:

FT-897D Headset interface

I’m yet to take the whole shebang for a ride… I have a 6′ long CB (27MHz) whip that, last time I tried, tuned up nicely on 10m and 6m… might work somewhat down on 20m. I have had a VK2 station come roaring in at S7 when listening on 80m via this antenna on the back of my fold-up bicycle, but unsurprisingly it’s pretty deaf there… I plan to get a second antenna mount and suitable spring (so the antenna doesn’t get snapped by a low branch), make up a new bracket, and mount that some time in the coming weeks… then we shall see what the bands are like around Brisbane.

Lemote Yeeloong: First impressions

Well, after a few minor hiccups with delivery (basically I wasn’t home when the first delivery was made, the second delivery — apparently the driver knocks on the door with a very delicate touch), I have at last gotten hold of one of these devices.

Out of the box, they run Debian Linux/MIPS, with just about every app you could think of that would be useful on a desktop.  They feature nicely integrated power management… and… looking at the defconfig for these devices, there seems to be the hint of suspend-to-disk capability, although I’m not sure how well developed it is.  Lemote have pulled off a lot of voodoo at the kernel level to get this going.  There are not a lot of MIPS systems that have power management to worry about.

Performance, well subjectively, it seems about on par with my old laptop, a Toshiba TE2100 (Pentium 4M 1.7GHz)  for responsiveness.  It runs a 64-bit kernel out-of-the-box, although runs a 32-bit userland (O32).

Ergonomics, for the size of the machine, it is not bad to use.  I think I found my old PDA more painful… this thing once you get used to the positions of keys, is quite usable.  I’m still getting used to the right-hand shift key being small, the backtick being above the 1 key (consequently, those numbers being one position to the left of where I expect), and for a while, I kept hitting S instead of A.  I find myself constantly hitting the up-arrow when typing capital letters, hitting Fn instead of Ctrl, and sometimes bumping the touch pad… but this will of course settle down as I get used to the machine.  Given the space available, Lemote have done well with the design of the machine.

Video capability seems quite good for 2D, there seems to be little evidence of 3D acceleration, but I guess that will come before long.  It did struggle to play a DVD earlier, however this is not conclusive, since there are a number of factors at play needed to play video smoothly.  I shall know more as I experiment.

What about Gentoo?  Well, I’m preparing new stages… I’ve had a few hiccups there, mainly glibc being difficult.  In the short term, I’ll stick with Debian on this box while I find out what makes the device tick (Gentoo will lurk in a chroot), then I may move to a dual-boot or pure Gentoo environment.

Anyway, I’m off to play with my new toy. 🙂