Posts Tagged speech synthesis
I subjected Haiku Detector to some serious stress-testing with a 29MB text file (that’s 671481 sentences, containing 16810 haiku, of which some are intentional) a few days ago, and kept finding more things that needed fixing or could do with improvement. A few days in a nerdsniped daze later, I have a new version, and some interesting tidbits about the way Mac speech synthesis pronounces things. Here’s some of what I did:
- Tweaked the user interface a bit, partly to improve responsiveness after 10000 or so haiku have been found.
- Made the list of haiku stay scrolled to the bottom so you can see the new ones as they’re found.
- Added a progress bar instead of the spinner that was there before.
- Fixed a memory issue.
- Changed a setting so it should work in Mac OS X 10.6, as I said here it would, but I didn’t have a 10.6 system to test it on, and it turns out it does not run on one. I think 10.7 (Lion) is the lowest version it will run on.
- Added some example text on startup so that it’s easier to know what to do.
- Made it a Developer ID signed application, because now that I have a bit more time to do Mac development (since I don’t have a day job; would you like to hire me?), it was worth signing up to the paid Mac Developer Program again. Once I get an icon for Haiku Detector, I’ll put it on the app store.
- Fixed a few bugs and made a few other changes relating to how syllables are counted, which lines certain punctuation goes on, and which things are counted as haiku.
That last item is more difficult than you’d think, because the Mac speech synthesis engine (which I use to count syllables for Haiku Detector) is very clever, and pronounces words differently depending on context and punctuation. Going through words until the right number of syllables for a given line of the haiku are reached can produce different results depending on which punctuation you keep, and a sentence or group of sentences which is pronounced with 17 syllables as a whole might not have words in it which add up to 17 syllables, or it might, but only if you keep a given punctuation mark at the start of one line or the end of the previous. There are therefore many cases where the speech synthesis says the syllable count of each line is wrong but the sum of the words is correct, or vice versa, and I had to make some decisions on which of those to keep. I’ve made better decisions in this version than the last one, but I may well change things in the next version if it gives better results.
Here are some interesting examples of words which are pronounced differently depending on punctuation or context:
|ooohh||Pronounced with one syllable, as you would expect|
|ooohh.||Pronounced with one syllable, as you would expect|
|ooohh..||Spelled out (Oh oh oh aitch aitch)|
|ooohh…||Pronounced with one syllable, as you would expect|
|H H||Pronounced aitch aitch|
|H H H||Pronounced aitch aitch aitch|
|H H H H H H H H||Pronounced aitch aitch aitch|
|Da-da-de-de-da||Pronounced with five syllables, roughly as you would expect|
|Da-da-de-de-da-||Pronounced dee-ay-dash-di-dash-di-dash-di-dash-di-dash. The dashes are pronounced for anything with hyphens in it that also ends in a hyphen, despite the fact that when splitting Da-da-de-de-da-de-da-de-da-de-da-de-da-da-de-da-da into a haiku, it’s correct punctuation to leave the hyphen at the end of the line:
Though in a different context, where – is a minus sign, and meant to be pronounced, it might need to go at the start of the next line. Greater-than and less-than signs have the same ambiguity, as they are not pronounced when they surround a single word as in an html tag, but are if they are unmatched or surround multiple words separated by spaces. Incidentally, surrounding da-da in angle brackets causes the dash to be pronounced where it otherwise wouldn’t be.
|U.S or u.s||Pronounced you dot es (this way, domain names such as angelastic.com are pronounced correctly.)|
|U.S. or u.s.||Pronounced you es|
|US||Pronounced you es, unless in a capitalised sentence such as ‘TAKE US AWAY’, where it’s pronounced ‘us’|
I also discovered what I’m pretty sure is a bug, and I’ve reported it to Apple. If two carriage returns (not newlines) are followed by any integer, then a dot, then a space, the number is pronounced ‘zero’ no matter what it is. You can try it with this file; download the file, open it in TextEdit, select the entire text of the file, then go to the Edit menu, Speech submenu, and choose ‘Start Speaking’. Quite a few haiku were missed or spuriously found due to that bug, but I happened to find it when trimming out harmless whitespace.
Apart from that bug, it’s all very clever. Note how even without the correct punctuation, it pronounces the ‘dr’s and ‘st’s in this sentence correctly:
the dr who lives on rodeo dr who is better than the dr I met on the st john’s st turnpike
However, it pronounces the second ‘st’ as ‘saint’ in the following:
the dr who lives on rodeo dr who is better than the dr I met in the st john’s st john
This is not just because it knows there is a saint called John; strangely enough, it also gets this one wrong:
the dr who lives on rodeo dr who is better than the dr I met in the st john’s st park
I could play with this all day, or all night, and indeed I have for the last couple of days, but now it’s your turn. Download the new Haiku Detector and paste your favourite novels, theses, holy texts or discussion threads into it.
If you don’t have a Mac, you’ll have to make do with a few more haiku from the New Scientist special issue on the brain which I mentioned in the last post:
Being a baby
is like paying attention
with most of our brain.
But that doesn’t mean
there isn’t a sex difference
in the brain,” he says.
They may even be
a different kind of cell that
just looks similar.
It is easy to
see how the mind and the brain
We like to think of
ourselves as rational and
It didn’t seem to
matter that the content of
these dreams was obtuse.
I’d like to thank the people of the xkcd Time discussion thread for writing so much in so many strange ways, and especially Sciscitor for exporting the entire thread as text. It was the test data set that kept on giving.
I’ve been thinking of getting my robot choir (an app I wrote to make my Mac’s speech synthesis sing) to sing Jonathan Coulton covers for a while, but as many of his songs involve robots, singing them with a robot voice forces a change of perspective. I rewrote Better to be from the perspective of a robot whose partner is becoming human, rather than a human whose partner is becoming a robot. Here‘s a rough recording of it using the Trinoids voice and the karaoke file for the song:
Where did we go?
When was the moment that we came unplugged?
I think I know.
In fact I am sure ’cause I’ve had your chips bugged.
I remember the first big surprise,
the day you came home with your infant-bred eyes.
I looked inside them and lased you a note
but your return signal was smoke.
But it’s not smoke, it’s fire,
and your burning desire
to turn into something
that I don’t require.
You used to be OK
and I liked you that way,
but I don’t think that I like you better.
No I don’t think that I like you better.
Started out small:
some lungs and a heart and your lasers unwired.
Now you’re just six feet tall.
Even when fully charged your organics get tired.
And I’m tired of the evenings I spend
making small talk with your new human friends
and their stupid insistence on blocking my lasers
when they know I know the three laws.
And you climbed the wrong way out
of the uncanny gorge.
You went from bad data
to bad Geordi La Forge.
You used to be OK
and I liked you that way,
but I don’t think that I like you better.
No I don’t think that I like you better.
So that’s how it goes.
Tap my interface once if you still understand.
No data flows.
Wait, are your digits just five on your hand?
I can tell by your insider art
There’s more than a pump in your chimpanzee heart.
I tried to reason, but something’s gone wrong.
Why am I singing a song?
Well, I like to think different, but it’s not quite the same.
If this is a trojan, I know who to blame.
You used to be flawless; now you’re F-ing lawless,
and I don’t think that I like you better.
No I don’t think that I like you better.
Some lines stay close to the original when I perhaps should have struck out and gone with something completely different. If you have any suggestions, let me know; the beauty of robots is I can change the words and make a new recording in seconds.
The tune is based on Spektugalo’s UltraStar file for that song. I had to make some changes to the robot choir to handle the one-beat gaps between notes, and I made a few tweaks to timing after that, which probably messed up more than they fixed. When I started writing this parody, I assumed I had the source tracks of the original song to work with, but it turns out that song is not on JoCo Looks Back, so all I have is the karaoke version with some backing vocals. I’ve turned the volume of my vocals way up, both so they’re easier to understand and to obscure the backing vocals more when the lyrics are not the same. Consider this a demo.
On the subject of cruises, I’ve just had some copies of my They Might Not Be Giants poster printed, and I’ll bring them with me on JoCo Cruise Crazy. If you are going on the cruise (or will just be in the area the night before) and you would like to buy one from me for less than it would cost through Zazzle, let me know and I’ll make sure I bring one for you. I can’t sell them on board the ship due to the cruise line needing a cut, but I can do so at the hotel before the cruise, the cruise port or airport after, or we can work out some kind of trade involving upcharged food or drink on the ship. They are A3 sized (just a tiny bit smaller than 11×17 inches) and printed beautifully on 300gsm silk-coated paper.
When Europeans colonised New Zealand, they brought not only mammals to drive many of the native birds to extinction, but also their religion to exterminate the native theodiversity. This began with Reverend Samuel Marsden on Christmas Day 1814, and there is a Christmas carol about it called Te Harinui. Since it just turned Christmas day about an hour ago in New Zealand, here‘s a recording of Te Harinui I just made.
It’s sung by the voice Vicki from my robot choir (an app I wrote to make my Mac sing using the built-in speech synthesis.) It has a couple of little glitches, and I couldn’t get it to pronounce the Māori words exactly right, but otherwise, I think this is the best Vicki has ever sounded. Usually I switch to Victoria because Vicki’s singing sounds weird. I made a couple of tweaks to the time allocated to consonants, and I think they helped. I used the music in the New Zealand Folk Song page, with a few small changes to the ‘glad tidings’ line to make it sound more like how I remember it.
You can see the effect of widespread hemispherism in the fact that the song opens by saying it isn’t snowy, as if being snowy were the default state and any deviation from it must be called out.
Now, I must get some good Christmas sleep.
I felt a bit bad about having to truncate the full-length instrumental that Colleen and Joseph made for JoCo Day is Wunnerful, so, having already taught my robot choir the main melody, I decided to record my own cover of Christmastime is Wunnerful. I was toying with the idea of making it a mashup with Jonathan Coulton’s other Christmas classic, Chiron Beta Prime (since the source tracks for that are available), when I realised that even without modification, Christmastime is Wunnerful is quite amusing to listen to while watching Tom Ellsworth‘s music video for Chiron Beta Prime. So I decided to edit that video (with Tom’s permission) to match my cover. Here is the result:
For comparison, here’s the original Chiron Beta Prime video. I didn’t have to change very much, really:
I had to pretty much abandon the ‘daily’ part of Holidailies because ended up flyng to New Zealand, which in itself takes more than a day without internet. But here’s some more holiday for you.
The voices I used were, in order of appearance:
Adult human male: Alex
Standard robots: Zarvox
Festive holiday figure robots for the purposes of augmenting human morale and productivity: Trinoids
Adult human female: Victoria
Human male emulation for the purposes of undetectable redaction: Ralph
Juvenile human: Junior
I also used the bells and ‘Message redacted’ tracks from Chiron Beta Prime, and the ‘Machines’ track from The Future Soon.
I originally wrote Haiku Detector because my friend Gry saw Times Haiku and wondered whether there were any haiku in her Ph. D. thesis. The other day I heard back about the haiku she found. It turns out that even the title of the thesis is a haiku:
studies of the extremes of
Here’s another one, which could be about anything. The last line is a bit of an anticlimax.
As of today, the
origin of this strength is
not well understood.
When I read this one, I wondered if miniball was a mini-golf style version of another ball game:
the MINIBALL would be used
for the same purpose.
are easily seen.
After seeing these, I sent her the as-yet-unreleased new version of Haiku Detector, which can detect haiku made up of several sentences. Having mostly had my name on papers authored by the entire CMS collaboration, I expected her to find a lot of haiku in the author list. But ISOLDE is much smaller, and also this is her thesis that she wrote, not some paper whose author list she got tacked onto. So she got some from references:
Goko, H. Toyokawa,
K. Yamada, T.
and some things with section numbers tacked on:
Open shell nuclei and
This matrix is the
starting point for the Oslo
That last one has so many possibilities. I like to think of it as being about an electronic band called The Oslo Method which released a 45rpm record about The Matrix. Unfortunately, nobody can be told what the haiku is. You have to see it for yourself. And indeed, you can see the other haiku she found on the #MyHaikuThesis tag on Twitter.
I noticed something interesting while writing this post — some of the ‘haiku’ Gry found include gamma (γ) symbols:
The γ-ray strength functions
display no strong enhancement
for low γ energies.
Haiku Detector on her Mac has treated them as having zero syllables, as if they are not pronounced, and I think I recall characters like that not being pronounced in the Princeton Companion to Mathematics. But I just checked on my Mac running Mac OS X Yosemite, and the speech synthesis (which Haiku Detector relies on for syllable counting) pronounces γ as ‘Greek small letter gamma’, so Haiku Detector does not find those erroneous haiku. I think that this might be a new feature in Yosemite.
But here’s where it gets weird: you’d think that it’s just reading ‘Greek small letter gamma’ because that’s the unicode name of the character. I tried with a few emoji and other special characters, and that hypothesis is upheld. But the unicode character named ‘chicken’ (🐔) is pronounced ‘chicken head’. Spooky. Another strange thing is that there is no unicode ‘duck’ character.
If you’ve been paying attention, you probably know why I happened to come across those oddities. I’ll have to investigate them later, though; right now I’m in Edinburgh for NSScotland, and it’s about time I looked at some tourism information.
So, Haiku Detector; what now? Maybe look for supersymmetric haiku?
Update: It seems that in Mac OS X 10.8, γ is not pronounced, and 🐔 is pronounced ‘chicken emoji’. Other emoji also have ’emoji’ in their pronunciations, while still others are not pronounced. I wonder if pronunciations were added (and later edited to remove the ’emoji’) for certain emoji, and now the default pronunciation has changed from nothing to the unicode name. So ‘🐔’ ended up with the explicit pronunciation ‘chicken head’ while others which were not previously pronounced use their unicode names. So this should be a haiku in Yosemite, though for some reason Haiku Detector does not detect it:
I am learning about four-part harmonies, so I wrote and recorded [mp3] a short song about self-confidence and poop. Anyone with a head and a butt should understand; understand also that I do not condone headbutting buttheads. These are four voices that might accumulate in one’s head as a child grows up and vacillates between self-confidence and self-doubt.
Here are the lyrics:
Soprano: Look how in-control my bowel is. Clearly I know where my towel is.
Alto: What if all I do is shit? How do they put up with it?
Tenor: Push and push and I’ll improve. Know my shit, my bowel will move.
Bass: Everyone poops.
All: If everyone poops…
Soprano & Tenor: Maybe I’m no better than them.
Alto & Bass: Maybe I’m no worse than them.
All: Maybe I am just as good.
It is sung by my robot choir (a program I wrote to make my Mac sing using the built-in speech synthesis), with the voice Princess as the soprano, Victoria as alto, Fred as tenor and Ralph as the bass, unless I’ve misunderstood how the parts are named or which octaves they were meant to be singing in, which is entirely likely after one half-hour lesson on the topic.
I’ve mentioned before that I’m doing music lessons with John Anealio over the internet. A couple of weeks ago I decided I wanted to learn about harmonies. We picked out some chords and random and then decided which notes each voice would sing from them. I checked out what they sounded like using instruments in GarageBand, then I decided I may as well write some words with it, with each voice singing the same sequence of notes over and over. I remember thinking about making them conflicting inner voices, but I’m not sure what made me decide that those inner voices were full of shit. Of course, I can’t tell whether this song is shit, good shit, horse shit, or the shit; when it comes to music, I’m still figuring out how not to soil myself. But it’s about poop, so it ought to entertain someone.
One of these days I’ll find a more convenient way to host podcasts so that I actually bother to put things like this on mine.
This is the fourth in a series called ‘Forms and Formulae‘ in which I write about articles in the Princeton Companion to Mathematics using poetic forms covered by articles in the Princeton Encyclopedia of Poetry and Poetics. This post’s mathematics article is entitled ‘The General Goals of Mathematical Research‘ and the poetic form is alba, which is a kind of song; I recorded it [direct mp3 link] using my robot choir and some newfound musical knowledge, and there are many notes on that after the lyrics below.
Here are some extracts from the article on the alba, explaining the features that I ended up using:
A dawn song about adulterous love, expressing one or both lovers’ regret over the coming of dawn after a night of love. A third voice, a watchman, may announce the coming of dawn and the need for the lovers to separate. An Occitan alba may contain a dialogue (or serial monologues) between lover and beloved or a lover and the watchman or a combination of monologue with a brief narrative intro.
The alba has no fixed metrical form, but in Occitan each stanza usually ends with a refrain that contains the word alba.
…the arrival of dawn signaled by light and bird’s song…
The watchman plays an important role as mediator between the two symbolic worlds of night (illicit love in an enclosed space) and day (courtly society, lauzengiers or evil gossips or enemies of love)
I based the song on section 8.3 of the article, entitled ‘Illegal Calculations‘. In retrospect, using the word alba in each refrain (are these even refrains?) doesn’t make much sense, since I’m not writing in Occitan, and the casual listener will not know that alba means ‘dawn’ in Occitan. But hey, it kind of rhymes with the start of ‘self-avoiding walk‘. How can I not rhyme an obscure foreign word with an obscure mathematical concept?
Mathematicians struggle even today to learn about the average distance between the endpoints of a self-avoiding walk. French physicist Pierre-Gilles de Gennes found answers by transforming the problem into a question about something called the n-vector model when the n is zero. But since this implies vectors with zero dimensions, mathematicians reject the approach as non-rigorous. Here we find that zero waking up next to its cherished n-vector model after a night of illicit osculation.
I am just a zero; I am hardly worth a mention.
I null your vector model figure, discarding your dimension,
and every night I’m here with you I fear the break of day,
when day breaks our veneer of proof, and we must go away.
Here by your side
till alba warns the clock.
Fear’s why I hide
in a self-avoiding walk.
Let the transformations of De Gennes show your place.
Never let them say we’re a degenerate case.
When I’m plus-two-n there’s just too many ways to move,
But you’re my sweetest nothing and we’ve got nothing to prove.
Here by your side
till alba warms the clock.
Fear can’t divide;
it’s a self-avoiding walk.
The sun has come; your jig is up. It’s time for peer review.
You think your secret union has engendered something new.
You thought you would both find a proof, but is it you’re confusing
The sorta almost kinda-truths the physicists are using?
That’s not rigorous,
says alba’s voice in shock.
All but meaningless
to the self-avoiding walk.
Zero and N-vector model together:
If you say that our results don’t matter,
then go straight to find a better path.
For as long as you insult our data,
Is it wrong to say you’re really math?
Hey there, Rigorous
at alba poised in shock,
you are just like us,
in a self-avoiding walk.
All voices are built-in Mac text-to-speech voices, some singing thanks to my robot choir (a program I wrote to make the Mac sing the tunes and lyrics I enter, which still needs a lot of work to be ready for anyone else to use.) Older voices tend to sound better when singing than the newer ones, and many new voices don’t respond to the singing commands at all, particularly those with non-US accents. So for the introduction I took the opportunity to use a couple of those non-US voices. These are the voices used:
Introduction: Tessa (South African English) and, since I also can’t fine-tune Tessa’s pronunciation of ‘Pierre-Gilles de Genne’, Virginie (French from France)
N-vector Model: Kathy
Most of the bird noises come from the end of Jonathan Coulton’s ‘Blue Sunny Day‘, and I can use them because they’re either Creative Commons licensed or owned by the birds. The two peacock noises are from a recording by junglebunny. Free Birds!
As I mentioned, I’ve been learning about songwriting from John Anealio, and since the Forms and Formulae project sometimes requires me to write songs, I’m putting the new knowledge into practice sooner than I expected. This song uses several musical things I’ve never tried before, which is quite exciting, but it also means I probably didn’t do them very well, because there’s only so much I can learn in a couple of months of half-hour weekly lessons. I welcome friendly criticism and advice. The new things are: Read the rest of this entry »
Back in late February, my friend Alice sent an email asking people to cover The Doubleclicks’ Nerdy Birthday Song for Sara Chicazul, who had a birthday on JoCo Cruise Crazy 2 but not on JoCo Cruise Crazy 3. The idea was to put up one per day, so that she could experience the thrill and horror (previously reserved for Mike Phirman) of having a birthday every day. A lot of people did. I don’t usually sing anything more melodic than Chicken Monkey Duck when people can hear me, so I figured I’d dust off my robot choir (a little program I wrote to take text and a tune played on my MIDI keyboard, and turn it into TUNE commands to make the built-in Mac speech synthesis sing) and record a cover that way. It took a fair bit of dusting off, what with a new version of XCode and of the MIDI framework I used, and I think the metaphorical dust mites gave me cold-like symptoms, which is why I haven’t posted anything for a while. Anyway, today I finally recorded a cover, and here it is. Given that the third thing I ever recorded using my robot choir was my Macs singing Happy Birthday to the London Science Museum, I think I may as well rename my robot choir to ‘The Phirmanator’.
This recording starts off with just the Victoria voice singing, then at the first ‘you’re getting older’, Vicki joins in. I have a cameo saying ‘everybody!’ and then Agnes joins in and all three voices get a gospel choir effect. I added Zarvox (an intentionally robotic voice) at the end, partly because I thought it would be funny, and partly because Vicki sounds awful holding that ‘all’ note and I wanted to make up for her being so much quieter in that part. I noticed part of the way through that I’d used the wrong notes in a few places, so I fixed those, but there are probably others. I don’t know how to make music; I just know how to turn MIDI notes into frequencies. Also, I can barely even play my rainstick, let alone a stringed instrument, so it’s a robocoppella. I timed everything to synch up with the original song, and it sounds kind of nice if you play both together. By itself, well… it sounds like autotune became sentient and killed all the human singers.
Somebody on Twitter mentioned he’d like the file I used to get my Mac to sing Still Alive, so here it is. If you have a Mac, you just need to open this in any application which can view text (TextEdit, for example) go to the Edit menu, Speech submenu, and select ‘Start Speaking’. You can try different voices by changing the system voice in the Speech pane in the System Preferences. For best results, use a high quality voice such as Vicki or Victoria. Alex is supposed to be the highest-quality, but it’s a male voice, and I don’t think I’ve tried it. Voices that already have their own built-in tunes (such as Good News and Bad News) won’t work. You could also create a sound file of it using the ‘Text to Audio File’ Automator action.
It won’t sound exactly like the recording in the video I made, because I edited the resulting sound file in GarageBand to get the timing to match up with the original song. If you want to shortcut all that, or if you don’t use a Mac, you can get your computer to sing (or lip-synch?) Still Alive by downloading this mp3.
This file is released under a PleaseDon’tSueMeValve-Attribution-Noncommercial-ShareAlike license, which is explained in detail in the file itself.