File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 100100 " Base input transport logic that is used by most transport input processors.
101101 Assumes audio-input-raw frames that come in are 16kHz PCM mono. Conversion to
102102 this format should be done beforehand."
103- [{:keys [pipeline/supports-interrupt?] :as state} _ msg]
103+ [{:keys [pipeline/supports-interrupt? ::muted? ] :as state} _ msg]
104104 (t/log! {:id :transport-in
105105 :msg " Processing frame"
106106 :data (:frame/type msg)
107107 :level :debug
108108 :sample 0.01 })
109109 (cond
110- (frame/audio-input-raw? msg)
110+ (frame/mute-input-start? msg)
111+ [(assoc state ::muted? true )]
112+
113+ (frame/mute-input-stop? msg)
114+ [(assoc state ::muted? false )]
115+
116+ (and (frame/audio-input-raw? msg)
117+ (not muted?))
111118 (if-let [analyser (:vad/analyser state)]
112119 (let [vad-state (vad/analyze-audio analyser (:frame/data msg))
113120 prev-vad-state (:vad/state state :vad.state/quiet )
Original file line number Diff line number Diff line change 114114 [rs {:keys [out sys-out]}] (in/base-input-transport-transform state :in (frame/bot-interrupt true ))]
115115 (is (= rs state))
116116 (is (nil? out))
117- (is (nil? sys-out))))))
117+ (is (nil? sys-out))))
118+
119+ (testing " Toggles muted state when mute-input-start frame is received"
120+ (let [[rs out] (in/base-input-transport-transform {} :sys-in (frame/mute-input-start ))]
121+ (is (= rs {::in/muted? true }))
122+ (is (empty? out))))
123+ (testing " Toggles muted state off when mute-input-stop frame is received"
124+ (let [[rs out] (in/base-input-transport-transform {::in/muted? true } :sys-in (frame/mute-input-stop ))]
125+ (is (= rs {::in/muted? false }))
126+ (is (empty? out))))
127+ (testing " When muted state is active, audio frames aren't processed"
128+ (let [[rs out] (in/base-input-transport-transform {::in/muted? true } :in (frame/audio-input-raw (byte-array (range 200 ))))]
129+ (is (= rs {::in/muted? true }))
130+ (is (empty? out))))))
118131
119132; ; =============================================================================
120133; ; Twilio Transport Tests
You can’t perform that action at this time.
0 commit comments