July 27, 2021, 23:18:10

Author Topic: [bb] Speech input for Blitz! by Beeps [ 1+ years ago ]  (Read 881 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Speech input for Blitz! by Beeps [ 1+ years ago ]
« on: June 29, 2017, 00:28:39 »
Title : Speech input for Blitz!
Author : Beeps
Posted : 1+ years ago

Description : 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


Code :
Code: BlitzBasic
  1. Examples of use....
  2.  
  3. ;training
  4.  
  5. Text 10,440,"repeat the words when prompted"
  6.  
  7. If VoiceInit()=0 Then
  8.    End
  9. EndIf
  10.  
  11. Type word
  12.    Field original$
  13.    Field id
  14. End Type
  15.  
  16. Type altword
  17.    Field id
  18.    Field alt$
  19.    Field hits
  20. End Type
  21.  
  22. makeword("up",0)
  23. makeword("down",1)
  24. makeword("left",2)
  25. makeword("right",3)
  26. makeword("blue",4)
  27. makeword("red",5)
  28. makeword("clear",6)
  29. makeword("green",7)
  30. makeword("stop",8)
  31. makeword("quit",9)
  32.  
  33. maxword=9
  34.  
  35. While True
  36.    
  37.    For wd.word=Each word
  38.       If wdid=iword Then
  39.          Exit
  40.       EndIf
  41.    Next
  42.    Cls
  43.    Color 255,255,255
  44.    Text 10,10,"Please say " + wdoriginal
  45.    icount = 2
  46.    For fd.altword = Each altword
  47.       If fdid=wdid Then
  48.          Text 10,icount*20,fdalt + " - " + fdhits
  49.          icount=icount+1
  50.       EndIf
  51.    Next
  52.    
  53.    Delay 100
  54.    a$=""
  55.    If VoiceBlockForResult()=1 Then
  56.       a$ = Lower(VoiceTestBlock())
  57.    EndIf
  58.    
  59.    If a$="" Then
  60.       ;Stop
  61.    Else
  62.       found=False
  63.       For tw.altword=Each altword
  64.          If twid=iword And twalt=a$ Then
  65.             twhits=twhits+1
  66.             found=True
  67.          EndIf
  68.       Next
  69.       If found=False Then
  70.          aw.altword = New altword
  71.          awid =iword
  72.          awalt= a$
  73.       EndIf
  74.       iword=iword+1
  75.       If iword>maxword Then iword=0
  76.    EndIf
  77.  
  78.    Delay 10
  79.    
  80.    If GetKey()<>0 Then
  81.       savewordlist()
  82.       VoiceShutdown
  83.       End
  84.    EndIf
  85. Wend
  86.  
  87. End
  88.  
  89. Function makeword(thisword$,id)
  90.    a.word=New word
  91.    aoriginal=thisword
  92.    aid=id
  93. End Function
  94.  
  95. Function savewordlist()
  96.    file=WriteFile ("word.txt")
  97.    For wd.word = Each word
  98.       ;save the word setcion header
  99.       WriteLine file,"#"
  100.       WriteLine file,wdid
  101.       WriteLine file,wdoriginal
  102.       For aw.altword=Each altword
  103.          ;save each alternative
  104.          If awid = wdid Then
  105.             WriteLine file,awalt
  106.          EndIf
  107.       Next
  108.    Next
  109.    WriteLine file,"#"
  110.  
  111.    CloseFile file
  112. End Function
  113.  
  114.  
  115.  
  116. ;;simple drawing snake game thing....
  117.  
  118. Graphics 640,480,0,2
  119.  
  120. x=160
  121. y=120
  122.  
  123. Color 255,255,255
  124.  
  125. R=255
  126. g=0
  127. b=0
  128.  
  129. Text 10,10,"initializing..."
  130. If VoiceInit()=0 Then
  131.    End
  132. EndIf
  133.  
  134. loadwordlist()
  135.  
  136. Rect x,y,10,10,True
  137.  
  138. ;VoiceSay("Welcome to speech draw 1")
  139.  
  140. test=True
  141. aa$="say something"
  142. While test
  143.  
  144.    
  145.    If VoiceBlockForResult()=1 Then
  146.       a$ = VoiceTestBlock()
  147.       aa$ = a$
  148.    Else
  149.       a$=""
  150.    EndIf
  151.    
  152.    Color 255,255,255
  153.    ;Text 10,10,icount
  154.    Color 0,0,0
  155.    Rect 0,350,120,420,1
  156.    Color 255,255,255
  157.    Text 10,400,aa$
  158.    ;Delay 1000
  159.    
  160.    thisid=getwordid(aa$)
  161.    Select thisid;Lower(a$)
  162.       Case 0;"up","a","cop"
  163.          dir=1
  164.       Case 1;"down"
  165.          dir=3
  166.       Case 2;"left"
  167.          dir=4
  168.       Case 3;"right"
  169.          dir=2
  170.       Case 5
  171.          r=255
  172.          g=0
  173.          b=0
  174.       Case 4
  175.          r=0
  176.          g=0
  177.          b=255
  178.       Case 7
  179.          r=0
  180.          g=255
  181.          b=0
  182.       Case 8
  183.          dir=0
  184.       Case 9
  185.          Print "finishing up"
  186.          VoiceShutdown()
  187.          
  188.          End
  189.    End Select
  190.    
  191.    If GetKey()<>0
  192.       Print "finishing up"
  193.          
  194.          VoiceShutdown()
  195.          End
  196.    EndIf
  197.    
  198.    Select dir
  199.       Case 1
  200.          y=y-1
  201.       Case 2
  202.          x=x+1
  203.       Case 3
  204.          y=y+1
  205.       Case 4
  206.          x=x-1
  207.    End Select
  208.    
  209.    Color r,g,b
  210.    Rect x,y,10,10,True
  211.    icount=icount + 1
  212.    Text 10,40,"up,down,left,right,blue,"
  213.    Text 10,60,"red,green,clear,stop,quit"
  214.    fade(True,0,1,0,0)
  215.    Delay 1
  216.    
  217.    If KeyHit(1) Then test=False
  218. Wend
  219.  
  220. VoiceShutdown()
  221.  
  222. End
  223.  
  224.  
  225. Function fade(fadein=False,pause=0,inc=10,xpos=0,ypos=0)
  226.    ;image1=image to fade in or out
  227.    ;fadein(default false) - is image to fade in or out?
  228.    ;pause= delay between frames
  229.    ;inc= how many colour points to jump per frame
  230.    ;x and y pos are position of image
  231.  
  232. ;   setup limits etc
  233. ;   ti=CopyImage (image1)
  234.    wd=320;ImageWidth(ti)
  235.    ht=256;ImageHeight(ti)
  236.    
  237.    
  238. ;   For icount=0 To 255/inc
  239.    ;fade an image out to black      
  240.       SetBuffer FrontBuffer();ImageBuffer(ti)
  241.       LockBuffer FrontBuffer();ImageBuffer(ti)
  242.       For x=0 To wd-1
  243.          For y=0 To ht-1
  244.             ;fade pixels to black
  245.             argb=ReadPixelFast (x,y,FrontBuffer());ImageBuffer(ti))
  246.              
  247.             tr=(argb Shr 16) And $ff
  248.             tg=(argb Shr 8) And $ff
  249.             tb=argb And $ff
  250.              
  251.             tr=tr - inc
  252.             tg=tg - inc
  253.             tb=tb - inc
  254.              
  255.             If tr<0 Then tr=0
  256.              
  257.             If tg<0 Then tg=0
  258.              
  259.             If tb<0 Then tb=0
  260.              
  261.             newargb=((tr Shl 16) Or (tg Shl 8) Or tb)
  262.    
  263.             WritePixelFast x,y,newargb,FrontBuffer();ImageBuffer(ti)
  264.          Next
  265.       Next
  266.       UnlockBuffer FrontBuffer();ImageBuffer(ti)
  267.        
  268.       SetBuffer FrontBuffer()
  269. ;      Cls
  270. ;      DrawImage ti,xpos,ypos
  271. ;      Flip
  272. ;      Delay pause
  273. ;   Next
  274.    
  275. ;   FreeImage ti
  276. ;   ti=0
  277. End Function
  278.  
  279.  
  280. Type word
  281.    Field original$
  282.    Field id
  283. End Type
  284.  
  285. Type altword
  286.    Field id
  287.    Field alt$
  288.    Field hits
  289. End Type
  290.  
  291.  
  292. Function getwordid(a$)
  293.    a$=Lower(a$)
  294.    For wd.word=Each word
  295.       If wdoriginal = a$
  296.          Return wdid
  297.       EndIf
  298.    Next
  299.    
  300.    For tw.altword=Each altword
  301.       If twalt=a$ Then
  302.          Return twid
  303.       EndIf
  304.    Next
  305.    Return -1
  306. End Function
  307.  
  308. Function loadwordlist()
  309.    file=ReadFile ("word.txt")
  310.  
  311.    temp$=ReadLine(file)
  312.    
  313.    While Not Eof(file)
  314.       If temp$="#"
  315.          ;start new word
  316.          wd.word=New word
  317.          wdid=ReadLine (file)
  318.          wdoriginal=ReadLine(file)
  319.          temp=""
  320.          
  321.          Repeat
  322.             ;add all alt words
  323.             temp$=ReadLine(file)
  324.             td.altword=New altword
  325.             tdid=wdid
  326.             tdalt=temp
  327.          
  328.          Until temp$="#"    
  329.       EndIf
  330.    Wend
  331.  
  332.    CloseFile file
  333. End Function


