File tree Expand file tree Collapse file tree 4 files changed +18
-5
lines changed
Expand file tree Collapse file tree 4 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 66 [simulflow.transport.in :as in]
77 [simulflow.transport.out :as out]
88 [simulflow.utils.audio :as audio]
9- [simulflow.utils.core :as u :refer [defaliases ]]))
9+ [simulflow.utils.core :as u :refer [defaliases ]]
10+ [taoensso.telemere :as t]))
1011
1112; ; =============================================================================
1213; ; Processors
6869 :channels 1 ; PCM is mono
6970 :sample-size-bits 16 ; PCM is 16-bit
7071 :duration-ms duration-ms})]
72+ (t/log! {:id :audio-splitter
73+ :msg " Received audio output. Splitting into chunks"
74+ :level :debug
75+ :data {:sample-rate sample-rate
76+ :chunk-size chunk-size}})
7177 (if-let [chunks (split-audio-into-chunks audio chunk-size)]
7278 ; ; Create new frames preserving the sample rate from original frame
7379 [state {:out (mapv (fn [chunk-audio]
Original file line number Diff line number Diff line change 2525
2626(defn log-vad-state!
2727 [prev-vad-state vad-state]
28- (when (not= prev-vad-state vad-state)
28+ (when (and prev-vad-state vad-state ( not= prev-vad-state vad-state) )
2929 (t/log! {:level :debug
3030 :id :transport-in
3131 :msg " Changed vad state"
Original file line number Diff line number Diff line change 5757 ; ; Audio writer process - handles only audio I/O side effects and lazy line opening
5858 (vthread-loop []
5959 (when-let [audio-command (<!! audio-write-ch)]
60+ (t/log! {:level :debug :id :speakers-out :msg " Playing audio chunk" :data audio-command})
6061 (when (= (:command audio-command) :write-audio )
6162 (let [current-time (u/mono-time )
6263 delay-until (:delay-until audio-command 0 )
7071 new-line))]
7172 (when (pos? wait-time)
7273 (<!! (timeout wait-time)))
74+
7375 (sound/write! (:data audio-command) line 0 )))
7476 (recur )))
7577
163165 [{:keys [transport/serializer] :as state
164166 ::keys [last-send-time sending-interval]
165167 :or {last-send-time 0 }} frame now]
168+ (t/log! {:level :debug :id :speakers-out :sample 0.01 :msg " Received playback frame" :data (dissoc (:frame/data frame) :audio )})
166169 (let [should-emit-start? (not (::speaking? state))
167170 maybe-next-send (+ last-send-time sending-interval)
168171 next-send-time (if (>= now maybe-next-send) now maybe-next-send)
196199 :or {now (u/mono-time )}} input-port frame]
197200 (cond
198201 ; ; Handle incoming audio frames - core business logic moved here
199- (and (= input-port :in )
200- (frame/audio-output-raw? frame))
202+ (frame/audio-output-raw? frame)
201203 (process-realtime-out-audio-frame state frame now)
202204
203205 (and (= input-port :timer-out )
Original file line number Diff line number Diff line change 2828 ::sut/sending-interval 20 }
2929 frame (frame/audio-output-raw {:audio (byte-array [1 2 3 ]) :sample-rate 24000 })
3030 current-time 2000
31- [new-state output] (sut/process-realtime-out-audio-frame state frame current-time)]
31+ [new-state output] (sut/process-realtime-out-audio-frame state frame current-time)
32+ command (first (:audio-write output))]
33+ (is (= (update command :data vec) {:command :write-audio
34+ :data [1 , 2 , 3 ]
35+ :delay-until 2000
36+ :sample-rate 24000 }))
3237
3338 (is (true ? (::sut/speaking? new-state)))
3439 (is (= 1 (count (:audio-write output))))
You can’t perform that action at this time.
0 commit comments