Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?
Save up to 50% on our desktop apps during our Year End Sale!Save up to 50% on our desktop apps during our Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our Year End Sale!

duhow's profile on WallpaperFusion.com
Could it be possible to create a macro that listens to arguments as well?
For example, I've developed ten macros, each one opens a website with a different name.
If I could join these macros within one, and then with Macro Script be able to distinguish each argument name (from a list of possibilities), it would be awesome!
Jan 6, 2016 (modified Jan 6, 2016)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Interesting idea! I've added this to our feature request list. We'll be sure to post an update if/when we're able to implement this :)

Thanks!
Jan 6, 2016  • #2
User Image
Darkstrumn
11 discussion posts
This is possible via macroscript. :D
I provide a long winded example, with a speech recognizer function (in the speech class) that one can use to make confirmation voice prompts, or other forms of vocal input to expand a macro with. Based on the OP's suggestion, I used a verbal site list selection prompt, with input validation. It includes selections that are initially difficult for the recognizer to understand, and will either require speech recognition training of the users system, or faking it by selecting the closest false positives and updating the valid list of responses.

Hopefully the code is not too hard to follow, it was a spur of the moment example where only the Speech class is from my code library; it should still be a good example of the recognizer's use.

setup:
make a macro for the trigger verbiage you want, say for example, "Goto my favorite sites"
add the macroscript block, and copy past the following code overwriting the initial template code.
Run it to test it, and adjust the site URL's and valid site list as you like, and click ok when good.
Click Ok, to save macro to profile.
Click Ok to save Profile to registry, and you're set. 8)

Code

using System;
using System.Drawing;
using System.Speech.Recognition;//append to the stuff between the quotes References textbox: " | C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll"

