@@ -936,17 +936,20 @@ class Endpoint extends Emitter {
936936 }
937937 /**
938938 * VAD detection
939- * @param {string } opts.strategy = one-shot, continuous, default is one-shot
940- * @param {string } [opts.mode] Default value is 2
939+ * @param {string } opts.vendor - vendor of VAD detection engine: 'native; (default), 'silero'
940+ * @param {string } opts.strategy = one-shot, continuous, default is continuous
941+ * @param {string } [opts.mode] (native) Default value is 2
941942 * -1 ("disable fvad, use native")
942943 * - 0 ("quality")
943944 * - 1 ("low bitrate")
944945 * - 2 ("aggressive")
945946 * - 3 ("very aggressive")
946- * @param {string } [opts.silenceMs] - number of milliseconds of silence that must
947- * come to transition from talking to stop talking, default is 250 ms
948- * @param {object|string } [opts.voiceMs] - number of milliseconds of voice that
949- * must come to transition to start talking, default is 150ms
947+ * @param {number } [opts.silenceMs] - number of milliseconds of silence that must
948+ * come to transition from talking to stop talking, default is 100 ms
949+ * @param {number } [opts.voiceMs] - number of milliseconds of voice that
950+ * must come to transition to start talking, default is 250ms
951+ * @param {number } [opts.threshold] - (silero) probability threshold for speech, default is 0.5
952+ * @param {number } [opts.speechPadMs] - (silero) number of milliseconds of speech padding, default is 30ms
950953 * @param {function } [callback] - callback invoked when api request completes
951954 * @return {Promise|Endpoint } returns a Promise if no callback supplied; otherwise
952955 * a reference to the Endpoint object
@@ -955,15 +958,21 @@ class Endpoint extends Emitter {
955958 */
956959 startVadDetection ( opts , callback ) {
957960 opts = opts || { } ;
958- const strategy = opts . strategy || 'one-shot' ;
961+ const vendor = opts . vendor || 'native' ;
962+ const apiCall = vendor === 'native' ? 'uuid_vad_detect' : 'uuid_vad_silero' ;
963+ const strategy = opts . strategy || 'continuous' ;
959964 const mode = opts . mode || 2 ;
960- const silenceMs = opts . silenceMs || 250 ;
961- const voiceMs = opts . voiceMs || 150 ;
962- const bugname = opts . bugname || 'vad_detection' ;
965+ const silenceMs = opts . silenceMs || 100 ;
966+ const voiceMs = opts . voiceMs || 250 ;
967+ const threshold = opts . threshold || 0.5 ;
968+ const speechPadMs = opts . speechPadMs || 30 ;
969+ const bugname = opts . bugname || ( vendor === 'native' ? 'vad_detection' : 'vad_detection_silero' ) ;
963970
964971 const __x = ( callback ) => {
965- const args = [ this . uuid , 'start' , strategy , mode , silenceMs , voiceMs , bugname ] ;
966- this . api ( 'uuid_vad_detect' , args , ( err , evt ) => {
972+ const args = vendor === 'native' ?
973+ [ this . uuid , 'start' , strategy , mode , silenceMs , voiceMs , bugname ] :
974+ [ this . uuid , 'start' , strategy , threshold , silenceMs , voiceMs , speechPadMs , bugname ] ;
975+ this . api ( apiCall , args , ( err , evt ) => {
967976 if ( err ) return callback ( err ) ;
968977 const body = evt . getBody ( ) ;
969978 if ( 0 === body . indexOf ( '+OK' ) ) {
@@ -988,10 +997,13 @@ class Endpoint extends Emitter {
988997
989998 stopVadDetection ( opts , callback ) {
990999 opts = opts || { } ;
991- const bugname = opts . bugname || 'vad_detection' ;
1000+ const vendor = opts . vendor || 'native' ;
1001+ const apiCall = vendor === 'native' ? 'uuid_vad_detect' : 'uuid_vad_silero' ;
1002+ const bugname = opts . bugname || ( vendor === 'native' ? 'vad_detection' : 'vad_detection_silero' ) ;
1003+
9921004 const __x = ( callback ) => {
9931005 const args = [ this . uuid , 'stop' , bugname ] ;
994- this . api ( 'uuid_vad_detect' , args , ( err , evt ) => {
1006+ this . api ( apiCall , args , ( err , evt ) => {
9951007 if ( err ) return callback ( err ) ;
9961008 const body = evt . getBody ( ) ;
9971009 if ( 0 === body . indexOf ( '+OK' ) ) {
0 commit comments