Skip to content

Commit 4369948

Browse files
authored
Merge branch 'master' into github-107
2 parents 25e9762 + 2bb15ec commit 4369948

File tree

112 files changed

+6789
-277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+6789
-277
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@startuml
2+
actor MediaServer
3+
MediaServer-> AsrFsm: enterCollecting
4+
AsrFsm -> AsrEngine: configure
5+
AsrFsm -> AsrEngine: setListener(AsrEngineListener)
6+
AsrFsm -> AsrEngine: activate
7+
AsrEngine -> AsrDriver: configure
8+
AsrEngine -> AsrDriver: setListener(AsrDriverEventListener)
9+
AsrEngine -> AsrDriver: startRecognizing
10+
AsrDriver -> SpeechClient: create(ApiStreamObserver, ResponseApiStreamingObserver)
11+
MediaServer -> AsrEngine: onMediaTransfer (1)
12+
AsrEngine -> AsrDriver: write(1)
13+
AsrDriver -> ApiStreamObserver : onNext(1)
14+
MediaServer -> AsrEngine: onMediaTransfer (2)
15+
AsrEngine -> AsrDriver: write(2)
16+
AsrDriver -> ApiStreamObserver : onNext(2)
17+
actor AsrService
18+
AsrService-> ResponseApiStreamingObserver: onNext(1)
19+
ResponseApiStreamingObserver -> AsrDriverEventListener: onSpeechRecognized(1)
20+
AsrDriverEventListener -> AsrEngineListener: onSpeechRecognized(1)
21+
AsrEngineListener -> AsrFsm: fire(RECOGNIZED_TEXT)
22+
AsrService-> ResponseApiStreamingObserver: onNext(2)
23+
ResponseApiStreamingObserver -> AsrDriverEventListener: onSpeechRecognized(2)
24+
AsrDriverEventListener -> AsrEngineListener: onSpeechRecognized(2)
25+
AsrEngineListener -> AsrFsm: fire(RECOGNIZED_TEXT)
26+
MediaServer -> AsrEngine: onMediaTransfer (3)
27+
AsrEngine -> AsrDriver: write(3)
28+
AsrDriver -> ApiStreamObserver : onNext(3)
29+
AsrService -> ResponseApiStreamingObserver: onNext(3)
30+
ResponseApiStreamingObserver -> AsrDriverEventListener: onSpeechRecognized(3)
31+
AsrDriverEventListener -> AsrEngineListener: onSpeechRecognized(3)
32+
AsrEngineListener -> AsrFsm: fire(RECOGNIZED_TEXT)
33+
MediaServer -> AsrFsm: exitWaitingForResponse
34+
AsrFsm -> AsrEngine: setListener(null)
35+
AsrFsm -> AsrEngine: deactivate
36+
AsrEngine -> AsrDriver: finishRecognizing
37+
AsrDriver -> ApiStreamObserver: onCompleted
38+
AsrDriver -> SpeechClient: close
39+
AsrEngine -> AsrDriver: setListener(null)
40+
@enduml
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@startuml
2+
state AsrSignal {
3+
[*] --> LoadingPlaylist
4+
LoadingPlaylist --> Prompting : prompt
5+
LoadingPlaylist --> Prompted : no_prompt
6+
Prompting --> Prompted : end_prompt
7+
Prompting --> Prompting : next_track
8+
Prompted --> [*]
9+
||
10+
[*] --> Collecting
11+
Collecting --> Collecting : recognized_text
12+
Collecting --> WaitingAsrTimeout: end_input (eik, mrt, pst)
13+
Collecting --> DigitsCollecting: digit
14+
DigitsCollecting --> Collected : digits_collected, end_input (eik, mrt, pst)
15+
DigitsCollecting --> DigitsCollecting: digit
16+
WaitingAsrTimeout --> Collected: asr_timeout
17+
WaitingAsrTimeout --> WaitingAsrTimeout : recognized_text
18+
Collected --> [*]
19+
}
20+
21+
[*] -down-> AsrSignal
22+
AsrSignal -down-> Evaluating : evaluate/timeout
23+
AsrSignal --> Canceled : cancel
24+
25+
Evaluating -down-> Failing : no_recognized_text
26+
Evaluating -down-> Canceled : cancel
27+
Evaluating -down-> Succeeding : succeed
28+
29+
Failing -down-> PlayingFailure : prompt
30+
Failing -down-> Failed : no_prompt/cancel
31+
PlayingFailure --> PlayingFailure : next_track
32+
PlayingFailure -down-> Failed : end_prompt/cancel
33+
34+
Succeeding -down-> PlayingSuccess : prompt
35+
Succeeding -down-> Succeeded : no_prompt/cancel
36+
PlayingSuccess --> PlayingSuccess : next_track
37+
PlayingSuccess -down-> Succeeded : end_prompt/cancel
38+
39+
Canceled -down-> Succeeded : succeed
40+
Canceled -down-> Failed : fail (NO_SPEECH)
41+
42+
Succeeded --> [*]
43+
Failed --> [*]
44+
@enduml
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@startuml
2+
state AsrSignal {
3+
[*] --> LoadingPlaylist
4+
LoadingPlaylist --> Prompting : prompt
5+
LoadingPlaylist --> Prompted : no_prompt
6+
Prompting --> Prompted : end_prompt
7+
Prompting --> Prompting : next_track
8+
Prompted --> [*]
9+
||
10+
[*] --> Collecting
11+
Collecting --> Collecting : recognized_text
12+
Collecting --> WaitingAsrTimeout: end_input
13+
Collecting --> Collected: end_input_without_wfr
14+
WaitingAsrTimeout --> Collected: asr_timeout
15+
WaitingAsrTimeout --> WaitingAsrTimeout : recognized_text
16+
Collected --> [*]
17+
}
18+
19+
[*] -down-> AsrSignal
20+
AsrSignal -down-> Evaluating : evaluate/timeout
21+
AsrSignal --> Canceled : cancel
22+
23+
Evaluating -down-> Failing : no_recognized_text
24+
Evaluating -down-> Canceled : cancel
25+
Evaluating -down-> Succeeding : succeed
26+
27+
Failing -down-> PlayingFailure : prompt
28+
Failing -down-> Failed : no_prompt/cancel
29+
PlayingFailure --> PlayingFailure : next_track
30+
PlayingFailure -down-> Failed : end_prompt/cancel
31+
32+
Succeeding -down-> PlayingSuccess : prompt
33+
Succeeding -down-> Succeeded : no_prompt/cancel
34+
PlayingSuccess --> PlayingSuccess : next_track
35+
PlayingSuccess -down-> Succeeded : end_prompt/cancel
36+
37+
Canceled -down-> Succeeded : succeed
38+
Canceled -down-> Failed : fail (NO_SPEECH)
39+
40+
Succeeded --> [*]
41+
Failed --> [*]
42+
@enduml