public static class VoiceBotScript
{
//---------------------------------------------------------------------------
/// <summary>
/// long winded example of verbal confirmation macroscript, where the response
/// must be "valid". To accept any response is much simpler, just remove the stuff
/// between //<Complex - validated response> and //</Complex - validated response>
/// then uncomment the commented line //<simple void prompt> for the simple voice prompt
/// </summary>
/// <param name="windowHandle"></param>
public static void Run(IntPtr windowHandle)
{
string str_valid_sites = "Google,Home,Eve-Gate,Discussions";//<<--some words may be harder to properly understand, so training may be needed to improve accuracy, or adding the false positives to the list of valid responses to mitigate them
string str_urls = "https://www.google.com/advanced_search,http://www.WhereEverYouHomePageIs.net,https://gate.eveonline.com/,https://www.voicebot.net/Discussions/";
string str_url = ""; //<<--selected url based on user response
string str_confirmation = "";//<<--verbal response converted to string
bool bln_valid_response = true;//<<--validation flag
bool bln_quit = false; //<<--failsafe flag
bool bln_heard_correctly = true; //<<--flag to retry without using a retry
int int_retries = 0;//<<--failsafe counter
int int_index = 0; //<<--used to link valid response to the associated url
//<simple void prompt>string str_confirmation = (string)Speech.SpeechRecognizer("Please select the site you would like to go to from the following {SITES}".Replace("{SITES}", str_valid_sites));
//<Complex - validated response>
bln_valid_response = false;
BFS.Speech.TextToSpeech("Please select the site you would like to go to from the following");
BFS.Speech.TextToSpeech("{SITES}".Replace("{SITES}", str_valid_sites));
while(bln_valid_response == false || bln_quit == false)
{
str_confirmation = (string)Speech.SpeechRecogizer("");//<<--we've moved the voice prompt out side the loop so the system waits for a valid response without further "prompt"
BFS.Speech.TextToSpeech("I heard: " + str_confirmation);
bln_heard_correctly = BFS.Dialog.GetUserConfirm("I heard: " + str_confirmation);//<<--so use can see the recognized speech, and update the valid list, or whatever... .
if(!bln_heard_correctly){continue;}else{;}//<<--skip processing, and try again, we were not heard correctly
BFS.Speech.TextToSpeech("looking for a matching valid site");
int_index = 0;
//
foreach(string str_valid_site in str_valid_sites.Split(','))
{
BFS.Speech.TextToSpeech("site: " + str_valid_site);
if(str_confirmation.Trim().ToLower() == str_valid_site.Trim().ToLower())
{
BFS.Speech.TextToSpeech("match found.");
str_url = str_urls.Split(',')[int_index];
bln_valid_response = true;
break;//<<--breach the loop
}
else{BFS.Speech.TextToSpeech("wasn't a match, continuing.");}
//</if(str_confirmation.ToLower() == str_valid_site.ToLower())>
int_index++;
}//</foreach(string str_valid_site in str_valid_sites.Split(','))>
//>>>>>was the response valid?
if(bln_valid_response == false)
{
int_retries++;//<<--increament failsafe value, this will allow the prompt to fail after so many retries
//>>>>>see if we want to provide "help" to the user...
switch(int_retries)
{
case 1:
BFS.Speech.TextToSpeech("I require a site chosen from the provided list: {SITES}.".Replace("{SITES}", str_valid_sites));
break;
case 3:
BFS.Speech.TextToSpeech("If I may, the following is the list of valid responses: {SITES}.".Replace("{SITES}",str_valid_sites));
break;
default:
if(int_retries >= 5)
{
BFS.Speech.TextToSpeech("As, I am unable to understand your response, I will accept this as a failure to respond and abort. There may be a technical fault with the voice input system if you were indeed responding.");
bln_quit = true;
}
else{;}
//</if(int_retries >= 5)>
break;
}//</switch(true)>
}
else
{
break;//<<--breach the loop
}
//</if(bln_valid_response == false)>
}//</while(bln_valid_response == false)>
//</Complex - validated response>
if(bln_valid_response)
{
if(BFS.Dialog.GetUserConfirm("You selected site \"{SITE}\" End of line.".Replace("{SITE}", str_url)))
{BFS.Web.OpenUrl(str_url);}
else{;}//>>>>>do nothing
//</if(BFS.Dialog.GetUserConfirm("You selected site "{SITE}" End of line.".Replace("{SITE}", str_url)))>
}
else{;}//>>>>>do nothing
}//</Run(IntPtr windowHandle)>
}/*</class VoiceBotScript>*/
//=====================================================================
/// <summary>
/// Author: Darkstrumn
/// Function: Aux speech functions, such as voice prompting
/// </summary>
public static class Speech
{
//---------------------------------------------------------------------
/// <summary>
/// SpeechRecogizer provide voice prompts, where the user can be prompted
/// aurally to respond verbally and the response is converted to string and
/// returned for further processing
/// </summary>
/// <param name=""str_voice_prompt""></param>
/// <returns></returns>
public static string SpeechRecogizer(string str_voice_prompt)
{
string str_return = "";
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
Grammar dictationGrammar = new DictationGrammar();
recognizer.LoadGrammar(dictationGrammar);
BFS.Speech.TextToSpeech(str_voice_prompt);
//
try
{
recognizer.SetInputToDefaultAudioDevice();
RecognitionResult result = recognizer.Recognize();
str_return = result.Text;
}
catch (InvalidOperationException exception)
{
BFS.Dialog.ShowMessageError("Error detected during sound acquisition: {SOURCE} - {MESSAGF}.".Replace("{SOURCE}",exception.Source).Replace("{MESSAGF}",exception.Message));
}
finally
{
recognizer.UnloadAllGrammars();
}//</try>
return (str_return);
}//</SpeachRecognizer()>
//------------------------------------------------------------------------
}/*</class Speech>*/
Hack and the world hacks with you!
Jan 18, 2016 (modified Feb 2, 2016)  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Wow, nice script! Thanks for sharing that, and for linking to it from the other posts as well :)
Jan 20, 2016  • #4
FluffyBunnyFeet's profile on WallpaperFusion.com
Is this script no longer functioning?

I tried it out, but during compile it give this error:
=================
Compile Failed.
Line 3: The type or namespace name 'Speech' does not exist in the namespace 'System' (are you missing an assembly reference?)
=================

here's line #3:
=================
using System.Speech.Recognition; //append to the stuff between the quotes References textbox: " | C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll"
=================

Is there an alternate line/package for the System.Speech.Recognition?

Thanks,

