Talking to your apps

User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Talking to your apps

Post by Antonio Linares »

This simple code lets you talk to your apps instead of having to write! :-)

Please test it, I do appreciate your feedback. I think this may be very interesting for our apps!

listen.prg

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   local oDlg, oGet, cText := Space( 30 )

   DEFINE DIALOG oDlg 

   @ 1, 1 GET oGet VAR cText
   oGet:bGotFocus = { || Listen() }

   ACTIVATE DIALOG oDlg CENTERED

return nil 

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

HB_FUNC( LISTEN )
{
    INPUT inputs[4];

    // Pulsación de tecla Windows
    inputs[0].type = INPUT_KEYBOARD;
    inputs[0].ki.wVk = VK_LWIN;

    // Pulsación de tecla H
    inputs[1].type = INPUT_KEYBOARD;
    inputs[1].ki.wVk = 'H';

    // Liberación de tecla H
    inputs[2].type = INPUT_KEYBOARD;
    inputs[2].ki.wVk = 'H';
    inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;

    // Liberación de tecla Windows
    inputs[3].type = INPUT_KEYBOARD;
    inputs[3].ki.wVk = VK_LWIN;
    inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;

    // Envía las pulsaciones de teclas
    SendInput(4, inputs, sizeof(INPUT));    
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Talking to your apps

Post by Enrico Maria Giordano »

What is it supposed to do? It does nothing here. I need a microphone?
User avatar
MarcoBoschi
Posts: 1070
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Talking to your apps

Post by MarcoBoschi »

Very very interesting!
How can I test it?
What have I to initializa in my pc?
Windows 10

Bye Marco
Marco Boschi
info@marcoboschi.it
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Talking to your apps

Post by Antonio Linares »

Enrico Maria Giordano wrote:What is it supposed to do? It does nothing here. I need a microphone?
Dear Enrico,

Yes, you need a microphone
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Talking to your apps

Post by Antonio Linares »

MarcoBoschi wrote:Very very interesting!
How can I test it?
What have I to initializa in my pc?
Windows 10

Bye Marco
Dear Marco,

It is built-in Windows 11. Now sure if it is available in Windows 10.

Just press Windows + h keys and see if you get it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Marc Venken
Posts: 1481
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Talking to your apps

Post by Marc Venken »

It seems that we have to setup our spoken language in windows. Mine was not setup and I get a system dialog saying to install and download a language pack. No time at this moment. Try later ...

Speech Recognition error...
Marc Venken
Using: FWH 23.08 with Harbour
User avatar
MarcoBoschi
Posts: 1070
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Talking to your apps

Post by MarcoBoschi »

It's amazing It works even in my old console program!
I press Windows H And then I click on microphone on the left
From what I understand it works in every application, as long as the focus is in a text field
Marco Boschi
info@marcoboschi.it
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Talking to your apps

Post by Antonio Linares »

> From what I understand it works in every application, as long as the focus is in a text field

right! Thats why we invoke it when a GET has the focus :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Talking to your apps

Post by Enrico Maria Giordano »

Ok, it works. There is one thing I don't understand: listening starts automatically only with Harbour but not with xHarbour. Do you know why?
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Talking to your apps

Post by Antonio Linares »

Dear Enrico,

I think it is a timing issue, maybe we invoke it too soon.

We need to find a way to fine tune it...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Boby6Muertos
Posts: 10
Joined: Fri Jun 20, 2008 1:14 am
Location: México
Contact:

Re: Talking to your apps

Post by Boby6Muertos »

In my case I managed to include it in my app, with another function name, because it clashed with winsock. I was able to use it with Windows 10, although I did have to activate it using the Windows key + h
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Talking to your apps

Post by Enrico Maria Giordano »

Antonio Linares wrote:Dear Enrico,

I think it is a timing issue, maybe we invoke it too soon.

We need to find a way to fine tune it...
Yes, I was thinking along the same line. I tried with a call to SysWait() but to no avail. I have to try putting a delay in the C code.
User avatar
Jimmy
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Talking to your apps

Post by Jimmy »

hi Antonio,

does it also work using 32 Bit or only using 64 Bit ?
greeting,
Jimmy
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Talking to your apps

Post by Enrico Maria Giordano »

It should work with both 32 and 64 bit. But here it only works with some combination of compilers (MSC, BCC, Harbour, xHarbour) and bits (32, 64), not for all the combinations.
User avatar
TimStone
Posts: 2951
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Talking to your apps

Post by TimStone »

I tried to test it using my Beelink SER 7 mini-pc. It turned out that the microphone ( on the camera ) doesn't work with that device ... didn't know that. Evidently it's a common problem and they don't have a solution.

SO ... I tried it on my Surface Notebook ( Windows + H ) and it did a nice job of converting voice to text.

I would suggest that when using this in our programs, as you have suggested, then we should have a program wide flag that allows the client to use, or NOT use, voice. Maybe a default on setup, and/or a hot key to toggle it. That way we don't always have a live microphone picking up unwanted comments. Of course, this is a developers task, not something FiveWin needs to handle.

Thanks for the idea.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Post Reply