Functions: Difference between revisions

From LINKS - Documentation
Jump to navigation Jump to search
Line 107: Line 107:


== Get data from url ==
== Get data from url ==
* <code>[LINKS.LHttp.GetResponse("http://ai-dot.net/test.txt","return","failed")]&output=plaintext</code>
* <code>[LINKS.LHttp.GetResponse("http<nowiki/>://ai-dot.net/test.txt","return","failed")]&output=plaintext</code>
 
== Run a get request ==
* <code>[LINKS.LHttp.Get("http<nowiki/>://ai-dot.net/","return","failed")]&output=plaintext</code>


== Return full grammar list in response ==
== Return full grammar list in response ==

Revision as of 19:41, 2 May 2016

Brief info on the web request syntax

  • Example URL: http://localhost:54657/?action=action=[LINKS.LExecute.SpeakFromLINKS("web requests disable")]&key=1234ABC&request=disable&output=json
  • If WebAccess under settings is not enabled we use localhost for i.e. http://localhost:54657/?
  • If WebAccess under settings is enabled we can either use localhost or local IP address for i.e. http://192.168.1.15:54657/?
Note: We can find what IP is the web service running on from windows command prompt using this command: netstat -a | findstr 54657
  • Base URL: http://IP_OR_LOCALHOST:54657/
  • For starting the web query: ? is used
  • For separating parameters: & is used
  • URL takes following parameters:
    • action: always required, you’ll need to find what commands can be called from here.
    • key: only needed if web access is enabled, located under LINKS settings.
    • request: can be used to enable or disable web request.
    • output: can be added to get json response or other formats.
    • Example:
      • action=[Speak("web requests disabled")]
      • key=1234ABC
      • request=disable
      • output=json
      • So if we put it together.. it will look like this:
        • http://localhost:54657/?action=[Speak("web requests disabled")]&key=1234ABC&request=disable&output=json
    • output parameter can have following values:
      • json: retrieves request, status, response, error as json.
      • plaintext: retrieves request, status, response, error as plain text.
      • xml: retrieves request, status, response, error as xml.
      • response: response field in plain text.
      • error: error field in plain text.
      • request: request field in plain text.
      • status: status field in plain text.

Speaking

All speak functions output can be randomized by using ; in the phrase.

  • Basic Speaking function
    • [Speak("Phrase")]
  • Speaks using specified values, allows you to change volume but is SYNCHRONOUS ONLY so it will NOT SHUT-UP - blocks the flow
    • [SpeakEx("Phrase","Volume","Rate","VoiceName")]
Phrase: Phrase to speak
Volume: 0 - 100
Rate: -10 to - 10
VoiceName: full voice name (case sensitive) (e.g. Microsoft Zira Desktop or Microsoft David Desktop etc..)
  • Speaks from LINKS using a text file as source
    • [LINKS.LExecute.SpeakTextFileFromLINKS("c:\temp\test.txt")]
  • Sets speech volume
    • [SetSpeechVolume("volume")]
volume: 0 - 100
  • Change voice
    • [SetSpeechVoice("VoiceName")]
VoiceName: Full name of the voice to be used for speech; case sensitive


Gets data from a file

  • [GetFile("c:\test.txt")]
If file path is not defined and uses %APPDATA%\LINKS\Data\Strings as the default directory.
In web request we can add &output=response to see plain text response in browser.

Executes any non-dynamic (non-WordList) commands

  • [CallCommand("Command")]
Command: any command from user interface

Executes an external programs or run as shell command action

  • [RunAsShell("Shell Action","Response after execution","Response before confirmation","Response on fail")]

Executes a shell command with voice name and volume specified

  • [RunAsShell("Shell Action","Response After Execution","Response Before Confirmation","Response Failed","VoiceVolume,"VoiceName")]
VoiceName: Full name of the voice to be used for speech
VoiceVolume: 0 - 100
If voice change does not work, then leave voice name blank to make volume change affected
This function also has compatibility issue for voice change and may not work on some machines.

Executes a shell command with specified system volume

  • [RunAsShellSysVol("shellCommand","responseAfterExecution","responseBeforeConfirmation","responseFailed","voiceVolume)]

Run a task according to a time and date with a specific voice name and voice volume

  • [SetTaskEx("datetime","speechBefore","speechAfter","speechFailed","VoiceVoice","VoiceVolume","shell action")]
VoiceName: Full name of the voice to be used for speech
VoiceVolume: 0 - 100

Run a task according to a time and date with a specific voice name and system volume

  • [SetTaskExSysVol("datetime","speechBefore","speechAfter","speechFailed","VoiceName","SysVolume","shell action")]
VoiceName: Full name of the voice to be used for speech
SysVolume: 0 - 100

Stop/Start web service

  • [Speak("Stoppping web service")]&request=disable
  • [Speak("Web service enabled")]&request=enable

Stop/start listening

  • [ToggleListening]
  • [StartListening("[PlaySound("Startup_Music")]Listening Started")]
  • [StopListening("[PlaySound("Startup_Music")]Listening Stopped")]

Speech to text using Cortana

  • [Cortana.LDictation.GetDictation("Question phrase","show_ui")]
Shows Windows 10 style dialogue box for voice prompt via Cortana.
  • [Cortana.LDictation.GetDictation("Question phrase","hide_ui")]]

Web Search

  • [LINKS.WebSearch.bingQuery("Search Query"," response on fail")]
Note: Search query can also come from Cortana or from windows speech recognition.

Get data from url

  • [LINKS.LHttp.GetResponse("http://ai-dot.net/test.txt","return","failed")]&output=plaintext

Run a get request

  • [LINKS.LHttp.Get("http://ai-dot.net/","return","failed")]&output=plaintext

Return full grammar list in response

  • [GetGrammarList("xml")]&output=xml&request=disable_recurse
  • [GetGrammarList("xml")]&output=response&request=disable_recurse
  • [GetGrammarList("xml")]&output=json&request=disable_recurse

Set microphone level

  • [SetMicrophone("volume","mute")]
volume: 0 - 100
mute_unmute: mute, unmute

Speech/sound file to text

  • [SpeechToText("c:\temp\1.wav")]

Set a reminder

  • [SetReminder("DateTime","Phrase","Volume")]
DateTime: system date format like: 04/01/2016 02:29:00 PM or 04/01/2016 14:29:00
Phrase: Phrase to be spoken, can be randomized using ; as phrase separator
Volume: 0 - 100

Set a reminder and emulate speech

  • [SetReminderEx("DateTime ","phrase","volume","EmulateSpeech” )]
DateTime: system date format like: 04/01/2016 02:29:00 PM or 04/01/2016 14:29:00
Phrase: Phrase to be spoken, can be randomized using ; as phrase separator
Volume: 0 - 100
EmulateSpeech: can be replaced by any grammar... like "turn of the lights"


Import commands remotely =

  • [AddCommands("F:\20160401_export_shell.txt")]
  • [AddCommands("F:\20160401_export_web.txt")]
  • [AddCommands("F:\20160401_export_social.txt")]
  • [AddCommands("F:\20160401_export_default.txt")]
  • [AddCommands("F:\20160401_export_keyboard.txt")]
Imports command files to database directly, does not check for duplicates.

Set a variable

  • [Set("VariableName","Value")]
VariableName: Name given to variable
Variable: Variable value
Sets and stores a variable for later use

Get a variable

  • [Get("VariableName")]
VariableName: Name given to variable