Van
Nov 3, 2018  • #5
User Image
Darkstrumn
11 discussion posts
It looks like there was come conditioning done upon paste that may have mangled it a bit.
I've cleaned it up, and made formatting adjustments. I'll use the code tags to hopefully preserve the code proper (likely forgot that the first time around).
Also, note that the comment on online #3 was corrected ( must not have proofread it, but it was confusing.
I have this macro-script in place just to make sure it did work, and it does for me, but again I think I may have not used code correctly or something, note the HTML encoded bits "%gt;" etc.

I include an attachment of the code as a file in case this re-post still is a swing and a miss. ;)

Oh, and in case it helps: this is the bit to for the references box for this proof. The fully qualified filename at the end is for the the speech recognition assembly:
System.Core.dll | System.Data.dll | System.dll  | System.Drawing.dll | System.Management.dll | System.Web.dll | System.Windows.Forms.dll | System.Xml.dll | C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll


Code

using System;
using System.Drawing;
using System.Speech.Recognition;//append the stuff between the quotes to References textbox: " | C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll"

public static class VoiceBotScript
    {
    //---------------------------------------------------------------------------
    /// <summary>
    /// long winded example of verbal confirmation macroscript, where the response
    /// must be "valid". To accept any response is much simpler, just remove the stuff
    /// between //<Complex - validated response> and //</Complex - validated response>
    /// then uncomment the commented line //<simple void prompt> for the simple voice prompt
    /// v2: cleaned up some for both clarity and updated coding style
    /// </summary>
    /// <param name="windowHandle"></param>
    public static void Run(IntPtr windowHandle)
        {
        string str_valid_sites = "Google,Home,Eve-Gate,Discussions";//<<--some words may be harder to properly understand, so training may be needed to improve accuracy, or adding the false positives to the list of valid responses to mitigate them
        string str_urls = "https://www.google.com/advanced_search,http://www.WhereEverYouHomePageIs.net,https://gate.eveonline.com/,https://www.voicebot.net/Discussions/";
        string str_url = ""; //<<--selected url based on user response
        string str_confirmation = "";//<<--verbal response converted to string
        bool bln_valid_response = true;//<<--validation flag
        bool bln_quit = false; //<<--failsafe flag
        bool bln_heard_correctly = true; //<<--flag to retry without using a retry
        int int_retries = 0;//<<--failsafe counter
        int int_index = 0; //<<--used to link valid response to the associated url
                           //<simple void prompt>string str_confirmation = (string)Speech.SpeechRecognizer("Please select the site you would like to go to from the following {str_valid_sites}".Replace("{str_valid_sites}", str_valid_sites));
                           //<Complex - validated response>
        bln_valid_response = false;
        BFS.Speech.TextToSpeech("Please select the site you would like to go to from the following");
        BFS.Speech.TextToSpeech("{str_valid_sites}".Replace("{str_valid_sites}", str_valid_sites));
        while( bln_valid_response == false || bln_quit == false )
            {
            str_confirmation = (string)Speech.SpeechRecogizer(string.Empty);//<<--we've moved the voice prompt out side the loop so the system waits for a valid response without further "prompt"
            BFS.Speech.TextToSpeech("I heard: {str_confirmation}".Replace("{str_confirmation}", str_confirmation));
            bln_heard_correctly = BFS.Dialog.GetUserConfirm("I heard: {str_confirmation}".Replace("{str_confirmation}", str_confirmation));//<<--so use can see the recognized speech, and update the valid list, or whatever... .
            if( !bln_heard_correctly ) { continue; } else {/*>>>>>do nothing*/; }//<<--skip processing, and try again, we were not heard correctly
            BFS.Speech.TextToSpeech("looking for a matching valid site");
            int_index = 0;
            //
            foreach( string str_valid_site in str_valid_sites.Split(',') )
                {
                BFS.Speech.TextToSpeech("site: {str_valid_site}".Replace("{str_valid_site}", str_valid_site));
                if( str_confirmation.Trim().ToLower() == str_valid_site.Trim().ToLower() )
                    {
                    BFS.Speech.TextToSpeech("match found.");
                    str_url = str_urls.Split(',')[int_index];
                    bln_valid_response = true;
                    break;//<<--breach the loop
                    }
                else { BFS.Speech.TextToSpeech("wasn't a match, continuing."); }//</if>
                int_index++;
                }//</foreach>
                 //>>>>>was the response valid?
            if( bln_valid_response == false )
                {
                int_retries++;//<<--increment failsafe value, this will allow the prompt to fail after so many retries
                              //>>>>>see if we want to provide "help" to the user...
                switch( int_retries )
                    {
                    case 1:
                        BFS.Speech.TextToSpeech("I require a site chosen from the provided list: {str_valid_sites}.".Replace("{str_valid_sites}", str_valid_sites));
                        break;
                    case 3:
                        BFS.Speech.TextToSpeech("If I may, the following is the list of valid responses: {str_valid_sites}.".Replace("{str_valid_sites}", str_valid_sites));
                        break;
                    default:
                        if( int_retries >= 5 )
                            {
                            BFS.Speech.TextToSpeech("As, I am unable to understand your response, I will accept this as a failure to respond and abort. There may be a technical fault with the voice input system if you were indeed responding.");
                            bln_quit = true;
                            }
                        else {/*>>>>>do nothing*/; }
                        break;
                    }//</switch>
                }
            else
                {
                break;//<<--breach the loop
                }//</if>
            }//</while>
             //</Complex - validated response>
        if( bln_valid_response )
            {
            if( BFS.Dialog.GetUserConfirm("You selected site \"{str_url}\" End of line.".Replace("{str_url}", str_url)) )
                { BFS.Web.OpenUrl(str_url); }
            else {/*>>>>>do nothing*/; }
            //</if>
            }
        else {/*>>>>>do nothing*/; }
        }//</Run>
    }/*</class VoiceBotScript>*/
     //=====================================================================
     /// <summary>
     /// Author: Darkstrumn
     /// Function: Aux speech functions, such as voice prompting
     /// </summary>
