Skip to content

Commit 098a9db

Browse files
authored
Merge pull request #3 from codeboost/main
Update to latest flow commit, make voice-id configurable
2 parents 64d66c7 + 1926f3c commit 098a9db

File tree

9 files changed

+29
-13
lines changed

9 files changed

+29
-13
lines changed

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
/target
3030
/resources/secrets.edn
3131
/core/resources/secrets.edn
32-
/core/.clj-kondo/.cache
3332
/core/.lsp/
3433
/examples/.calva/
35-
/.idea/
36-
/core/.idea/
37-
/core/core.iml
34+
.idea/
35+
.clj-kondo/
36+
*.iml

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ This project's status is **_experimental_**. Expect breaking changes.
1515

1616

1717
## Quick Start: Local example
18+
19+
First, create a `resources/secrets.edn`:
20+
21+
```edn
22+
{:deepgram {:api-key ""}
23+
:elevenlabs {:api-key ""
24+
:voice-id ""}
25+
:groq {:api-key ""}
26+
:openai {:new-api-sk ""}}
27+
```
28+
29+
Obtain the API keys from the respective providers and fill in the blank values.
30+
31+
Start a REPL and evaluate the snippets in the `(comment ...)` blocks to start the flows.
32+
Allow Microphone access when prompted.
33+
1834
```clojure
1935
(ns voice-fn-examples.local
2036
(:require

deps.edn

Lines changed: 1 addition & 1 deletion
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 {:git/sha "0529d79f1b73a4788567f9b571f8b423657bb409" :git/url "https://github.com/clojure/core.async"}
6+
org.clojure/core.async {:git/sha "88a7971196cd41fbc921df3f4c36a004a3f974d6" :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"}

examples/src/voice_fn_examples/local.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
:tts {:proc tts/elevenlabs-tts-process
9898
:args {:elevenlabs/api-key (secret [:elevenlabs :api-key])
9999
:elevenlabs/model-id "eleven_flash_v2_5"
100-
:elevenlabs/voice-id "7sJPxFeMXAVWZloGIqg2"
100+
:elevenlabs/voice-id (secret [:elevenlabs :voice-id])
101101
:voice/stability 0.5
102102
:voice/similarity-boost 0.8
103103
:voice/use-speaker-boost? true

examples/src/voice_fn_examples/scenario_example.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
:tools []}
7272

7373
;; add gateway process for scenario to inject frames
74-
:extra-procs {:scenario {:proc (flow/step-process #'sm/scenario-in-process)}}
74+
:extra-procs {:scenario {:proc (flow/process #'sm/scenario-in-process)}}
7575
:extra-conns [[[:scenario :speak-out] [:tts :in]]
7676
[[:scenario :context-out] [:context-aggregator :in]]]})
7777

@@ -102,5 +102,4 @@
102102

103103
;; Stop the conversation
104104
(flow/stop (:flow s))
105-
106105
,)

examples/src/voice_fn_examples/twilio_websocket.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
:tts {:proc tts/elevenlabs-tts-process
122122
:args {:elevenlabs/api-key (secret [:elevenlabs :api-key])
123123
:elevenlabs/model-id "eleven_flash_v2_5"
124-
:elevenlabs/voice-id "7sJPxFeMXAVWZloGIqg2"
124+
:elevenlabs/voice-id (secret [:elevenlabs :voice-id])
125125
:voice/stability 0.5
126126
:voice/similarity-boost 0.8
127127
:voice/use-speaker-boost? true

src/voice_fn/processors/elevenlabs.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
(let [{:audio.out/keys [encoding sample-rate]
3131
:flow/keys [language]
3232
:elevenlabs/keys [model-id voice-id]
33-
:or {model-id "eleven_flash_v2_5"
34-
voice-id "cjVigY5qzO86Huf0OWal"}}
33+
:or {model-id "eleven_flash_v2_5"}}
3534
args]
35+
(assert voice-id "Voice ID is required")
3636
(u/append-search-params (format xi-tts-websocket-url voice-id)
3737
{:model_id model-id
3838
:language_code language
@@ -42,7 +42,7 @@
4242
(make-elevenlabs-ws-url
4343
{:elevenlabs/api-key (secrets/secret [:elevenlabs :api-key])
4444
:elevenlabs/model-id "eleven_flash_v2_5"
45-
:elevenlabs/voice-id "7sJPxFeMXAVWZloGIqg2"
45+
:elevenlabs/voice-id (secrets/secret [:elevenlabs :voice-id])
4646
:voice/stability 0.5
4747
:voice/similarity-boost 0.8
4848
:voice/use-speaker-boost? true}))

src/voice_fn/processors/llm_context_aggregator.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ S: Start, E: End, T: Transcription, I: Interim, X: Text
334334
([] {:ins {:in "Channel for llm text chunks"}
335335
:outs {:out "Channel for assembled speak frames"}})
336336
([_] {:acc nil})
337+
([state _] state)
337338
([{:keys [acc]} _ msg]
338339
(when (frame/llm-text-chunk? msg)
339340
(let [{:keys [sentence accumulator]} (u/assemble-sentence acc (:frame/data msg))]
@@ -375,4 +376,4 @@ S: Start, E: End, T: Transcription, I: Interim, X: Text
375376
(def llm-sentence-assembler
376377
"Takes in llm-text-chunk frames and returns a full sentence. Useful for
377378
generating speech sentence by sentence, instead of waiting for the full LLM message."
378-
(flow/step-process #'llm-sentence-assembler-impl))
379+
(flow/process #'llm-sentence-assembler-impl))

src/voice_fn/scenario_manager.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
:outs {:speak-out "Channel where speak-frames will be put. Should be connected to text to speech process"
136136
:context-out "Channel where context frames will be put"}})
137137
([_] nil)
138+
([state _] state)
138139
([_ _ frame]
139140
[nil (cond-> {:context-out [frame]}
140141
(frame/speak-frame? frame) (assoc :speak-out [frame]))]))

0 commit comments

Comments
 (0)