Working on speech rec

This commit is contained in:
Hillel Coren 2017-04-04 18:54:17 +03:00
parent 5128ca45a7
commit 025c9abc90
3 changed files with 42 additions and 3 deletions

View File

@ -73,6 +73,17 @@ class BaseIntent
return new $className($state, $data); return new $className($state, $data);
} }
protected function getField($field)
{
foreach ($this->data->entities as $entity) {
if ($entity->type === $field) {
return $entity->entity;
}
}
return false;
}
public function process() public function process()
{ {
throw new Exception(trans('texts.intent_not_supported')); throw new Exception(trans('texts.intent_not_supported'));

View File

@ -0,0 +1,29 @@
<?php
namespace App\Ninja\Intents\WebApp;
use App\Models\Account;
use App\Ninja\Intents\BaseIntent;
class NavigateToIntent extends BaseIntent
{
public function process()
{
$location = $this->getField('Location');
$location = str_replace(' ', '_', $location);
$map = [
'report' => 'reports',
];
if (isset($map[$location])) {
$location = $map[$location];
}
if (in_array($location, array_merge(Account::$basicSettings, Account::$advancedSettings))) {
$location = '/settings/' . $location;
}
return redirect($location);
}
}

View File

@ -134,7 +134,6 @@
recognition.onend = function() { recognition.onend = function() {
recognizing = false; recognizing = false;
$('.fa-microphone').show(); $('.fa-microphone').show();
$('#search').val('');
if (ignore_onend) { if (ignore_onend) {
return; return;
} }
@ -174,8 +173,8 @@
function onMicrophoneClick() { function onMicrophoneClick() {
//$('#search').val('create new invoice for edgar a po number of 1234'); //$('#search').val('create new invoice for edgar a po number of 1234');
$('#search').val('create a task for edgar'); //$('#search').val('create a task for edgar');
//$('#search').val('show me all vendors'); $('#search').val('go to localization');
$('#search-form').submit(); $('#search-form').submit();
return; return;