Comments :


Klaas(Posted 1+ years ago)

 Sounds great ... but wich files i need (Requires the Speech libs from Microsoft) to run it ?


xmlspy(Posted 1+ years ago)

 This is awesome, thanks dude


Beeps(Posted 1+ years ago)

 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.


Klaas(Posted 1+ years ago)

 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 :-)


Beeps(Posted 1+ years ago)

 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.


Klaas(Posted 1+ years ago)

 well, i knowDid 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 ?


Beeps(Posted 1+ years ago)

 I think there's language packs on that Microsoft page, not sure though.


Beeps(Posted 1+ years ago)

 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


asdfasdf(Posted 1+ years ago)

 Blitz says there is two type word and type wordinti


asdfasdf(Posted 1+ years ago)

 What is the file called that you need to download?


_PJ_(Posted 1+ years ago)

 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!


Picklesworth(Posted 1+ years ago)

 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).


.rIKmAN.(Posted 1+ years ago)

 Whats the deal with using this in our projects, freeware, commercial, not at all cos of M$ and the SAM licence...?


Ked(Posted 1+ years ago)

 The binary-people link doesn't work anyone have an idea onhow to make the userlibs??? Someone help me please!


Compt-Man(Posted 1+ years ago)

 The binary-people link doesn't work anyone have an idea onhow to make the userlibs??? Someone help me please!


