Let's Make Robots!

Learning Spin: Text-to-Speech

Let's take a look at Text-to-Speech & show you an example of how objects can be used.  My other tutorials (including my written objects guide) are here.

The Code


You can also download it here.

Building on previous tutorials, there are a few new concepts;

Pipe (|)
When you declare a method (prog1), you can use a pipe (the key above the backslash on your keyboard) and declare local variables.  Here, I've declared just one, 'i'.  You can declare multiple with a comma between each; PUB start | i,x,z.  Local variables are only available within the method (other methods can't access them), and are re-initialized each time the method is called.  They're often used for controlling incrementing loops and other throwaway type activities.

Symbol Address (@)
The @ sign return the address the variable is stored instead of the value.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Are you using the speach demo Object that I sent you or a different one?

but Phil put an updated copy on the Parallax forums a few days ago.  I think they're pretty much the same, though.

The search feature on the OBEX is less than desired. What name did Phil use so I can find it?

Because I think it's GPL instead of MIT.  But here's the forum post - http://forums.parallax.com/showthread.php?t=126586

Have tried out your code on my Prop. system and it works "reeli wel" - phonetics just require some lazy spelling ......thanks for the tip.......

Yeah, feeding it raw text is unlikely to give you something comprehensible unless you prepare the text first.  But there are a few modifiers to help - like changing the pitch and replay speed.  They're in the documentation view of the talk object.

Thus my delema... As you know, Walter's voice is done by a friend in London. The voice is mp3 and crystal clear but I must know in advance everything I want him to say. At best, he can say numbers on-the-fly but of course, one at a time. With any kind of speech like you are showing here, there is always going to be a trade between quality and vocabulary. I will say this though, as a point-of-reference, the ability to simply understand the "propeller voice" is for sure, a plus. I would put it against the crap coming out of a speak-jet any day.

I checked it out - the sound quality isn't that bad, although the price hurts ($25!).  One thing I do like about Phil's phoneme library is it's all open source, so anyone can improve on it. 

For my talking alarm clock, I just concatenated wav's '40.wav + 5.wav = forty five'.  Propeller TTS requires some pre-prep, too.  Unless you just want it to spell stuff. 

Phil's phoneme library isn't complete, the spelling works pretty well, though (just change the method to t.spell). I should have typed 'hello' as 'hellow'. 

I think using wav samples off an SD card is better for actual use, but using a keyboard was fun. 

I have been playing with this one sense you zapped it to me and yeah, I like it. I do have to say that Yoo riilee need too spell things foneticklee. All in all not bad --and I am surprised how small it is on the chip.