Skip to content

Commit

Permalink
voice recognition optimizations #50
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman committed Mar 24, 2018
1 parent cc15350 commit 63c56a4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ static $meeting_search_radius = -50;
```
This would set the radius at the first 50 results and is the default.

## Voice Recognition Optimizations ##

It's possible to set the expected spoken language, for recognition by setting the following variable in config.php to the culture variant. The default is `en-US`, which is US English.

Use the this chart to find the code of your preference https://www.twilio.com/docs/api/twiml/gather#languagetags.

```php
$gather_language = "en-US";
```

You can also set some expected words or hints, to help the voice recognition engine along. Use the setting by separating words with commas. You can use phrases as well.

Each hint may not be more than 100 characters (including spaces). You can use up to 500 hints.

```php
$gather_hints = "";
```

## Helpline Call Routing

Expand Down
3 changes: 2 additions & 1 deletion city-or-county-voice-input.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
include 'config.php';
include 'functions.php';
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

Expand All @@ -12,7 +13,7 @@
}
?>
<Response>
<Gather input="speech" timeout="5" speechTimeout="auto" action="voice-input-result.php?SearchType=<?php echo $searchType; ?>&amp;Province=<?php echo urlencode($province)?>" method="GET">
<Gather language="<?php echo getGatherLanguage(); ?>" hints="<?php echo getGatherHints(); ?>" input="speech" timeout="5" speechTimeout="auto" action="voice-input-result.php?SearchType=<?php echo $searchType; ?>&amp;Province=<?php echo urlencode($province)?>" method="GET">
<Say voice="<?php echo $voice; ?>" language="<?php echo $language; ?>">Please say the name of the city or county.</Say>
</Gather>
</Response>
13 changes: 13 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class MeetingResults {
public $filteredList = [];
}

class GatherMods {
public $language;
public $hints;
}

function getCoordinatesForAddress($address) {
$coordinates = new Coordinates();

Expand Down Expand Up @@ -71,6 +76,14 @@ function getProvince() {
}
}

function getGatherLanguage() {
return isset($GLOBALS["gather_language"]) ? $GLOBALS["gather_language"] : "en-US";
}

function getGatherHints() {
return isset($GLOBALS["gather_hints"]) ? $GLOBALS["gather_hints"] : "";
}

function helplineSearch($latitude, $longitude) {
$helpline_search_radius = isset($GLOBALS['helpline_search_radius']) ? $GLOBALS['helpline_search_radius'] : 30;
$bmlt_search_endpoint = getHelplineBMLTRootServer() . "/client_interface/json/?switcher=GetSearchResults&sort_results_by_distance=1&long_val={LONGITUDE}&lat_val={LATITUDE}&geo_width=" . $helpline_search_radius;
Expand Down
3 changes: 2 additions & 1 deletion province-voice-input.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
include 'config.php';
include 'functions.php';
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

$searchType = $_REQUEST['SearchType'];
?>
<Response>
<Gather input="speech" timeout="5" speechTimeout="auto" action="city-or-county-voice-input.php?SearchType=<?php echo $searchType; ?>" method="GET">
<Gather language="<?php echo getGatherLanguage(); ?>" hints="<?php echo getGatherHints(); ?>" input="speech" timeout="5" speechTimeout="auto" action="city-or-county-voice-input.php?SearchType=<?php echo $searchType; ?>" method="GET">
<Say voice="<?php echo $voice; ?>" language="<?php echo $language; ?>">Please say the name of the state or province.</Say>
</Gather>
</Response>

0 comments on commit 63c56a4

Please sign in to comment.