Talking bot "Hello"

Is it possible at all to get this to work with the botboard II pro 28?

[code]func play_hello()
mouthindex = 0
soundindex = 0
eyeindex = 0
eyecommands(0)=0

soundcommands(0)=1 
soundcommands(1)=0 
soundfile(0)=".Face\hello.wav" 
soundtimes(0) = getms()+10 

mouthcommands(0)=3 
mouthtimes(0)=getms() 

mouthcommands(1)=1 
mouthtimes(1)=getms()+200 
mouthcommands(2)=2 
mouthtimes(2)=getms()+780 
mouthcommands(3)=2 
'mouthtimes(3)=getms()+1000 
'mouthcommands(4)=2 
'mouthtimes(4)=getms()+3000 
mouthcommands(3)=0 

endfunc
[/code]

I just want my bot to say small words like hello. But it has to use the onboard speaker. Also i hear people say you have to place the file in the same folder but how do i acces the botboards memory??

might help to know what you clipped that from. :bulb:

it looks like it is calling some built-in or library based functions.

I see Eddie beat me to this.

It is hard to answer this for you on many different levels.

  1. Can you get sounds out of that little speaker on the BB2 that will meet your approval? For sure it will not compete with a sound board and external speakers on a PC. If you wish to do speaking, you may want to look at the speakerjet board. There is at least one thread on that.

  2. Assuming 1) Is it possible to write code that runs on the BAP28 that can parse through a .WAV file and convert its format into something that you can output the sounds to speaker. Maybe, if you know the format of the file and are good at programming. I don’t know of any example code for the BAP that does this. It would probably be easier if you could come up with a set of frequency/Duriation pairs to store out and playback.

  3. Not sure what you mean by access the access the botboard memory. The board does not have any memory. The BAP28 has memory, but there are different types of memory and ways to read and write to them.
    a) 32K of program space. You can hardcode tables of numbers using commands like BYTETABLE that stores a set of numbers into program space at compile time.
    b) 2K of Ram - This is your normal program memory space, where you simply define variables and use them
    c) 4k of EEPROM (on newer chips): There is 4k of memory that you can read to and write from on the chip. The values of this memory stays set accross reboots and power cycles so it is good for things like user preferences, servo zero offsets, etc. You can access this memory using such commands as Read/Write or ReadDM and WriteDM.

Kurt

Trying to develop Mbasic code to generate speech or play .wav files would be a first. There are no example code that I know of that can be referred to.

If you’re like me, and have limited programming skills, using a speak jet is a lot easier. You can generate custom sounds as well as use built in sound clips. It’s easy to interface to the BAP and there are some example code available. You can create a word or a short phrase with as little as one line of code.

The chip is available here: speechchips.com/shop/

That’s what i was looking for… Is there some kind of generator to generate a “hello”? it must be possible right?

I remember a couple decades ago some clever programmers were able to get some degree of understandability from assembly language programming on the old PC XT platform. I say clever because it was using the on board speaker much like the Bot Board has. The speaker was only sent high and lows from the PC XT. However it is not a simple matter to do this on an Atom Pro and would likely take up too much resources. So, I dunno… lol

Yes exactly. i thought of that yesterday. I had a 386 laptop with the same system.

It wouldn’t have to run on the atom pro. I only need the output for hello and put that in the code…

By the way, this is where i got the code from:lynxmotion.net/viewtopic.php?t=576&highlight=wav&sid=5e92b8146290a0ea5b698e4bcf80a64a

I have not done anything like this on the BAP, the closest I have done was on the Seattle Robotics Society workshop robot kit with the arc expension board, which had a a little speaker like this was to be able to play notes. So then I encoded some of the songs that came with the AVR butterfly board and was able to play some real simple songs…

Good Luck
Kurt

didn’t that software use to convert all sound to .vog or .mod files before sending them to the speaker? Maybe those files are compatible?

hehehe LOL :smiley:

Just for the fun of it, I did hack in a version of the song playing stuff I had up on the AVR processors. I did it on my current test setup, which is now an ABB board so I used P4-P6 switches instead of the P12-P14 where the switches are on the BB2, but that is easy to change…

If You hit buttonA it plays one song, not to bad and if you hit B it plays a different one (sort of…), but then again this is not saying Hello…

Kurt

[code];--------------------------------------------------------------------
; Simple test program to play a simple song when you press a button…
;

TRUE con 1
FALSE con 0

;button init
buttonA var bit
buttonB var bit
buttonC var bit

prevA var bit
prevB var bit
prevC var bit

