Ok I have looked at the C++ stuff and thought that would take me a very long time to do... so I decided to try it with memblocks in dbpro first. here is the code for the program... don't know if it works I just did it and since it is night time over here I would not want to do any recording. I will test this out tomorrow, but try it out yourselves if there is a bug I will edit the code (on the post also). Lol I might of made a mistake with reading the memblocks with bytes (that's my thought).
code:
sync on : sync rate 60
dim compare(500)
dim compare2(500)
load sound "hello.wav",1
sync : text 100,100,"press key to record"
wait key
record sound 2,500
do
sync
print "RECORDING NOW!"
if mouseclick()=1
stop recording sound
goto con
endif
loop
print "RECORDING STOPPED" : sync
con:
make memblock from sound 1,1
make memblock from sound 2,2
make object sphere 1,10
set ambient light 300
percent = 0
do
if upkey() = 1 then a = a + 1
if downkey() = 1 then a = a - a
if a < get memblock size(1) then aa = memblock byte(1,a)
if a < get memblock size(2) then bb = memblock byte(2,a)
if keystate(2)=1
gosub compare_sounds_1
wait 1000
endif
if keystate(3)=1
gosub compare_sounds_2
wait 1000
endif
print percent
sync
print "aa: ",aa
print "bb: ",bb
if a < 500 then print "compare array: ",compare(a)
if a < 500 then print "compare2 array: ",compare2(a)
wait 500
loop
compare_sounds_1:
a_size = get memblock size(1)
b_size = get memblock size(2)
if a_size > b_size
for x=1 to (a_size - 1)
byte_a = memblock byte(1,x)
if x < b_size
byte_b = memblock byte(2,x)
endif
if byte_a > (byte_b - 1) and byte_a < (byte_b + 1)
chance = chance + 1
endif
next
endif
if b_size > a_size
for x=1 to (b_size - 1)
byte_b = memblock byte(2,x)
if x < a_size
byte_a = memblock byte(1,x)
endif
if byte_a > (byte_b - 1) and byte_a < (byte_b + 1)
chance = chance + 1
endif
next
endif
if a_size > b_size
percent = (chance / a_size) * 100
else
percent = (chance / b_size) * 100
endif
return
compare_sounds_2:
if file exist("command.wav")=1
delete file "command.wav"
endif
save sound "command.wav",2
open to read 1,"hello.wav"
for i=1 to 500
read byte 1,compare(i)
next i
close file 1
open to read 1,"command.wav"
for i=1 to 500
read byte 1,compare2(i)
next i
return
Ohh and chris this code is just like your idea, maybe slightly different.
edit: about the code! you need a sound file called hello.wav, which is the same word and recording duration as the word you are about to say. when you press a key to continue just say the word and wait. there should be a 0 printed on the screen, now you press key 1 to get a percentage of how similar they are. This might work fine or really bad, but I suspect the accuracy to be bad.
*another thought is you could have one massive sound file (that has 1000's of words with spaces between them) that could be scanned once with the small sound file to be scanned many times. get what I am saying?
*yet another edit: I have added a second method of comparing to sounds file using arrays which tend to be a lot more accurate!
sov the game creator!