hier mal ein Bsp:
so sieht bei mir die Sprachdefinition aus:
<? //Do not delete or modify.
include(IPS_GetKernelDirEx()."scripts/__ipsmodule.inc.php");
include("../modules/ips4Windows/ips4WinCortana/module.php");
$ips4WinCortana = new ips4WinCortana(57217 /*[ips4WinCortana\CortanaVoiceCommands]*/);
//Your code goes here...
$ips4WinCortana->EnableDebug(true);
//you can add up to 100 sections (called Commands, each need a unique name like Block1\/Block2 or what ever you like)
//each section can have up to 10 speach commands and include multiple PhraseLists (like {room}) entries
$ips4WinCortana->AddVoiceCommand("TempFragen","Wieviel Grad haben wir [li] {room}?");
[/li]$ips4WinCortana->AddVoiceCommand("TempFragen","Wie ist die Temperatur [li] {room}?");
[/li]
$ips4WinCortana->AddVoiceCommand("Block1","{action} [das] {actor} [das] {room}");
$ips4WinCortana->AddVoiceCommand("Block1","{action} [das] {actor} [das] {room} [auf] {status}");
$ips4WinCortana->AddVoiceCommand("Block1","{action} [das] {actor} [das] {room} [auf] {status} Prozent");
//each section needs a Feedback and Example entry. Feedback is used when command was processed from Cortana
//Example will shown, when user asks Cortana "What can I say?/Was kann ich sagen?"
$ips4WinCortana->AddCommandExample("TempFragen","Wieviel Grad haben wir im Wohnzimmer?");
$ips4WinCortana->AddCommandExample("Block1","schliesse das Rollo im Büro");
$ips4WinCortana->AddCommandFeedback("TempFragen","moment ich fühle mal");
$ips4WinCortana->AddCommandFeedback("Block1","ich arbeite dran");
//you can add multiple PhraseLists with an total of max. 2000 entries
$ips4WinCortana->AddActionPhraseCommand("actor","Rollo");
$ips4WinCortana->AddActionPhraseCommand("actor","Licht");
$ips4WinCortana->AddActionPhraseCommand("actor","Radio");
$ips4WinCortana->AddActionPhraseCommand("action","öffne");
$ips4WinCortana->AddActionPhraseCommand("action","schliesse");
$ips4WinCortana->AddActionPhraseCommand("action","schalte");
$ips4WinCortana->AddActionPhraseCommand("action","stelle");
$ips4WinCortana->AddActionPhraseCommand("action","ändere");
$ips4WinCortana->AddActionPhraseCommand("action","dimme");
$ips4WinCortana->AddActionPhraseCommand("status","an");
$ips4WinCortana->AddActionPhraseCommand("status","aus");
$ips4WinCortana->AddActionPhraseCommand("status","Hälfte");
$ips4WinCortana->AddActionPhraseCommand("status","0");
$ips4WinCortana->AddActionPhraseCommand("status","10");
$ips4WinCortana->AddActionPhraseCommand("status","17");
$ips4WinCortana->AddActionPhraseCommand("status","18");
$ips4WinCortana->AddActionPhraseCommand("status","19");
$ips4WinCortana->AddActionPhraseCommand("status","20");
$ips4WinCortana->AddActionPhraseCommand("status","21");
$ips4WinCortana->AddActionPhraseCommand("status","22");
$ips4WinCortana->AddActionPhraseCommand("status","23");
$ips4WinCortana->AddActionPhraseCommand("status","24");
$ips4WinCortana->AddActionPhraseCommand("status","30");
$ips4WinCortana->AddActionPhraseCommand("status","40");
$ips4WinCortana->AddActionPhraseCommand("status","50");
$ips4WinCortana->AddActionPhraseCommand("status","60");
$ips4WinCortana->AddActionPhraseCommand("status","70");
$ips4WinCortana->AddActionPhraseCommand("status","80");
$ips4WinCortana->AddActionPhraseCommand("status","90");
$ips4WinCortana->AddActionPhraseCommand("status","100");
$ips4WinCortana->AddActionPhraseCommand("room","Büro");
$ips4WinCortana->AddActionPhraseCommand("room","Wohnzimmer");
$ips4WinCortana->AddActionPhraseCommand("room","Küche");
$ips4WinCortana->AddActionPhraseCommand("room","Schlafzimmer");
$ips4WinCortana->AddActionPhraseCommand("room","Bad");
$ips4WinCortana->AddActionPhraseCommand("room","Kinderzimmer");
$ips4WinCortana->AddActionPhraseCommand("room","Garten");
$ips4WinCortana->AddActionPhraseCommand("room","Erdgeschoss");
$ips4WinCortana->AddActionPhraseCommand("room","Obergeschoss");
$ips4WinCortana->AddActionPhraseCommand("room","Haus");
//ProcessData will convert all the entries to something readable for ips4Windows App
$ips4WinCortana->ProcessData();
Auswerten möchte ich aber nicht den gesprochenen Satz, weil das ist zu unsicher. Es können ja auch Wörter ausgelassen werden je nach persönlichen Vorlieben der Nutzer. Deswegen versuche ich auf die Elemente zu Filtern…
hier mal ein einfacher Test ohne großes Fehlerhandling:
<? //Do not delete or modify.
include(IPS_GetKernelDirEx()."scripts/__ipsmodule.inc.php");
include("../modules/ips4Windows/ips4WinCortana/module.php");
$ips4WinCortana = new ips4WinCortana(23921 /*[ips4WinCortana]*/);
$ips4WinCortana->ProcessHookData();
if ($_POST['ips4Command'] != "GetConfig")
{
//Your code goes here...
$resultArray = $ips4WinCortana->GetCortanaResult();
//$resultArray has all the data from Cortana
//textSpoken - full message captured by Cortana
//CommandName - Command of textSpoken line, user defined in ips4CortanaSprachbefehle script (aka section)
//action - used entry from PhraseList defined in ips4CortanaSprachbefehle script
//room - used entry from PhraseList defined in ips4CortanaSprachbefehle script
//feedback - if you used SendFeedbackVerify or SendFeedbackVerifyDetailed you will get the result from this commands, multiple iteration will be added with "#+#" as seperator. Use explode ( "#+#" , $resultArray->feedback) to work with the result array
IPS_LogMessage("WebHook Cortana", print_r($resultArray, true));
//do something useful
//...
//Cortana waits for feedback, otherwise the request will timeout in seconds and shows an error
//Options: sucess - SendFeedbackSuccess(Msg), failure - SendFeedbackFailure(Msg)
//verify with yes/no - SendFeedbackVerify(Msg), verify with more option - SendFeedbackVerifyDetailed(Msg, ListofOptions as array)
/*
31.01.2016 18:40:49*| WebHook Cortana*| Array
(
[ips4Command] => Data
[commandMode] => voice
[actor] => Licht
[room] => Wohnzimmer
[NavigationTarget] => ips4WindowsVoiceCommandService
[status] => 50
[action] => ändere
[CommandName] => Block1
[textSpoken] => ändere das Licht Wohnzimmer auf 50 Prozent
)*/
$bProcessed = false;
$status = $resultArray['status'];
if ($status == "an")
$status = true;
else if ($status == "aus")
$status = false;
else if ($status == "schliesse")
$status = 0;
else if ($status == "öffne")
$status = 1;
else
$status = $status;
if ($resultArray['actor'] == "Licht")
{
if ($resultArray['room'] == "Wohnzimmer")
{
$bProcessed = HM_WriteValueFloat(28396 /*[Räume\Wohnzimmer\Schalter Dimmer Decke (Küche)\1]*/,"LEVEL",($status/100));
}
}
else if ($resultArray['actor'] == "Rollo")
{
if ($resultArray['room'] == "Wohnzimmer")
{
$bProcessed = HM_WriteValueFloat(20797 /*[Räume\Wohnzimmer\Rollo\Rollo Terasse\Rollo]*/,"LEVEL",($status/100));
$bProcessed = HM_WriteValueFloat(13445 /*[Räume\Wohnzimmer\Rollo\Rollo Seite\Rollo]*/,"LEVEL",($status/100));
}
}
if ($bProcessed)
{
$result = $ips4WinCortana->SendFeedbackSuccess("Erfolgreich ausgeführt");
}
else
{
$result = $ips4WinCortana->SendFeedbackFailure("IPS konnte den Befehl nicht ausführen");
}
//last line of the script must be an echo result
echo $result;
}
Grüße
Seb.