;--------------------------------------------------------------------
;[Sound definitions] - Make defines for different frequencies… in hz
FREQ_A0 con 28: FREQ_A1 con 55: FREQ_A2 con 110: FREQ_A3 con 220: FREQ_A4 con 440: FREQ_A5 con 880: FREQ_A6 con 1760
FREQ_Bb0 con 29: FREQ_Bb1 con 58: FREQ_Bb2 con 117: FREQ_Bb3 con 233: FREQ_Bb4 con 466: FREQ_Bb5 con 932: FREQ_Bb6 con 1865
FREQ_B0 con 31: FREQ_B1 con 62: FREQ_B2 con 123: FREQ_B3 con 247: FREQ_B4 con 494: FREQ_B5 con 988: FREQ_B6 con 1976
FREQ_C0 con 33: FREQ_C1 con 65: FREQ_C2 con 131: FREQ_C3 con 262: FREQ_C4 con 523: FREQ_C5 con 1047: FREQ_C6 con 2093
FREQ_Db0 con 35: FREQ_Db1 con 69: FREQ_Db2 con 139: FREQ_Db3 con 277: FREQ_Db4 con 554: FREQ_Db5 con 1109: FREQ_Db6 con 2217
FREQ_D0 con 37: FREQ_D1 con 73: FREQ_D2 con 147: FREQ_D3 con 294: FREQ_D4 con 587: FREQ_D5 con 1175: FREQ_D6 con 2349
FREQ_Eb0 con 39: FREQ_Eb1 con 78: FREQ_Eb2 con 156: FREQ_Eb3 con 311: FREQ_Eb4 con 622: FREQ_Eb5 con 1245: FREQ_Eb6 con 2489
FREQ_E0 con 41: FREQ_E1 con 82: FREQ_E2 con 165: FREQ_E3 con 330: FREQ_E4 con 659: FREQ_E5 con 1319: FREQ_E6 con 2637
FREQ_F0 con 44: FREQ_F1 con 87: FREQ_F2 con 175: FREQ_F3 con 349: FREQ_F4 con 698: FREQ_F5 con 1397: FREQ_F6 con 2794
FREQ_Gb0 con 46: FREQ_Gb1 con 92: FREQ_Gb2 con 185: FREQ_Gb3 con 370: FREQ_Gb4 con 740: FREQ_Gb5 con 1480: FREQ_Gb6 con 2960
FREQ_G0 con 49: FREQ_G1 con 98: FREQ_G2 con 196: FREQ_G3 con 392: FREQ_G4 con 784: FREQ_G5 con 1568: FREQ_G6 con 3136
FREQ_Ab0 con 52: FREQ_Ab1 con 104: FREQ_Ab2 con 208: FREQ_Ab3 con 415: FREQ_Ab4 con 831: FREQ_Ab5 con 1661: FREQ_Ab6 con 3322

;--------------------------------------------------------------------
;[Song Defs]

FurElise wordtable | ;
8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_B4, 8,FREQ_D5, 8,FREQ_C5, 4,FREQ_A4, 8,0, |
8,FREQ_C4, 8,FREQ_E4, 8,FREQ_A4, 4,FREQ_B4, 8,0, 8,FREQ_E4, 8,FREQ_Ab4, 8,FREQ_B4, 4,FREQ_C5, 8,0, 8,FREQ_E4,|
8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_B4, 8,FREQ_D5, 8,FREQ_C5, 4,FREQ_A4, 8,0, 8,FREQ_C4, |
8,FREQ_E4, 8,FREQ_A4, 4,FREQ_B4, 8,0, 8,FREQ_E4, 8,FREQ_C5, 8,FREQ_B4, 4,FREQ_A4, |
0, 0

Mozart wordtable |
16,FREQ_Gb4, 16,FREQ_E4, 16,FREQ_Eb4, 16,FREQ_E4, 4,FREQ_G4, 16,FREQ_A4, 16,FREQ_G4, 16,FREQ_Gb4, 16,FREQ_G4, |
4,FREQ_B4, 16,FREQ_C5, 16,FREQ_B4, 16,FREQ_Bb4, 16,FREQ_B4, 16,FREQ_Gb5, 16,FREQ_E5, 16,FREQ_Eb5, 16,FREQ_E5, |
16,FREQ_Gb5, 16,FREQ_E5, 16,FREQ_Eb5, 16,FREQ_E5, 4,FREQ_G5, 8,FREQ_E5, 8,FREQ_G5, 32,FREQ_D5, 32,FREQ_E5, |
16,FREQ_Gb5, 8,FREQ_E5, 8,FREQ_D5, 8,FREQ_E5, 32,FREQ_D5, 32,FREQ_E5, 16,FREQ_Gb5, 8,FREQ_E5, 8,FREQ_D5, 8,FREQ_E5, |
32,FREQ_D5, 32,FREQ_E5, 16,FREQ_Gb5, 8,FREQ_E5, 8,FREQ_D5, 8,FREQ_Db5, 4,FREQ_B4, |
0, 1

