@@ -1800,67 +1800,72 @@ public void execute(final Object message) throws Exception {
1800
1800
final Recording recording = builder .build ();
1801
1801
final RecordingsDao recordings = storage .getRecordingsDao ();
1802
1802
recordings .addRecording (recording );
1803
- // Start transcription.
1804
- URI transcribeCallback = null ;
1805
- Attribute attribute = verb .attribute ("transcribeCallback" );
1806
- if (attribute != null ) {
1807
- final String value = attribute .value ();
1808
- if (value != null && !value .isEmpty ()) {
1809
- try {
1810
- transcribeCallback = URI .create (value );
1811
- } catch (final Exception exception ) {
1812
- final Notification notification = notification (ERROR_NOTIFICATION , 11100 , transcribeCallback
1813
- + " is an invalid URI." );
1814
- notifications .addNotification (notification );
1815
- sendMail (notification );
1816
- final StopInterpreter stop = new StopInterpreter ();
1817
- source .tell (stop , source );
1818
- return ;
1819
- }
1820
- }
1821
- }
1822
- boolean transcribe = false ;
1823
- if (transcribeCallback != null ) {
1824
- transcribe = true ;
1825
- } else {
1826
- attribute = verb .attribute ("transcribe" );
1803
+
1804
+ Attribute attribute = null ;
1805
+
1806
+ if (checkAsrService ()) {
1807
+ // ASR service is enabled. Start transcription.
1808
+ URI transcribeCallback = null ;
1809
+ attribute = verb .attribute ("transcribeCallback" );
1827
1810
if (attribute != null ) {
1828
1811
final String value = attribute .value ();
1829
1812
if (value != null && !value .isEmpty ()) {
1830
- transcribe = Boolean .parseBoolean (value );
1813
+ try {
1814
+ transcribeCallback = URI .create (value );
1815
+ } catch (final Exception exception ) {
1816
+ final Notification notification = notification (ERROR_NOTIFICATION , 11100 , transcribeCallback
1817
+ + " is an invalid URI." );
1818
+ notifications .addNotification (notification );
1819
+ sendMail (notification );
1820
+ final StopInterpreter stop = new StopInterpreter ();
1821
+ source .tell (stop , source );
1822
+ return ;
1823
+ }
1831
1824
}
1832
1825
}
1833
- }
1834
- if (transcribe && checkAsrService ()) {
1835
- final Sid sid = Sid .generate (Sid .Type .TRANSCRIPTION );
1836
- final Transcription .Builder otherBuilder = Transcription .builder ();
1837
- otherBuilder .setSid (sid );
1838
- otherBuilder .setAccountSid (accountId );
1839
- otherBuilder .setStatus (Transcription .Status .IN_PROGRESS );
1840
- otherBuilder .setRecordingSid (recordingSid );
1841
- otherBuilder .setTranscriptionText ("Transcription Text not available" );
1842
- otherBuilder .setDuration (duration );
1843
- otherBuilder .setPrice (new BigDecimal ("0.00" ));
1844
- buffer = new StringBuilder ();
1845
- buffer .append ("/" ).append (version ).append ("/Accounts/" ).append (accountId .toString ());
1846
- buffer .append ("/Transcriptions/" ).append (sid .toString ());
1847
- final URI uri = URI .create (buffer .toString ());
1848
- otherBuilder .setUri (uri );
1849
- final Transcription transcription = otherBuilder .build ();
1850
- final TranscriptionsDao transcriptions = storage .getTranscriptionsDao ();
1851
- transcriptions .addTranscription (transcription );
1852
- try {
1853
- final Map <String , Object > attributes = new HashMap <String , Object >();
1854
- attributes .put ("callback" , transcribeCallback );
1855
- attributes .put ("transcription" , transcription );
1856
- getAsrService ().tell (new AsrRequest (new File (recordingUri ), "en" , attributes ), source );
1857
- outstandingAsrRequests ++;
1858
- } catch (final Exception exception ) {
1859
- logger .error (exception .getMessage (), exception );
1826
+ boolean transcribe = false ;
1827
+ if (transcribeCallback != null ) {
1828
+ transcribe = true ;
1829
+ } else {
1830
+ attribute = verb .attribute ("transcribe" );
1831
+ if (attribute != null ) {
1832
+ final String value = attribute .value ();
1833
+ if (value != null && !value .isEmpty ()) {
1834
+ transcribe = Boolean .parseBoolean (value );
1835
+ }
1836
+ }
1837
+ }
1838
+ if (transcribe && checkAsrService ()) {
1839
+ final Sid sid = Sid .generate (Sid .Type .TRANSCRIPTION );
1840
+ final Transcription .Builder otherBuilder = Transcription .builder ();
1841
+ otherBuilder .setSid (sid );
1842
+ otherBuilder .setAccountSid (accountId );
1843
+ otherBuilder .setStatus (Transcription .Status .IN_PROGRESS );
1844
+ otherBuilder .setRecordingSid (recordingSid );
1845
+ otherBuilder .setTranscriptionText ("Transcription Text not available" );
1846
+ otherBuilder .setDuration (duration );
1847
+ otherBuilder .setPrice (new BigDecimal ("0.00" ));
1848
+ buffer = new StringBuilder ();
1849
+ buffer .append ("/" ).append (version ).append ("/Accounts/" ).append (accountId .toString ());
1850
+ buffer .append ("/Transcriptions/" ).append (sid .toString ());
1851
+ final URI uri = URI .create (buffer .toString ());
1852
+ otherBuilder .setUri (uri );
1853
+ final Transcription transcription = otherBuilder .build ();
1854
+ final TranscriptionsDao transcriptions = storage .getTranscriptionsDao ();
1855
+ transcriptions .addTranscription (transcription );
1856
+ try {
1857
+ final Map <String , Object > attributes = new HashMap <String , Object >();
1858
+ attributes .put ("callback" , transcribeCallback );
1859
+ attributes .put ("transcription" , transcription );
1860
+ getAsrService ().tell (new AsrRequest (new File (recordingUri ), "en" , attributes ), source );
1861
+ outstandingAsrRequests ++;
1862
+ } catch (final Exception exception ) {
1863
+ logger .error (exception .getMessage (), exception );
1864
+ }
1860
1865
}
1861
1866
} else if (logger .isInfoEnabled ()){
1862
- logger .info ("AsrService activated but not properly configured. Please set api-key for AsrService " );
1863
- }
1867
+ logger .info ("AsrService is not enabled " );
1868
+ }
1864
1869
1865
1870
// If action is present redirect to the action URI.
1866
1871
String action = null ;
@@ -1946,11 +1951,11 @@ public void execute(final Object message) throws Exception {
1946
1951
if (CallStateChanged .class .equals (klass ) ) {
1947
1952
if (action == null || action .isEmpty ()) {
1948
1953
source .tell (new StopInterpreter (), source );
1954
+ } else {
1955
+ // Ask the parser for the next action to take.
1956
+ final GetNextVerb next = new GetNextVerb ();
1957
+ parser .tell (next , source );
1949
1958
}
1950
- } else {
1951
- // Ask the parser for the next action to take.
1952
- final GetNextVerb next = new GetNextVerb ();
1953
- parser .tell (next , source );
1954
1959
}
1955
1960
// A little clean up.
1956
1961
recordingSid = null ;
0 commit comments