FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Talking to your apps
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Talking to your apps
Posted: Fri Mar 29, 2024 09:40 AM
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 (fw): Select all Collapse
#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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 11:10 AM

What is it supposed to do? It does nothing here. I need a microphone?

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 11:46 AM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 12:49 PM
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 12:50 PM
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
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 12:58 PM

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
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 01:09 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 01:27 PM
> 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 02:01 PM

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?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 06:50 PM

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
Posts: 10
Joined: Fri Jun 20, 2008 01:14 AM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 07:11 PM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Talking to your apps
Posted: Fri Mar 29, 2024 07:33 PM
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.
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Talking to your apps
Posted: Sat Mar 30, 2024 09:32 AM

hi Antonio,

does it also work using 32 Bit or only using 64 Bit ?

greeting,

Jimmy
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Talking to your apps
Posted: Sat Mar 30, 2024 09:43 AM

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.

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Talking to your apps
Posted: Mon Apr 01, 2024 09:36 PM

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