public static class Speech
    {
    //---------------------------------------------------------------------
    /// <summary>
    /// SpeechRecogizer provide voice prompts, where the user can be prompted
    /// aurally to respond verbally and the response is converted to string and
    /// returned for further processing
    /// </summary>
    /// <param name="str_voice_prompt"></param>
    /// <returns></returns>
    public static string SpeechRecogizer(string str_voice_prompt)
        {
        string str_return = "";
        SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
        Grammar dictationGrammar = new DictationGrammar();
        recognizer.LoadGrammar(dictationGrammar);
        BFS.Speech.TextToSpeech(str_voice_prompt);
        //
        try
            {
            recognizer.SetInputToDefaultAudioDevice();
            RecognitionResult result = recognizer.Recognize();
            str_return = result.Text;
            }
        catch( InvalidOperationException exception )
            {
            BFS.Dialog.ShowMessageError("Error detected during sound acquisition: {exception.Source} - {exception.Message}.".Replace("{exception.Source}", exception.Source).Replace("{exception.Message}", exception.Message));
            }
        finally
            {
            recognizer.UnloadAllGrammars();
            }//</try>
        return (str_return);
        }//</SpeachRecognizer()>
         //------------------------------------------------------------------------
    }/*</class Speech>*/
Hack and the world hacks with you!
• Attachment: VoiceRecognizer-Proof.cs [7,789 bytes]
Nov 3, 2018 (modified Nov 3, 2018)  • #6
User Image
Darkstrumn
11 discussion posts
Just an aside, if the issue was more a situation where the location of the DLL was not found, then you may have to see if it's in another framework location, ie the version I have listed you may not have installed. If that's the case, locate the correct file location on your system via find or the like, and update the reference to point to it instead.

Hope that helps, if my last post didn't.

Cheers!
Hack and the world hacks with you!
Nov 3, 2018  • #7
User Image
Darkstrumn
11 discussion posts
Hi All,

It looks like embedded code is being mangled, some characters are being encoded\\altered.
I recommend taking a look at the attachment to see the proof as intended.

Thanks. ???

edit: How interesting, even the emoji's seem to be unencoded... not sure if it's just me, or an issue with the message system... .
Hack and the world hacks with you!
Nov 3, 2018 (modified Nov 3, 2018)  • #8
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Good catch, guys! We'll have the code boxes fixed later today :)
Nov 7, 2018  • #9
User Image
Darkstrumn
11 discussion posts
Awesome!
Hack and the world hacks with you!
Nov 7, 2018  • #10
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)