News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Voice recognition code

Started by Magnum, December 11, 2011, 12:21:03 AM

Previous topic - Next topic

Magnum

There are a few voice recognition samples here, but this is the shortest if you don't count the Constants.

Can someone test this on Win 7.

Would it work on Win 95 - XP ?


; SpVoice Simple example  By G-Spider 2010

.586
.model flat,stdcall
option casemap:none
  include /masm32/include/windows.inc
  include /masm32/include/kernel32.inc
  include /masm32/include/user32.inc
  include /masm32/include/ole32.inc

  includelib /masm32/lib/kernel32.lib
  includelib /masm32/lib/user32.lib
  includelib /masm32/lib/ole32.lib

.data

TEXT    dw 'M','e','r','r','y',' ','C','h','r','i','s','t','m','a','s',' ','t','o',' ','e','v','e','r','y','o','n','e','.',0

.data?

lpSpVoiceCOM    dd ?

.const

CLSID_SpVoice GUID <096749377h, 03391h, 011D2h, <09Eh, 0E3h, 000h, 0C0h, 04Fh, 079h, 073h, 096h>>
IID_ISpVoice  GUID <06C44DF74h, 072B9h, 04992h, <0A1h, 0ECh, 0EFh, 099h, 06Eh, 004h, 022h, 0D4h>>

ISpNotifySource  STRUCT
SetNotifySink              DWORD   ?
SetNotifyWindowMessage     DWORD   ?
SetNotifyCallbackFunction  DWORD   ?
SetNotifyCallbackInterface DWORD   ?
SetNotifyWin32Event        DWORD   ?
WaitForNotifyEvent         DWORD   ?
GetNotifyEventHandle       DWORD   ?

ISpNotifySource  ENDS

ISpEventSource  STRUCT
SpNotifySource      ISpNotifySource   <>
SetInterest         DWORD   ?
GetEvents           DWORD   ?
GetInfo             DWORD   ?
ISpEventSource  ENDS

ISpVoiceVtbl        STRUCT
; IUnknown methods
QueryInterface       DWORD   ?
AddRef               DWORD   ?
Release              DWORD   ?
SpEventSource        ISpEventSource   <>
SetOutput            DWORD   ?
GetOutputObjectToken DWORD   ?
GetOutputStream      DWORD   ?
_Pause               DWORD   ?
Resume               DWORD   ?
SetVoice             DWORD   ?
GetVoice             DWORD   ?
Speak                DWORD   ?
SpeakStream          DWORD   ?
GetStatus            DWORD   ?
Skip                 DWORD   ?
SetPriority          DWORD   ?
GetPriority          DWORD   ?
SetAlertBoundary     DWORD   ?
GetAlertBoundary     DWORD   ?
SetRate              DWORD   ?
GetRate              DWORD   ?
SetVolume            DWORD   ?
GetVolume            DWORD   ?
WaitUntilDone        DWORD   ?
SetSyncSpeakTimeout  DWORD   ?
GetSyncSpeakTimeout  DWORD   ?
SpeakCompleteEvent   DWORD   ?
IsUISupported        DWORD   ?
DisplayUI            DWORD   ?
ISpVoiceVtbl ENDS

ISpVoice    STRUCT
   lpVtbl            DWORD   ?
ISpVoice   ENDS

.code

