Skip to content

Commit

Permalink
Merge pull request #2500 from RestComm/asr
Browse files Browse the repository at this point in the history
Asr
  • Loading branch information
maria-farooq committed Sep 20, 2017
2 parents d8c0578 + f479d67 commit 9b5dc44
Show file tree
Hide file tree
Showing 34 changed files with 3,392 additions and 258 deletions.
6 changes: 5 additions & 1 deletion .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,20 @@ configRMSNetworking() {
fi
}

configAsrDriver() {
if [ ! -z "$MG_ASR_DRIVERS" ] && [ ! -z "$MG_ASR_DRIVER_DEFAULT" ]; then
FILE=$RESTCOMM_DEPLOY/WEB-INF/conf/restcomm.xml
xmlstarlet ed --inplace -d "/restcomm/runtime-settings/mg-asr-drivers" \
-s "/restcomm/runtime-settings" -t elem -n mg-asr-drivers \
-i "/restcomm/runtime-settings/mg-asr-drivers" -t attr -n default -v "$MG_ASR_DRIVER_DEFAULT" \
$FILE
for driverName in ${MG_ASR_DRIVERS//,/ }; do
xmlstarlet ed --inplace -s "/restcomm/runtime-settings/mg-asr-drivers" -t elem -n "driver" -v "$driverName" \
$FILE
done
fi
}

# MAIN
echo 'Configuring RestComm...'
configRCJavaOpts
Expand Down Expand Up @@ -674,4 +688,5 @@ otherRestCommConf
confRcmlserver
confRVD
configRMSNetworking
configAsrDriver
echo 'Configured RestComm!'
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ LOG_LEVEL_COMPONENT_SIPRESTCOMM='INFO' #Log level for "org.mobicents.servlet.sip
LOG_LEVEL_COMPONENT_RESTCOMM='INFO' #Log level for "org.restcomm.connect" module

#AKKA log level. Set the Log level for the AKKA actor system.
AKKA_LOG_LEVEL='INFO'
AKKA_LOG_LEVEL='INFO'

#ASR drivers
#list of drivers divided with comma, for example: "driver1,driver2,driver3"
MG_ASR_DRIVERS=""
#default asr driver to use. It has to be included to MG_ASR_DRIVERS
MG_ASR_DRIVER_DEFAULT=""
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,124 @@
<conference-entry-audio>beep.wav</conference-entry-audio>
<conference-exit-audio>alert.wav</conference-exit-audio>

<!-- ASR Supported Languages -->
<asr-languages default="en-US">
<language>af-ZA</language>
<language>id-ID</language>
<language>ms-MY</language>
<language>ca-ES</language>
<language>cs-CZ</language>
<language>da-DK</language>
<language>de-DE</language>
<language>en-AU</language>
<language>en-CA</language>
<language>en-GB</language>
<language>en-IN</language>
<language>en-IE</language>
<language>en-NZ</language>
<language>en-PH</language>
<language>en-ZA</language>
<language>en-US</language>
<language>es-AR</language>
<language>es-BO</language>
<language>es-CL</language>
<language>es-CO</language>
<language>es-CR</language>
<language>es-EC</language>
<language>es-SV</language>
<language>es-ES</language>
<language>es-US</language>
<language>es-GT</language>
<language>es-HN</language>
<language>es-MX</language>
<language>es-NI</language>
<language>es-PA</language>
<language>es-PY</language>
<language>es-PE</language>
<language>es-PR</language>
<language>es-DO</language>
<language>es-UY</language>
<language>es-VE</language>
<language>eu-ES</language>
<language>fil-PH</language>
<language>fr-CA</language>
<language>fr-FR</language>
<language>gl-ES</language>
<language>hr-HR</language>
<language>zu-ZA</language>
<language>is-IS</language>
<language>it-IT</language>
<language>lt-LT</language>
<language>hu-HU</language>
<language>nl-NL</language>
<language>nb-NO</language>
<language>pl-PL</language>
<language>pt-BR</language>
<language>pt-PT</language>
<language>ro-RO</language>
<language>sk-SK</language>
<language>sl-SI</language>
<language>fi-FI</language>
<language>sv-SE</language>
<language>vi-VN</language>
<language>tr-TR</language>
<language>el-GR</language>
<language>bg-BG</language>
<language>ru-RU</language>
<language>sr-RS</language>
<language>uk-UA</language>
<language>he-IL</language>
<language>ar-IL</language>
<language>ar-JO</language>
<language>ar-AE</language>
<language>ar-BH</language>
<language>ar-DZ</language>
<language>ar-SA</language>
<language>ar-IQ</language>
<language>ar-KW</language>
<language>ar-MA</language>
<language>ar-TN</language>
<language>ar-OM</language>
<language>ar-PS</language>
<language>ar-QA</language>
<language>ar-LB</language>
<language>ar-EG</language>
<language>fa-IR</language>
<language>hi-IN</language>
<language>th-TH</language>
<language>ko-KR</language>
<language>cmn-Hant-TW</language>
<language>yue-Hant-HK</language>
<language>ja-JP</language>
<language>cmn-Hans-HK</language>
<language>cmn-Hans-CN</language>
</asr-languages>

<!--
Timeouts description:
wit: waiting time to detect user input (gather timeout)
We fire failure event if we haven't received any user input during wit timeout.
This timeout is very similar to fdt (First Digit Timer) for DTMF
pst: amount of silence necessary after the end of speech (gather timeout)
We stop speech recognition if user has suspended input for pst timeout. We fire success event if we have recognized something. We return failure event if we haven't recognized anything.
This timeout is very similar to idt (Inter Digit Timer) for DTMF
mrt: maximum recognition time
We stop speech recognition on pst timeout after user started input.We fire success event if we have recognized something. We return failure event if we haven't recognized anything.
-->
<!-- Default Gathering Timeout. Also is used as default WIT and PST in ASR -->
<default-gathering-timeout>5</default-gathering-timeout>
<!-- ASR Maximum Recognition Time -->
<asr-mrt-timeout>60</asr-mrt-timeout>

<!-- Speech to text drivers -->
<!--mg-asr-drivers default="driver1">
<driver>driver1</driver>
<driver>driver2</driver>
</mg-asr-drivers-->

<!-- Cache settings. -->
<cache-path>${restcomm:home}/cache</cache-path>
<cache-uri>/restcomm/cache</cache-uri>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import org.apache.commons.configuration.Configuration;
import org.restcomm.connect.commons.configuration.sets.CacheConfigurationSet;
import org.restcomm.connect.commons.configuration.sets.RcmlserverConfigurationSet;
import org.restcomm.connect.commons.configuration.sets.MainConfigurationSet;
import org.restcomm.connect.commons.configuration.sets.impl.CacheConfigurationSetImpl;
import org.restcomm.connect.commons.configuration.sets.impl.ConfigurationSet;
import org.restcomm.connect.commons.configuration.sets.MainConfigurationSet;
import org.restcomm.connect.commons.configuration.sets.impl.MainConfigurationSetImpl;
import org.restcomm.connect.commons.configuration.sets.impl.MgAsrConfigurationSet;
import org.restcomm.connect.commons.configuration.sets.impl.RcmlserverConfigurationSetImpl;
import org.restcomm.connect.commons.configuration.sources.ApacheConfigurationSource;

Expand All @@ -55,6 +56,7 @@ public RestcommConfiguration(Configuration apacheConf) {
addConfigurationSet("main", new MainConfigurationSetImpl(apacheCfgSrc));
addConfigurationSet("cache", new CacheConfigurationSetImpl(apacheCfgSrc));
addConfigurationSet("rcmlserver", new RcmlserverConfigurationSetImpl(apacheCfgSrc));
addConfigurationSet("mg-asr", new MgAsrConfigurationSet(apacheCfgSrc, apacheConf));

// addConfigurationSet("identity", new IdentityConfigurationSet( new DbConfigurationSource(dbConf)));
// ...
Expand Down Expand Up @@ -86,6 +88,10 @@ public CacheConfigurationSet getCache() {

public RcmlserverConfigurationSet getRcmlserver() { return (RcmlserverConfigurationSet) sets.get("rcmlserver"); }

public MgAsrConfigurationSet getMgAsr() {
return (MgAsrConfigurationSet) sets.get("mg-asr");
}

// singleton stuff
private static RestcommConfiguration instance;
public static RestcommConfiguration createOnce(Configuration apacheConf) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2014, Telestax Inc and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

package org.restcomm.connect.commons.configuration.sets.impl;

import org.apache.commons.configuration.Configuration;
import org.restcomm.connect.commons.configuration.sources.ConfigurationSource;

import java.util.Collections;
import java.util.List;

/**
* Created by gdubina on 26.06.17.
*/
public class MgAsrConfigurationSet extends ConfigurationSet {

private final List<String> drivers;
private final String defaultDriver;
private final List<String> languages;
private final String defaultLanguage;
private final int asrMRT;
private final int defaultGatheringTimeout;

public MgAsrConfigurationSet(ConfigurationSource source, Configuration config) {
super(source);
drivers = Collections.unmodifiableList(config.getList("runtime-settings.mg-asr-drivers.driver"));
defaultDriver = config.getString("runtime-settings.mg-asr-drivers[@default]");
languages = Collections.unmodifiableList(config.getList("runtime-settings.asr-languages.language"));
defaultLanguage = config.getString("runtime-settings.asr-languages[@default]");
asrMRT = config.containsKey("runtime-settings.asr-mrt-timeout") ? config.getInt("runtime-settings.asr-mrt-timeout") : 60;
defaultGatheringTimeout = config.containsKey("runtime-settings.default-gathering-timeout") ? config.getInt("runtime-settings.default-gathering-timeout") : 5;
}

public List<String> getDrivers() {
return drivers;
}

public String getDefaultDriver() {
return defaultDriver;
}

public List<String> getLanguages() {
return languages;
}

public String getDefaultLanguage() {
return defaultLanguage;
}

public int getAsrMRT() {
return asrMRT;
}

public int getDefaultGatheringTimeout() {
return defaultGatheringTimeout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2014, Telestax Inc and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

package org.restcomm.connect.commons.configuration;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.junit.Test;
import org.restcomm.connect.commons.configuration.sets.impl.MgAsrConfigurationSet;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import static org.junit.Assert.*;

public class MgAsrConfigurationTest {

private List<String> expectedDrivers = Arrays.asList("driver1", "driver2");

private List<String> expectedLanguages = Arrays.asList("en-US", "en-GB", "es-ES", "it-IT", "fr-FR", "pl-PL", "pt-PT");

private RestcommConfiguration createCfg(final String cfgFileName) throws ConfigurationException,
MalformedURLException {
URL url = this.getClass().getResource(cfgFileName);

Configuration xml = new XMLConfiguration(url);
return new RestcommConfiguration(xml);
}

public MgAsrConfigurationTest() {
super();
}

@Test
public void checkMgAsrSection() throws ConfigurationException, MalformedURLException {
MgAsrConfigurationSet conf = createCfg("/restcomm.xml").getMgAsr();

assertTrue(CollectionUtils.isEqualCollection(expectedDrivers, conf.getDrivers()));
assertEquals("driver1", conf.getDefaultDriver());
}

@Test
public void checkNoMgAsrSection() throws ConfigurationException, MalformedURLException {
MgAsrConfigurationSet conf = createCfg("/restcomm-no-mg-asr.xml").getMgAsr();

assertTrue(CollectionUtils.isEqualCollection(Collections.emptyList(), conf.getDrivers()));
assertNull(conf.getDefaultDriver());
}

@Test
public void checkAsrLanguagesSection() throws ConfigurationException, MalformedURLException {
MgAsrConfigurationSet conf = createCfg("/restcomm.xml").getMgAsr();

assertTrue(CollectionUtils.isEqualCollection(expectedLanguages, conf.getLanguages()));
assertEquals("en-US", conf.getDefaultLanguage());
}

@Test
public void checkAsrMRT() throws ConfigurationException, MalformedURLException {
MgAsrConfigurationSet conf = createCfg("/restcomm.xml").getMgAsr();
assertSame(60, conf.getAsrMRT());
}

@Test
public void checkDefaultGatheringTimeout() throws ConfigurationException, MalformedURLException {
MgAsrConfigurationSet conf = createCfg("/restcomm.xml").getMgAsr();
assertSame(5, conf.getDefaultGatheringTimeout());
}

}
Loading

0 comments on commit 9b5dc44

Please sign in to comment.