Talking to your apps

Talking to your apps

Postby Antonio Linares » Fri Mar 29, 2024 9: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: Select all  Expand view
#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
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Talking to your apps

Postby Enrico Maria Giordano » Fri Mar 29, 2024 11:10 am

What is it supposed to do? It does nothing here. I need a microphone?
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Talking to your apps

Postby MarcoBoschi » 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
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Talking to your apps

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Talking to your apps

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Talking to your apps

Postby Marc Venken » 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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Talking to your apps

Postby MarcoBoschi » Fri Mar 29, 2024 1: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
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Talking to your apps

Postby Antonio Linares » Fri Mar 29, 2024 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Talking to your apps

Postby Enrico Maria Giordano » Fri Mar 29, 2024 2: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?
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Talking to your apps

Postby Antonio Linares » Fri Mar 29, 2024 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Talking to your apps

Postby Boby6Muertos » Fri Mar 29, 2024 7: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
Boby6Muertos
 
Posts: 4
Joined: Fri Jun 20, 2008 1:14 am
Location: México

Re: Talking to your apps

Postby Enrico Maria Giordano » Fri Mar 29, 2024 7: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.
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Talking to your apps

Postby Jimmy » Sat Mar 30, 2024 9:32 am

hi Antonio,

does it also work using 32 Bit or only using 64 Bit ?
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1584
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Talking to your apps

Postby Enrico Maria Giordano » Sat Mar 30, 2024 9: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.
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Talking to your apps

Postby TimStone » Mon Apr 01, 2024 9: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
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 68 guests