start:

   invoke CoInitialize,0
   invoke CoCreateInstance,offset CLSID_SpVoice, 0,CLSCTX_INPROC_SERVER, offset IID_ISpVoice,offset lpSpVoiceCOM

   .if eax == 0   

       push 100   ;USHORT Volume0~100
       mov eax,lpSpVoiceCOM
       push eax   ;<===Note!
       mov eax,[eax]
       call [eax].ISpVoiceVtbl.SetVolume

       ;lpSpVoiceCOM->Speak(L"Golden Spider", 0, 0)//; c++
       ;lpSpVoiceCOM->lpVtbl->Speak(lpSpVoiceCOM,L"I LOVE YOU!", 0, 0)//; pure c

       push 0
       push 0
       push offset TEXT
       mov eax,lpSpVoiceCOM
       push eax   
       mov eax,[eax].ISpVoice.lpVtbl  ;equ  mov eax,[eax]     
       call [eax].ISpVoiceVtbl.Speak  ;call DWORD PTR[eax+50h]
       
       mov eax,lpSpVoiceCOM
       push eax
       mov eax,[eax]
       call [eax].ISpVoiceVtbl.SpEventSource.SpNotifySource.SetNotifyWin32Event
   
       ;// release ISpVoice COM interfaces
       ;lpSpVoiceCOM->lpVtbl->Release(lpSpVoiceCOM)

       mov eax,lpSpVoiceCOM
       push eax
       mov eax,[eax]
       call [eax].ISpVoiceVtbl.Release
       
       mov  lpSpVoiceCOM,0
   .endif
   
    invoke   CoUninitialize
   
invoke ExitProcess,0

end start
Have a great day,
                         Andy

jj2007


bomz

voice recognition - I am shocked.
This is voice text reader, with using windows Text-to-speech engine

I have already acronis backup of Windows NT4.0, Windows 98, Windows 2000 and Windows 7. but it's a long story . It's better to read have it text-to-speech engine or not

You may always put dll from XP near your application

Here Russian fun club of Windows 98 you may ask to try your code
http://forum.ru-board.com/topic.cgi?forum=62&topic=21298&start=2380
Here Windows NT 4. but there is no user. It's rarely used for server
http://forum.ru-board.com/topic.cgi?forum=35&bm=1&topic=3631&start=200#lt

MichaelW

Under Windows 2000 CoCreateInstance returns 80040154h, REGDB_E_CLASSNOTREG (Class not registered).

eschew obfuscation

bomz

QuoteUnder Windows 2000
no need go low - 98,  NT, 95
put ole32.dll in application directory http://zalil.ru/32245213
there is many alternative text-to-speech engines which know different languages and have man and woman voices

MichaelW

Under Windows 2000 I solved the problem by installing Microsoft Speech SDK 5.1
eschew obfuscation

jj2007

Quote from: bomz on December 11, 2011, 01:16:07 AM
voice recognition - I am shocked.

Me too, but you are right it's TTS. What worries me more is that I can't get any Lernout & Hauspie voices to work. They don't appear in the Control Panel speech options. Just Microsoft Sam & Mike & Mary.

L&H is SAPI 4, that might be the problem. Fully incompatible with 5.1...

Magnum

I am currently downloading the package that contains M.S. Mary's voice since I run XP.

Microsoft Larry's voice ain't cutting it, it sounds like the one that the old Soundblaster boards used to use.

I hope I can get it to work.

A lot of times it's a BIG production given Microsoft terse documentation.  :bdg

I don't have a speech icon in Control Panel, is that something that started with Vista ?
Have a great day,
                         Andy

sinsi

Works OK in win7 pro x64 and win8 preview x64.
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

Andy,

My Windows 2000 has a speech icon in Control Panel, and I'm fairly certain that the Microsoft Speech SDK put it there.

Try looking in your registry for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices. If the branch is not there then you might try installing the SDK.
eschew obfuscation

Bill Cravener

Dougie Murray did up a great example of text to speech, I modified it slightly to simplify it just a bit years back.

You can get the example here from this old thread.

http://www.masm32.com/board/index.php?topic=9024.0
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

Magnum

Dougie example showed me that I have sapi.cpl.

For some reason, it isn't in my Control Panel.

Haven't had any luck determining why.

I will see if TwekUi can help.

I made a shortcut.
Have a great day,
                         Andy

Farabi

There is somebody who post about FFT. Interested to be researcher in here?  :cheekygreen:
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

jj2007

Folks, go the Loquendo demo page. Fantastic. Unfortunately those voices cost a fortune ::)

Farabi

Anyway there is 44100 sample each second where each sample is 16-bit code.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"