| |
The SpeakJet is a wonderful little IC that is capable
of producing a myriad of sounds including speech! It is designed to
easily interface to an MCU through a serial interface. Below is an
example of using a DevBoard-M8 to control the SpeakJet
IC. The output from the SpeakJet is connected to an audio amplifier
- LM386. This will drive a standard speaker loud enough to be
heard across a room.

I used Phrase
Translator to create the Data statements at the end. Additional
phrases can be added using the same method.
This program will make the Speak
Jet Say "Welcome to
Wrighthobbies.net"
'SpeakJet Sample code
'Baud: 9600 using hardware UART
'The SpeakJet says "Welcome to WrightHobbies.net"
'Eddy Wright - Wright Hobbies, LLC
'http://www.wrighthobbies.net
'Dimension Variables
Dim Y As Byte , Tmp As
Byte
'temp vars
Dim Msg As String *
40
'Var that holds message
'Do Setup
'It isn't necessary to use the MCU to control M0,M1 & Reset
'You can tie M0 to Low and M1 & Reset to High for normal operation
'I included this to help do auto-baud detect if needed
Config Portd =
Output
'Using PortD to control Mode and reset lines
Mode0 Alias
Portd.5
'M0 line
Mode1 Alias
Portd.6
'M1 Line
Rst Alias
Portd.7
'Reset Line
'Set Control lines accordingly
Reset
Mode0
'M0 low
Set
Mode1
'M1 high
Set
Rst
'Reset High
Waitms 500
'Force Speakjet to Reset
Reset
Rst
'Bring Reset low momentarily to force the chip to reset
Waitms 250
Set Rst
Wait 2
Y =
0
'Y is used as the index to the Data below
Do
'Load the message from the Data statements
Tmp = Lookup(y , Message)
If Tmp = 0 Then Exit
Do
'Zero byte is used to indicate the end of data
Msg = Msg + Chr(tmp)
Incr Y
Loop
Do
Print Msg
'Send message to the SpeakJet
Wait 5
Loop
End
Message:
Data 147 , 159 , 194 , 134 , 140 , 8 , 191 , 162 , 148 , 7 ,
155 'Data constructed using Phrase
Translator
Data 7 , 128 , 191 , 8 , 6 , 184 , 6 , 135 , 8 , 173 , 8 , 128
Data 8 , 187 , 1 , 175 , 8 , 136 , 191 , 1 , 6 , 141 , 131 , 191 , 0
Auto-Baud Detection
The SpeakJet worked great using the
default setting of 9600 baud. But after an hour of playing, the
battery ran down to the point that the SpeakJet started to sputter. I
replaced the battery, but it would no longer speak the words correctly. The
demo mode still worked, so I guessed the baud rate had somehow changed on
the chip. This small program will put the SpeakJet into auto-baud mode
and recalibrate automatically. This works with the same hardware
configuration depicted above.
Bascom Code
'SpeakJet Auto-Baud code
'Baud: 9600 using hardware UART
''Eddy Wright
'http://www.wrighthobbies.net
Wait
1
'Wait a second
'Dimension Vars
Dim Y As Byte , Tmp As Byte 'temp vars
Dim Msg As String * 24
'var holding text to send
'Do Setup
Config Portd = Output
'Configure PortD for output to control M0,M1,RST
Mode0 Alias Portd.5
'Friendly Name for port pin
Mode1 Alias Portd.6
'Friendly Name for port pin
Rst Alias Portd.7
'Friendly Name for port pin
Set Mode0
'M0 high
Set Mode1
'M1 High
Set Rst
'Reset High
Wait 5
'Wait 5 seconds - In Demo mode
Reset Mode1
'Bring M1 low momentarily
Waitms 500
Set Mode1
Wait 5
'You should hear sonar pinging now
Print Chr(&H55)
'Send synch byte to set baud rate
Wait 1
Reset Mode0
'Return to normal mode
Wait 1
Reset Rst
'Force SpeakJet to Reset
Waitms 250
'You should hear it say "Ready"
Set Rst
End
|
|