Skip to content

Commit 0505990

Browse files
authored
Merge pull request #1 from shipclojure/exp/confert-to-core-async-flow
Convert voice-fn to core.async.flow
2 parents c810283 + c907b94 commit 0505990

File tree

26 files changed

+1089
-1706
lines changed

26 files changed

+1089
-1706
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ jobs:
3434
# key: cljdeps-${{ hashFiles('build.boot') }}
3535
restore-keys: cljdeps-
3636

37-
- name: Setup Babashka
38-
uses: turtlequeue/setup-babashka@v1.7.0
39-
with:
40-
babashka-version: 1.3.189
41-
42-
- name: Check bb runs
43-
run: bb --version
44-
working-directory: ./core
45-
4637
- name: Run Clj Unit tests
47-
run: bb test
38+
run: clojure -M:test -m kaocha.runner :unit
4839
working-directory: ./core

TODO.org

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CLOCK: [2025-01-08 Wed 08:29]--[2025-01-08 Wed 08:54] => 0:25
6363
* TODO Add tools calls support :mvp:
6464
DEADLINE: <2025-01-17 Fri>
6565
:LOGBOOK:
66+
CLOCK: [2025-01-23 Thu 08:23]--[2025-01-23 Thu 08:48] => 0:25
6667
CLOCK: [2025-01-20 Lun 07:26]--[2025-01-20 Lun 07:51] => 0:25
6768
CLOCK: [2025-01-19 Dum 07:56]--[2025-01-19 Dum 08:21] => 0:25
6869
CLOCK: [2025-01-18 Sat 06:36]--[2025-01-18 Sat 06:41] => 0:05
@@ -102,3 +103,11 @@ CLOSED: [2025-01-20 Lun 07:43]
102103
#+end_src
103104

104105
* TODO research [[https://github.com/phronmophobic/clj-media][clojure-media]] for dedicated ffmpeg support for media conversion
106+
107+
* TODO add core.async.flow support
108+
:LOGBOOK:
109+
CLOCK: [2025-01-25 Sat 16:35]--[2025-01-25 Sat 17:00] => 0:25
110+
CLOCK: [2025-01-25 Sat 15:18]--[2025-01-25 Sat 15:43] => 0:25
111+
CLOCK: [2025-01-25 Sat 11:14]--[2025-01-25 Sat 11:39] => 0:25
112+
CLOCK: [2025-01-25 Sat 09:50]--[2025-01-25 Sat 10:15] => 0:25
113+
:END:

core/.clj-kondo/metosin/malli-types-clj/config.edn

Lines changed: 107 additions & 61 deletions
Large diffs are not rendered by default.

core/deps.edn

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
org.uncomplicate/clojure-sound {:mvn/version "0.3.0"}
44
com.taoensso/telemere {:mvn/version "1.0.0-RC1"}
55
metosin/malli {:mvn/version "0.17.0"}
6-
org.clojure/core.async {:mvn/version "1.7.701"}
6+
org.clojure/core.async {:git/sha "cfb53ac7e48dbcf197b700c62bdd429675fa77b2" :git/url "https://github.com/clojure/core.async"}
77
metosin/jsonista {:mvn/version "0.3.8"}
88
com.microsoft.onnxruntime/onnxruntime {:mvn/version "1.20.0"}
99
com.microsoft.onnxruntime/onnxruntime_gpu {:mvn/version "1.20.0"}
@@ -36,6 +36,5 @@
3636
ring/ring-jetty-adapter {:mvn/version "1.13.0"}
3737
metosin/reitit {:mvn/version "0.7.2"}}
3838
:extra-paths ["../examples/src"]}
39-
:clj-kondo
40-
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}
41-
:main-opts ["-m" "clj-kondo.main"]}}}
39+
:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}
40+
:main-opts ["-m" "clj-kondo.main"]}}}

core/src/voice_fn/core.clj

Lines changed: 0 additions & 14 deletions
This file was deleted.