;====================================================================
;Interrupt init
;====================================================================
;[INIT]

;PS2 controller
input p4
input p5
input p6

sound P9,[100\5000, 100\4500, 100\4000]

;====================================================================
;[MAIN]
main:

prevA = buttonA
prevB = buttonB
prevC = buttonC

buttonA = in4	; BUGBUG for BB2 12-14
buttonB = in5
buttonC = in6

if (buttonA = 0) AND (prevA = 1) then
	gosub PlayASong@FurElise]
endif
if (buttonB = 0) AND (prevB = 1) then
	gosub PlayASong@Mozart]
endif

pause 100

goto main

;--------------------------------------------------------------------
;[PlayASong] - takes the pointer as a set of times and notes and runs
; them on the spaker
SongPtr var pointer
Dur var word
Note var word

PlayASong [SongPtr]:

; serout s_out, i9600, “Song: “, hex songPtr, 13]
; See if Pointer properly uses the type information to increment
while @SongPtr
Dur = @SongPtr * 16 ; scale it up
SongPtr = SongPtr + 2 ; Ok it does not scale the add
Note = @SongPtr
SongPtr = SongPtr + 2 ; Ok it does not scale the add
; Serout s_out, i9600, “P:”, hex SongPtr, " D:”, dec dur, " N:”, dec Note, 13]
Sound P9, [Dur\Note]
wend

return
	[/code]

P.S - I tried this using the Pointer variable. Took a few attempts as I was not sure if adding to a pointer variable would scale the addition to size of what is in it (It does not). Also tried using the pointer with array index numbers and did not get what I expected… but you can ignore all of that.

Ow wow, this will keep me busy for days! that’s good!! :smiley:

But how did you generate the frequency code?

When I was working on the SRS board and writting my own set of functions for the expansion board which included a speaker. Cathy Saxton, the person who developed this board sent me an excel spreadsheet that had frequencies on it, which included data like:

[code]Frequencies
A 28 55 110 220 440 880 1760
A#/Bb 29 58 117 233 466 932 1865
B 31 62 123 247 494 988 1976 x^12=2
C 33 65 131 262 523 1047 2093 logx(2) = 12
C#/Db 35 69 139 277 554 1109 2217 log2/logx = 12
D 37 73 147 294 587 1175 2349 logx=log2/12
D#/Eb 39 78 156 311 622 1245 2489 10^(log2/12) = x
E 41 82 165 330 659 1319 2637 0.025085833
F 44 87 175 349 698 1397 2794 1.059463094
F#/Gb 46 92 185 370 740 1480 2960
G 49 98 196 392 784 1568 3136
G#/Ab 52 104 208 415 831 1661 3322

Mary...					1812				
EDCDEEEDDDEGGEDCDEEEEDDEDC					BbEbFGFEbFG Eb Eb				

[/code]
The spreadsheet included additional information, like if you should divide the system clock by different divisors, what are the clock counts for each of the notes, such that you can pick a good setup… Not needed here as I let the basic handle this for me with the sound command…

Some of the sounds were derived from the AVR butterfly test board, which was a pin you could wear with a button on it and an LCD display… This was a fun little cheap board you could reprogram and the like.

Kurt

ah i have the same excel sheet lying around here.

And with the chip you talked about. Do i only need the chip or do i need a board with that?

The chip is only 16 dollars. that is do-able.

By the way. I am using a power supply of 5V at the moment. If i upgrade it to a 6V one, will the torque increase?

The code I posted, works with the little speaker on the BB2. But if you still want your robot to talk, I would look into that speakerjet. You should look at some of the threads of SN96 where if I remember correctly he has designed his own add on boards with this.

Kurt

Not sure what chip you are talking about. If you are talking about the speakjet, it cost $25.00 and no, you do not need a board to use the chip. You will need, however, a bread board, a few caps and a LM386 if you want to hear the sounds nice and loud. If you prefer to use the chip without the extra components, you can wire up a speaker directly to the SJ chip and short the appropriate pins using jumper wire. This configuration will play sounds very softly but it will work.

thanx i will buy one! Is there a toturial about it that you know is any good?