Code archives/User Input/Speech input for Blitz!
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Grab your microphone - Blitz input will never be the same again! Requires the Speech libs from Microsoft ( Search www.microsoft.com for SAPI 5.1 ) Download the zipped userlib with examples at www.binary-people.com/downloads/simplespeech.zip | |||||
Examples of use.... ;training Text 10,440,"repeat the words when prompted" If VoiceInit()=0 Then End EndIf Type word Field original$ Field id End Type Type altword Field id Field alt$ Field hits End Type makeword("up",0) makeword("down",1) makeword("left",2) makeword("right",3) makeword("blue",4) makeword("red",5) makeword("clear",6) makeword("green",7) makeword("stop",8) makeword("quit",9) maxword=9 While True For wd.word=Each word If wd\id=iword Then Exit EndIf Next Cls Color 255,255,255 Text 10,10,"Please say " + wd\original icount = 2 For fd.altword = Each altword If fd\id=wd\id Then Text 10,icount*20,fd\alt + " - " + fd\hits icount=icount+1 EndIf Next Delay 100 a$="" If VoiceBlockForResult()=1 Then a$ = Lower(VoiceTestBlock()) EndIf If a$="" Then ;Stop Else found=False For tw.altword=Each altword If tw\id=iword And tw\alt=a$ Then tw\hits=tw\hits+1 found=True EndIf Next If found=False Then aw.altword = New altword aw\id =iword aw\alt= a$ EndIf iword=iword+1 If iword>maxword Then iword=0 EndIf Delay 10 If GetKey()<>0 Then savewordlist() VoiceShutdown End EndIf Wend End Function makeword(thisword$,id) a.word=New word a\original=thisword a\id=id End Function Function savewordlist() file=WriteFile ("word.txt") For wd.word = Each word ;save the word setcion header WriteLine file,"#" WriteLine file,wd\id WriteLine file,wd\original For aw.altword=Each altword ;save each alternative If aw\id = wd\id Then WriteLine file,aw\alt EndIf Next Next WriteLine file,"#" CloseFile file End Function ;;simple drawing snake game thing.... Graphics 640,480,0,2 x=160 y=120 Color 255,255,255 R=255 g=0 b=0 Text 10,10,"initializing..." If VoiceInit()=0 Then End EndIf loadwordlist() Rect x,y,10,10,True ;VoiceSay("Welcome to speech draw 1") test=True aa$="say something" While test If VoiceBlockForResult()=1 Then a$ = VoiceTestBlock() aa$ = a$ Else a$="" EndIf Color 255,255,255 ;Text 10,10,icount Color 0,0,0 Rect 0,350,120,420,1 Color 255,255,255 Text 10,400,aa$ ;Delay 1000 thisid=getwordid(aa$) Select thisid;Lower(a$) Case 0;"up","a","cop" dir=1 Case 1;"down" dir=3 Case 2;"left" dir=4 Case 3;"right" dir=2 Case 5 r=255 g=0 b=0 Case 4 r=0 g=0 b=255 Case 7 r=0 g=255 b=0 Case 8 dir=0 Case 9 Print "finishing up" VoiceShutdown() End End Select If GetKey()<>0 Print "finishing up" VoiceShutdown() End EndIf Select dir Case 1 y=y-1 Case 2 x=x+1 Case 3 y=y+1 Case 4 x=x-1 End Select Color r,g,b Rect x,y,10,10,True icount=icount + 1 Text 10,40,"up,down,left,right,blue," Text 10,60,"red,green,clear,stop,quit" fade(True,0,1,0,0) Delay 1 If KeyHit(1) Then test=False Wend VoiceShutdown() End Function fade(fadein=False,pause=0,inc=10,xpos=0,ypos=0) ;image1=image to fade in or out ;fadein(default false) - is image to fade in or out? ;pause= delay between frames ;inc= how many colour points to jump per frame ;x and y pos are position of image ; setup limits etc ; ti=CopyImage (image1) wd=320;ImageWidth(ti) ht=256;ImageHeight(ti) ; For icount=0 To 255/inc ;fade an image out to black SetBuffer FrontBuffer();ImageBuffer(ti) LockBuffer FrontBuffer();ImageBuffer(ti) For x=0 To wd-1 For y=0 To ht-1 ;fade pixels to black argb=ReadPixelFast (x,y,FrontBuffer());ImageBuffer(ti)) tr=(argb Shr 16) And $ff tg=(argb Shr 8) And $ff tb=argb And $ff tr=tr - inc tg=tg - inc tb=tb - inc If tr<0 Then tr=0 If tg<0 Then tg=0 If tb<0 Then tb=0 newargb=((tr Shl 16) Or (tg Shl 8) Or tb) WritePixelFast x,y,newargb,FrontBuffer();ImageBuffer(ti) Next Next UnlockBuffer FrontBuffer();ImageBuffer(ti) SetBuffer FrontBuffer() ; Cls ; DrawImage ti,xpos,ypos ; Flip ; Delay pause ; Next ; FreeImage ti ; ti=0 End Function Type word Field original$ Field id End Type Type altword Field id Field alt$ Field hits End Type Function getwordid(a$) a$=Lower(a$) For wd.word=Each word If wd\original = a$ Return wd\id EndIf Next For tw.altword=Each altword If tw\alt=a$ Then Return tw\id EndIf Next Return -1 End Function Function loadwordlist() file=ReadFile ("word.txt") temp$=ReadLine(file) While Not Eof(file) If temp$="#" ;start new word wd.word=New word wd\id=ReadLine (file) wd\original=ReadLine(file) temp="" Repeat ;add all alt words temp$=ReadLine(file) td.altword=New altword td\id=wd\id td\alt=temp Until temp$="#" EndIf Wend CloseFile file End Function |
Comments
| ||
Sounds great ... but wich files i need (Requires the Speech libs from Microsoft) to run it ? |
| ||
This is awesome, thanks dude |
| ||
you can find the files from the M$ website at... www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en I used the 70mb download but I needed this to create the userlib, there's an msi installation file but I don't know how to use it OR get it into an install for use by another person. Any light anyone can shed on this would be great :) Also, in the control panel if you go to speech and train your machine to understand your voice (until you get sick of it) you'll find the userlib works much better. |
| ||
Wohoo ... this is fun ... thanks a lot. Well, my english must sound awfull ... cause the litle dot does everything except what i told him to do :-) |
| ||
Here's the deal with the little dot app. Run the training one through about 5 times for each word (it repeats) then hit a key (not [esc]), this saves a list of all the words the speech userlib 'thinks' you said while saying the words that flashed on screen. When you run the snakey dot thing (in the same dir) it maps what you say to those words like a lookup - making the snake respond better the longer you train it :) Hope that helps. |
| ||
well, i know Did you know what those .msm files for ? ... this installation file of the speech sdk is english language only i think. Is there a way to use this for other languages too ? |
| ||
I think there's language packs on that Microsoft page, not sure though. |
| ||
Jay Mattis updated this in the forum, here's what he said... Ok, I added commands to the library. VoiceInit now takes a string. If you run VoiceInit("") it will run just like the original version. Otherwise, you need to pass the filepath to your commandset. SAPI has an XML standard for writing in new commands and phrases and whatnot. Search the internet. So, write your XML file and then use gc.exe provided with the SAPI SDK to compile your XML to a CFG file. Then use VoiceInit like this: VoiceInit("C:\mycommands.cfg") and it will load your commands instead of the universal dictionary. Have fun! www.cowgames.com/sapiuserlib.zip |
| ||
Blitz says there is two type word and type wordinti |
| ||
What is the file called that you need to download? |
| ||
Until I see an idiot's (and I mean PROPER I D I O T ) and a fully working example, Ive given up - the only reminder I have of this functionality is ctfmon running on startup everytime! |
| ||
Hey, this would work great for a feature in a sci-fi space flight game (which I just so happen to be planning) if it is what I think it is. You could talk to your ship like in Star Trek and tell it to adjust shields, or divert power to weapons, etc. If it was for a purposefully cheezy one, then the voice recognition would be even better because of its common failure rate unless properly calibrated. That would save people who don't like memorizing controls a bit of time! I also just thought of how this could help people with lip syncronization, even if it gets the words wrong. So, very handy dll, thank you. And it looks like microsoft has once again proven to actually be quite generous (if you ignore the very frghteningly confusing license). |
| ||
Whats the deal with using this in our projects, freeware, commercial, not at all cos of M$ and the SAM licence...? |
| ||
The binary-people link doesn't work anyone have an idea on how to make the userlibs??? Someone help me please! |
| ||
The binary-people link doesn't work anyone have an idea on how to make the userlibs??? Someone help me please! |
| ||
same here ! |
| ||
It didn't really work properly even when the link wasn't dead. Would have been nice though... |
| ||
someone still got the files? please upload or send me to hunulullu{at}gmx{dot]de |
| ||
Try "So To Speak" by semar, it's written in BlitzPlus and uses a DLL made by Metalman. I'm not sure but it's probably compatible with Blitz3D. Download the exe, dll and complete source code here: http://www.sergiomarcello.com/so_to_speak/so_to_speak.html Edit: for speech input I think you can use MSAgent. |
| ||
www.binary-people.com/downloads/simplespeech.zip www.cowgames.com/sapiuserlib.zip Hi, Dead links :( Someone has these files? Malice? Picklesworth? Please send me to zjp@... JP |
| ||
I'm not sure, I didn't get very far with this and have re-installed don't know how many times since... I'll have a look for you, ZJP... Okay, sent... let me know that you received them okay, my email client likes to remove attachments :) |
| ||
Hi, Receive ok. The .decls is "empty" :( Thx a lot. ;) JP |
| ||
yes, i need them too mate. why not upload to http://mediafire.com |
| ||
i have located the sdk file: http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en#filelist what dll and where to get the decls, idk.. |
| ||
does anyone have the files for this? |
| ||
can someone please post the files for this? |
| ||
Send Malice an email. |
| ||
As ZJP states, and as I didn't know prior to his response here, the decls file I had is empty. :( The dll itself should be available with windows or via Microsoft as part of their TTS and SAPI systems. |
| ||
Can someone crack into the dll w/ a dll viewer, and re-create the decls file? |
| ||
anyone? |
| ||
All links are dead! Available for download only "speech synthesis" Can someone upload files, mentioned in the beginning of the theme? Sorry 4 my english) |
| ||
. |
| ||
Does anyone still have this zip file? |
| ||
After two years of begging, i would assume not. |
| ||
I'm pretty sure someone does. |
| ||
Well, have fun, then. |
| ||
Indeed I will :) |
Code Archives Forum