Panno(Posted 1+ years ago)

 same here !


Matty(Posted 1+ years ago)

 It didn't really work properly even when the link wasn't dead.  Would have been nice though...


hunulullu(Posted 1+ years ago)

 someone still got the files?please upload or send me to hunulullu{at}gmx{dot]de


markcw(Posted 1+ years ago)

 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:<a href="http://www.sergiomarcello.com/so_to_speak/so_to_speak.html" target="_blank">http://www.sergiomarcello.com/so_to_speak/so_to_speak.html[/url]Edit: for speech input I think you can use MSAgent.


ZJP(Posted 1+ years ago)

 
Code: [Select]
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


_PJ_(Posted 1+ years ago)

 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 :)


ZJP(Posted 1+ years ago)

 Hi,Receive ok. The .decls is "empty" :(Thx a lot. ;)JP


Guy Fawkes(Posted 1+ years ago)

 yes, i need them too mate. why not upload to <a href="http://mediafire.com/" target="_blank">http://mediafire.com[/url]


Guy Fawkes(Posted 1+ years ago)

 i have located the sdk file: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en#filelist" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en#filelist[/url]what dll and where to get the decls, idk..


Guy Fawkes(Posted 1+ years ago)

 does anyone have the files for this?


Guy Fawkes(Posted 1+ years ago)

 can someone please post the files for this?


markcw(Posted 1+ years ago)

 Send Malice an email.


_PJ_(Posted 1+ years ago)

 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.


Guy Fawkes(Posted 1+ years ago)

 Can someone crack into the dll w/ a dll viewer, and re-create the decls file?


Guy Fawkes(Posted 1+ years ago)

 anyone?


impersonalis(Posted 1+ years ago)

 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)


Guy Fawkes(Posted 1+ years ago)

 .


Guy Fawkes(Posted 1+ years ago)

 Does anyone still have this zip file?


GfK(Posted 1+ years ago)

 After two years of begging, i would assume not.


Guy Fawkes(Posted 1+ years ago)

 I'm pretty sure someone does.


GfK(Posted 1+ years ago)

 Well, have fun, then.


Guy Fawkes(Posted 1+ years ago)

 Indeed I will :) [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal