Discussions related to Visual Prolog
archit507
Posts: 14
Joined: 24 Oct 2016 10:02

Unread post by archit507 »

Hi Thomas,

Can we do speech recognization like can we convert speech to text using visual prolog and store it in database? If yes, then can you please provide me any document regarding that.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Yes, that is possible. But not trivial.

You will have to import the Microsoft SAPI COM component in your project.

Notice that working with COM requires the Commercial Edition.
Regards Thomas Linder Puls
PDC
archit507
Posts: 14
Joined: 24 Oct 2016 10:02

Unread post by archit507 »

Thank you for the update. Can you please provide me code regarding speech recognization, so that I can refer and work on that.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

This recognizes speech from a file:

Code: Select all

implement main     open core, sapiDDI_types   constants     recognizerId : string = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Recognizers\Tokens\MS-1033-80-DESK".     grammarId = 123.     spfei_interest : unsigned64 = spfei_flagcheck + 2 ^ spei_end_sr_stream + 2 ^ spei_recognition.   clauses     run() :-         stdio::outputStream:allowNullPointers := true,         AudioFileName = @"..\test.wav",         Recognizer = spInprocRecognizer::new(),         SpToken = spObjectToken::new(),         RecognizerToken = SpToken:get_ISpObjectToken_import(),         RecognizerToken:setId(uncheckedConvert(string, null), recognizerId, b_false),         Recognizer:setRecognizer(RecognizerToken),         Recognizer:createRecoContext(RecoContext),         RecoContext:createGrammar(grammarId, Grammar),         SpStream = spStream::new(),         SpStream:bindToFile(AudioFileName, spfm_open_readonly, uncheckedConvert(core::nativeGuid, null), uncheckedConvert(waveformatex, null), 0),         Recognizer:setInput(SpStream:getIUnknown(), 0),         Grammar:loadDictation("", splo_static),         Grammar:setDictationState(sprs_active),         RecoContext:setNotifyWin32Event(),         RecoContext:setInterest(spfei_interest, spfei_interest),         try             eventLoop(RecoContext)         finally             Grammar:unloadDictation(),             Grammar:setDictationState(sprs_inactive),             Grammar:release(),             SpStream:release(),             SpStream:close(),             RecoContext:release(),             Recognizer:release()         end try.   class predicates     eventLoop : (iSpRecoContext_import RecoContext). clauses     eventLoop(RecoContext) :-         std::repeat(), %+             RecoContext:waitForNotifyEvent(0xFFFFFFFF),             RecoContext:getEvents(1, Event, Fetched),             if Fetched <> 0 then                 handleEvent(Event)             end if,             (Fetched = 0 orelse spevent(spei_end_sr_stream, _, _, _, _, _) = Event),         !.       eventLoop(_RecoContext).   class predicates     handleEvent : (sapiDDI_types::spevent Event). clauses     handleEvent(sapiDDI_types::spevent(spei_recognition, _ParamType, _StreamNum, _AudioStreamOffset, _WParam, LParam)) :-         !,         Native = uncheckedConvert(iSpRecoResult_native, LParam),         RecoResult = iSpRecoResult_import::new(Native, comMemory::release()),         RecoResult:getText(0xFFFFFFFF, 0xFFFFFFFF, 1, Text, DisplayAttributes),         RecoResult:getPhrase(Phrase),         stdio::writef("Text = %\nDisplayAttributes = %\nPhrase = %\n", toString(Text), DisplayAttributes, Phrase).       handleEvent(_).   end implement main
Regards Thomas Linder Puls
PDC
archit507
Posts: 14
Joined: 24 Oct 2016 10:02

Unread post by archit507 »

Thank you Thomas.
Post Reply