Skip to content

Commit ec598f2

Browse files
committed
Updates
1 parent eb68b38 commit ec598f2

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

examples/src/simulflow_examples/local_w_interruption_support.clj

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
(:require
66
[clojure.core.async :as a]
77
[clojure.core.async.flow :as flow]
8-
[simulflow-examples.local :as local]
98
[simulflow.async :refer [vthread-loop]]
109
[simulflow.processors.activity-monitor :as activity-monitor]
1110
[simulflow.processors.deepgram :as deepgram]
@@ -17,7 +16,6 @@
1716
[simulflow.transport :as transport]
1817
[simulflow.transport.in :as transport-in]
1918
[simulflow.transport.out :as transport-out]
20-
[simulflow.vad.silero :as silero]
2119
[taoensso.telemere :as t]))
2220

2321
(def llm-context
@@ -124,29 +122,28 @@
124122
{:procs flow-processors
125123
:conns flow-conns})
126124

127-
(comment
125+
(def g (flow/create-flow flow-config))
128126

129-
(def local-ai (local/make-local-flow {:vad-analyser (silero/create-silero-vad)
130-
:extra-procs {}}))
127+
(defonce flow-started? (atom false))
131128

132-
(defonce flow-started? (atom false))
129+
(comment
133130

134131
;; Start local ai flow - starts paused
135-
(let [{:keys [report-chan error-chan]} (flow/start local-ai)]
132+
(let [{:keys [report-chan error-chan]} (flow/start g)]
136133
(reset! flow-started? true)
137134
;; Resume local ai -> you can now speak with the AI
138-
(flow/resume local-ai)
135+
(flow/resume g)
139136
(vthread-loop []
140-
(when @flow-started?
141-
(when-let [[msg c] (a/alts!! [report-chan error-chan])]
142-
(when (map? msg)
143-
(t/log! (cond-> {:level :debug :id (if (= c error-chan) :error :report)}
144-
(= c error-chan) (assoc :error msg)) msg))
145-
(recur)))))
137+
(when @flow-started?
138+
(when-let [[msg c] (a/alts!! [report-chan error-chan])]
139+
(when (map? msg)
140+
(t/log! (cond-> {:level :debug :id (if (= c error-chan) :error :report)}
141+
(= c error-chan) (assoc :error msg)) msg))
142+
(recur)))))
146143

147144
;; Stop the conversation
148145
(do
149-
(flow/stop local-ai)
146+
(flow/stop g)
150147
(reset! flow-started? false))
151148

152149
,)

src/simulflow/processors/elevenlabs.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,14 @@
220220
[state {::ws-write [(process-speak-frame msg)]}])
221221

222222
(frame/control-interrupt-start? msg)
223-
[(assoc state ::accumulator "" :pipeline/interrupted? true)]
223+
(do
224+
(t/log! {:level :debug :id :elevenlabs :data msg :msg "[Interrupted] switching to interrupted state"})
225+
[(assoc state ::accumulator "" :pipeline/interrupted? true)])
224226

225227
(frame/control-interrupt-stop? msg)
226-
[(assoc state :pipeline/interrupted? false)]
228+
(do
229+
(t/log! {:level :debug :id :elevenlabs :data msg :msg "[UnInterrupted] switching to normal state"})
230+
[(assoc state :pipeline/interrupted? false)])
227231

228232
;; Default case - no action
229233
:else

src/simulflow/processors/system_frame_router.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"Returns true if the flow-config contains the system-frame-router-process"
6969
[flow-config]
7070
(reduce-kv (fn [_ _ v]
71-
(if (= (:proc v) system-frame-router-process)
71+
(if (= (:proc v) system-frame-router)
7272
(reduced true)
7373
false))
7474
false

src/simulflow/transport/out.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@
243243
[state {}])
244244

245245
(frame/control-interrupt-start? frame)
246-
[(assoc state :pipeline/interrupted? true) {::command [{:command/kind :command/drain-queue}]}]
246+
(do
247+
(t/log! {:msg "[Interrupted] Draining playback queue" :id :transport-out :level :trace})
248+
[(assoc state :pipeline/interrupted? true) {::command [{:command/kind :command/drain-queue}]}])
247249

248250
(frame/control-interrupt-stop? frame)
249251
[(assoc state :pipeline/interrupted? false) {}]

src/simulflow/vad/silero.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[simulflow.vad.core :as vad]
66
[taoensso.telemere :as t])
77
(:import
8-
(ai.onnxruntime OnnxTensor OrtEnvironment OrtSession OrtSession$SessionOptions OrtSession$Result)
8+
(ai.onnxruntime OnnxTensor OrtEnvironment OrtSession OrtSession$Result OrtSession$SessionOptions)
99
(java.util HashMap)))
1010

1111
;; Constants

0 commit comments

Comments
 (0)