core/src/voice_fn/frame.clj

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,17 @@
3333
(= frame-type :frame.control/interrupt-start)
3434
(= frame-type :frame.control/interrupt-stop))))
3535

36-
(def BaseFrameSchema
37-
[:map
38-
[:frame/type :keyword]
39-
[:frame/data :any]
40-
[:frame/ts :int]])
41-
4236
(defmacro defframe
4337
"Define a frame creator function and its predicate with schema validation.
4438
Usage: (defframe audio-input
4539
\"Doc string\"
4640
{:type :frame.audio/input-raw
4741
:schema [:map [:data AudioData]])}"
48-
[name docstring {:keys [type schema]}]
49-
(let [frame-schema (if schema
50-
[:map
51-
[:frame/type [:= type]]
52-
[:frame/data schema]
53-
[:frame/ts :int]]
54-
BaseFrameSchema)
42+
[name docstring {:keys [type schema] :or {schema :any}}]
43+
(let [frame-schema [:map
44+
[:frame/type [:= type]]
45+
[:frame/data schema]
46+
[:frame/ts :any]]
5547
frame-schema-name (symbol (str name "-schema"))
5648
pred-name (symbol (str name "?"))]
5749
`(do
@@ -114,20 +106,27 @@
114106

115107
(defframe system-stop
116108
"Frame sent when the pipeline stops"
117-
{:type :frame.system/stop})
109+
{:type :frame.system/stop
110+
:schema :boolean})
118111

119112
(defframe system-error
120113
"General error frame"
121114
{:type :frame.system/error})
122115

116+
(defframe system-config-change
117+
"Frame with configuration changes for the running pipeline"
118+
{:type :frame.system/config-change
119+
:schema schema/PartialConfigSchema})
120+
123121
;;
124122
;; Audio Frames
125123
;; Frames for handling raw audio data
126124
;;
127125

128126
(defframe audio-input-raw
129127
"Raw audio input frame from input transport"
130-
{:type :frame.audio/input-raw})
128+
{:type :frame.audio/input-raw
129+
:schema schema/ByteArray})
131130

132131
(defframe audio-output-raw
133132
"Raw audio output frame for playback through output transport"
@@ -201,11 +200,13 @@
201200

202201
(defframe user-speech-start
203202
"User started speaking"
204-
{:type :frame.user/speech-start})
203+
{:type :frame.user/speech-start
204+
:schema :boolean})
205205

206206
(defframe user-speech-stop
207207
"User stopped speaking"
208-
{:type :frame.user/speech-stop})
208+
{:type :frame.user/speech-stop
209+
:scheam :boolean})
209210

210211
;;
211212
;; Control Frames
@@ -214,21 +215,29 @@
214215

215216
(defframe control-bot-interrupt
216217
"Bot should be interrupted"
217-
{:type :frame.control/bot-interrupt})
218+
{:type :frame.control/bot-interrupt
219+
:schema :boolean})
218220

219221
(defframe control-interrupt-start
220222
"Start pipeline interruption"
221-
{:type :frame.control/interrupt-start})
223+
{:type :frame.control/interrupt-start
224+
:schema :boolean})
222225

223226
(defframe control-interrupt-stop
224227
"Stop pipeline interruption"
225-
{:type :frame.control/interrupt-stop})
228+
{:type :frame.control/interrupt-stop
229+
:schema :boolean})
226230

227231
;;
228232
;; Input/Output Text Frames
229233
;; Frames for text processing
230234
;;
231235

236+
(defframe speak-frame
237+
"Text frame meant for TTS processors to generate speech from the input"
238+
{:type :frame.tts/speak
239+
:schema :string})
240+
232241
(defframe text-input
233242
"Text input frame for LLM processing"
234243
{:type :frame.text/input})

core/src/voice_fn/pipeline.clj

Lines changed: 0 additions & 218 deletions
This file was deleted.

0 commit comments

Comments
 (0)