asr/asr-api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

asr/asr-api/pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<packaging>jar</packaging>
6+
7+
<parent>
8+
<groupId>org.restcomm.media</groupId>
9+
<artifactId>asr</artifactId>
10+
<version>7.0.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<groupId>org.restcomm.media.asr</groupId>
14+
<artifactId>asr-api</artifactId>
15+
<name>ASR API</name>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.restcomm.media.drivers.asr</groupId>
20+
<artifactId>asr-driver-api</artifactId>
21+
<version>${project.parent.version}</version>
22+
</dependency>
23+
</dependencies>
24+
25+
<build>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-compiler-plugin</artifactId>
30+
<configuration>
31+
<source>1.7</source>
32+
<target>1.7</target>
33+
</configuration>
34+
</plugin>
35+
</plugins>
36+
<finalName>restcomm-mediaserver-asr-api-${project.parent.version}</finalName>
37+
</build>
38+
</project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2017, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
22+
package org.restcomm.media.asr;
23+
24+
import java.util.List;
25+
26+
import org.restcomm.media.drivers.asr.AsrDriverConfigurationException;
27+
import org.restcomm.media.drivers.asr.UnknownAsrDriverException;
28+
29+
/**
30+
* @author gdubina
31+
*
32+
*/
33+
public interface AsrEngine extends SpeechDetector {
34+
35+
/**
36+
* Configures the ASR Engine.
37+
*
38+
* @param driver The ASR driver to be loaded.
39+
* @param language The language to be used.
40+
* @param hints The list of hotwords to help raise detection accuracy.
41+
* @throws UnknownAsrDriverException When the provided driver is not supported.
42+
* @throws AsrDriverConfigurationException When the driver is badly configured.
43+
*/
44+
void configure(String driver, String language, List<String> hints) throws UnknownAsrDriverException, AsrDriverConfigurationException;
45+
46+
/**
47+
* Attaches a listener to the engine to be notified about ASR events.
48+
*
49+
* @param listener The listener who will be notified by the ASR Engine.
50+
*/
51+
void setListener(AsrEngineListener listener);
52+
53+
/**
54+
* Gets the amount of time the engine will wait for the ASR provider to provide a transcription.
55+
*
56+
* @return The waiting time, in milliseconds.
57+
*/
58+
int getResponseTimeoutInMilliseconds();
59+
60+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2017, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
22+
package org.restcomm.media.asr;
23+
24+
import org.restcomm.media.drivers.asr.AsrDriverException;
25+
26+
/**
27+
* Listens to events raised by {@link AsrEngine}.
28+
*
29+
* @author gdubina
30+
*
31+
*/
32+
public interface AsrEngineListener {
33+
34+
/**
35+
* Event raised when a speech transcription is provided.
36+
*
37+
* @param text The speech transcription.
38+
* @param isFinal Whether the result is final or interim.
39+
*/
40+
void onSpeechRecognized(String text, boolean isFinal);
41+
42+
/**
43+
* Event raised when the underlying ASR driver fails unexpectedly.
44+
*
45+
* @param e The error thrown by the driver.
46+
*/
47+
void onDriverError(AsrDriverException e);
48+
49+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2017, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
22+
package org.restcomm.media.asr;
23+
24+
/**
25+
* Produces instances of {@link AsrEngine}.
26+
*
27+
* @author gdubina
28+
*
29+
*/
30+
public interface AsrEngineProvider {
31+
32+
/**
33+
* Build a new ASR engine.
34+
*
35+
* @return A new instance of ASR engine.
36+
*/
37+
AsrEngine provide();
38+
39+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2017, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
22+
package org.restcomm.media.asr;
23+
24+
/**
25+
* Exception that is thrown whenever a problem occurs during a speech detection process.
26+
*
27+
* @author anikiforov
28+
*/
29+
public class AsrException extends Exception {
30+
31+
private static final long serialVersionUID = 3170306388026514101L;
32+
33+
public AsrException(String message, Throwable cause) {
34+
super(message, cause);
35+
}
36+
37+
public AsrException(String message) {
38+
super(message);
39+
}
40+
41+
public AsrException(Throwable cause) {
42+
super(cause);
43+
}
44+
45+
}

0 commit comments

Comments
 (0)