@lovelace_lol/polymer 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +937 -936
- package/dist/worker/agency-worker.js +846 -843
- package/package.json +1 -1
- package/src/polymer/character.cljs +281 -349
- package/src/polymer/society.cljs +31 -17
- package/src/polymer/worker.cljs +11 -0
|
@@ -25,29 +25,204 @@
|
|
|
25
25
|
;; to Embody. Hair appearance and physics are Embody runtime concerns, not a
|
|
26
26
|
;; Polymer behavioral agency.
|
|
27
27
|
|
|
28
|
+
(defn- with-source-agency [event route]
|
|
29
|
+
(assoc event :sourceAgency (:from route)))
|
|
30
|
+
|
|
31
|
+
(defn- animation-command [event route]
|
|
32
|
+
(when (= "animation" (:to route))
|
|
33
|
+
(case (:type event)
|
|
34
|
+
"animation.requestScheduleSnippet"
|
|
35
|
+
{:type "scheduleSnippet"
|
|
36
|
+
:sourceAgency (:agency event)
|
|
37
|
+
:snippet (:snippet event)
|
|
38
|
+
:options (:options event)}
|
|
39
|
+
|
|
40
|
+
"animation.requestRemoveSnippet"
|
|
41
|
+
{:type "removeSnippet"
|
|
42
|
+
:sourceAgency (:agency event)
|
|
43
|
+
:name (:name event)}
|
|
44
|
+
|
|
45
|
+
"animation.requestSeekSnippet"
|
|
46
|
+
{:type "seekSnippet"
|
|
47
|
+
:sourceAgency (:agency event)
|
|
48
|
+
:name (:name event)
|
|
49
|
+
:offsetSec (:offsetSec event)}
|
|
50
|
+
|
|
51
|
+
nil)))
|
|
52
|
+
|
|
53
|
+
(defn- transcription-command [event]
|
|
54
|
+
(case (:type event)
|
|
55
|
+
"transcription.final"
|
|
56
|
+
{:type "transcript.final"
|
|
57
|
+
:text (:text event)
|
|
58
|
+
:source "transcription"
|
|
59
|
+
:confidence (:confidence event)
|
|
60
|
+
:sequence (:sequence event)
|
|
61
|
+
:sessionId (:sessionId event)
|
|
62
|
+
:at (:at event)}
|
|
63
|
+
|
|
64
|
+
"transcription.interruption"
|
|
65
|
+
{:type "interrupt"
|
|
66
|
+
:reason "transcription-interruption"
|
|
67
|
+
:text (:text event)
|
|
68
|
+
:source "transcription"}
|
|
69
|
+
|
|
70
|
+
"transcription.audioInterruption"
|
|
71
|
+
{:type "interrupt"
|
|
72
|
+
:reason "audio-interruption"
|
|
73
|
+
:event event
|
|
74
|
+
:source "transcription"}
|
|
75
|
+
|
|
76
|
+
nil))
|
|
77
|
+
|
|
78
|
+
(defn- conversation-command [event route]
|
|
79
|
+
(case (:type event)
|
|
80
|
+
"tts.requestSpeak"
|
|
81
|
+
(:command event)
|
|
82
|
+
|
|
83
|
+
"conversation.cancelRequested"
|
|
84
|
+
(if (= "tts" (:to route))
|
|
85
|
+
{:type "stop"
|
|
86
|
+
:reason (:reason event)}
|
|
87
|
+
(with-source-agency event route))
|
|
88
|
+
|
|
89
|
+
(with-source-agency event route)))
|
|
90
|
+
|
|
91
|
+
(defn- tts-command [event route]
|
|
92
|
+
(case (:type event)
|
|
93
|
+
"lipSync.command"
|
|
94
|
+
(:command event)
|
|
95
|
+
|
|
96
|
+
"ttsStatusChanged"
|
|
97
|
+
(let [status (get-in event [:state :status])]
|
|
98
|
+
(case (:to route)
|
|
99
|
+
"conversation" {:type "tts.status"
|
|
100
|
+
:status status}
|
|
101
|
+
"transcription" {:type "tts.status"
|
|
102
|
+
:status status
|
|
103
|
+
:speaking (get-in event [:state :speaking])
|
|
104
|
+
:state (:state event)}
|
|
105
|
+
nil))
|
|
106
|
+
|
|
107
|
+
"ttsSpeechStarted"
|
|
108
|
+
(case (:to route)
|
|
109
|
+
"prosodic" {:type "speechStarted"
|
|
110
|
+
:sourceAgency "tts"
|
|
111
|
+
:name (:name event)
|
|
112
|
+
:engine (:engine event)}
|
|
113
|
+
"conversation" {:type "tts.status"
|
|
114
|
+
:status "speaking"}
|
|
115
|
+
"transcription" event
|
|
116
|
+
nil)
|
|
117
|
+
|
|
118
|
+
"ttsWordBoundary"
|
|
119
|
+
(when (= "prosodic" (:to route))
|
|
120
|
+
{:type "wordBoundary"
|
|
121
|
+
:sourceAgency "tts"
|
|
122
|
+
:word (:word event)
|
|
123
|
+
:wordIndex (:wordIndex event)
|
|
124
|
+
:observedElapsedSec (:observedElapsedSec event)
|
|
125
|
+
:hostElapsedSec (:hostElapsedSec event)})
|
|
126
|
+
|
|
127
|
+
"ttsSpeechStopped"
|
|
128
|
+
(case (:to route)
|
|
129
|
+
"prosodic" {:type "speechStopped"
|
|
130
|
+
:sourceAgency "tts"
|
|
131
|
+
:reason (:reason event)}
|
|
132
|
+
"conversation" {:type "tts.status"
|
|
133
|
+
:status "idle"}
|
|
134
|
+
"transcription" event
|
|
135
|
+
nil)
|
|
136
|
+
|
|
137
|
+
"ttsSpeechEnded"
|
|
138
|
+
(case (:to route)
|
|
139
|
+
"prosodic" {:type "speechStopped"
|
|
140
|
+
:sourceAgency "tts"
|
|
141
|
+
:reason "completed"}
|
|
142
|
+
"conversation" {:type "tts.status"
|
|
143
|
+
:status "idle"}
|
|
144
|
+
"transcription" event
|
|
145
|
+
nil)
|
|
146
|
+
|
|
147
|
+
(with-source-agency event route)))
|
|
148
|
+
|
|
149
|
+
(defn- routed-command [event route]
|
|
150
|
+
(case (:type event)
|
|
151
|
+
("animation.requestScheduleSnippet"
|
|
152
|
+
"animation.requestRemoveSnippet"
|
|
153
|
+
"animation.requestSeekSnippet")
|
|
154
|
+
(animation-command event route)
|
|
155
|
+
|
|
156
|
+
"signal"
|
|
157
|
+
(if (and (= "blink" (:from route))
|
|
158
|
+
(= "prosodic" (:to route))
|
|
159
|
+
(= "blink-fast" (:signal event)))
|
|
160
|
+
{:type "blinkFast"
|
|
161
|
+
:sourceAgency "blink"
|
|
162
|
+
:plan (:plan event)}
|
|
163
|
+
(with-source-agency event route))
|
|
164
|
+
|
|
165
|
+
("eyeHeadTracking.requestGaze"
|
|
166
|
+
"eyeHeadTracking.requestReset"
|
|
167
|
+
"eyeHeadTracking.requestCancel"
|
|
168
|
+
"camera.fact"
|
|
169
|
+
"camera.stale")
|
|
170
|
+
event
|
|
171
|
+
|
|
172
|
+
("transcription.final"
|
|
173
|
+
"transcription.interruption"
|
|
174
|
+
"transcription.audioInterruption")
|
|
175
|
+
(transcription-command event)
|
|
176
|
+
|
|
177
|
+
("conversation.userUtterance"
|
|
178
|
+
"conversation.agentUtterance"
|
|
179
|
+
"conversation.requestResponse"
|
|
180
|
+
"tts.requestSpeak"
|
|
181
|
+
"conversation.cancelRequested")
|
|
182
|
+
(conversation-command event route)
|
|
183
|
+
|
|
184
|
+
("lipSync.command"
|
|
185
|
+
"ttsStatusChanged"
|
|
186
|
+
"ttsSpeechStarted"
|
|
187
|
+
"ttsWordBoundary"
|
|
188
|
+
"ttsSpeechStopped"
|
|
189
|
+
"ttsSpeechEnded")
|
|
190
|
+
(tts-command event route)
|
|
191
|
+
|
|
192
|
+
(with-source-agency event route)))
|
|
193
|
+
|
|
194
|
+
(defn canonical-agency-event
|
|
195
|
+
"Attach the source known by the agency subscription to an outgoing event.
|
|
196
|
+
|
|
197
|
+
Agency payloads are plain data and may be malformed or supplied by an
|
|
198
|
+
injected provider. The character router must not let a payload select another
|
|
199
|
+
agency's outgoing graph edges by spoofing its `agency` field."
|
|
200
|
+
[source event]
|
|
201
|
+
(assoc event :agency source))
|
|
202
|
+
|
|
28
203
|
(defn create-character-agencies [config]
|
|
29
204
|
(let [input-stream (stream/create-stream)
|
|
30
205
|
event-stream (stream/create-stream)
|
|
31
206
|
emit-input (:emit input-stream)
|
|
32
207
|
emit-event (:emit event-stream)
|
|
33
|
-
agency-society (society/normalize-agency-society
|
|
34
|
-
|
|
208
|
+
agency-society (atom (society/normalize-agency-society
|
|
209
|
+
(when config (aget config "agencySociety"))))
|
|
35
210
|
animation-agency (animation/create-animation-agency
|
|
36
|
-
(society/agency-config config agency-society "animation"))
|
|
211
|
+
(society/agency-config config @agency-society "animation"))
|
|
37
212
|
blink-agency (blink/create-blink-agency
|
|
38
|
-
(society/agency-config config agency-society "blink"))
|
|
213
|
+
(society/agency-config config @agency-society "blink"))
|
|
39
214
|
gaze-agency (gaze/create-gaze-agency
|
|
40
|
-
(society/agency-config config agency-society "gaze"))
|
|
215
|
+
(society/agency-config config @agency-society "gaze"))
|
|
41
216
|
eye-head-agency (eye-head/create-eye-head-tracking-agency
|
|
42
|
-
(society/agency-config config agency-society "eyeHeadTracking"))
|
|
217
|
+
(society/agency-config config @agency-society "eyeHeadTracking"))
|
|
43
218
|
gesture-agency (gesture/create-gesture-agency
|
|
44
|
-
(society/agency-config config agency-society "gesture"))
|
|
219
|
+
(society/agency-config config @agency-society "gesture"))
|
|
45
220
|
camera-context-agency (camera-context/create-camera-context-agency
|
|
46
|
-
(society/agency-config config agency-society "cameraContext"))
|
|
221
|
+
(society/agency-config config @agency-society "cameraContext"))
|
|
47
222
|
transcription-agency (transcription/create-transcription-agency
|
|
48
|
-
(society/agency-config config agency-society "transcription"))
|
|
223
|
+
(society/agency-config config @agency-society "transcription"))
|
|
49
224
|
conversation-config (society/agency-config
|
|
50
|
-
config agency-society "conversation")
|
|
225
|
+
config @agency-society "conversation")
|
|
51
226
|
;; The provider is injected once into Conversation's private effector.
|
|
52
227
|
;; The character router never invokes provider functions itself.
|
|
53
228
|
conversation-provider (when config (aget config "conversationProvider"))
|
|
@@ -61,13 +236,13 @@
|
|
|
61
236
|
conversation-agency (conversation/create-conversation-agency
|
|
62
237
|
conversation-options)
|
|
63
238
|
tts-agency (tts/create-tts-agency
|
|
64
|
-
(society/agency-config config agency-society "tts"))
|
|
239
|
+
(society/agency-config config @agency-society "tts"))
|
|
65
240
|
lipsync-runtime (when config (aget config "lipSyncRuntime"))
|
|
66
241
|
lipsync-agency (lipsync/create-lipsync-agency
|
|
67
|
-
(society/agency-config config agency-society "lipSync")
|
|
242
|
+
(society/agency-config config @agency-society "lipSync")
|
|
68
243
|
lipsync-runtime)
|
|
69
244
|
prosodic-agency (prosodic/create-prosodic-agency
|
|
70
|
-
(society/agency-config config agency-society "prosodic"))
|
|
245
|
+
(society/agency-config config @agency-society "prosodic"))
|
|
71
246
|
unsubscribers (atom [])
|
|
72
247
|
disposed? (atom false)]
|
|
73
248
|
(letfn [(track! [unsubscribe]
|
|
@@ -94,35 +269,34 @@
|
|
|
94
269
|
(.call dispatch target (clj->js command))
|
|
95
270
|
true)))
|
|
96
271
|
|
|
97
|
-
(route-
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
:offsetSec (:offsetSec event)}))
|
|
272
|
+
(route-event! [source event]
|
|
273
|
+
(doseq [route (society/route-contexts @agency-society
|
|
274
|
+
source
|
|
275
|
+
event)]
|
|
276
|
+
(when-let [command (routed-command event route)]
|
|
277
|
+
(when (dispatch-to! (:to route) (assoc command :society route))
|
|
278
|
+
;; Route telemetry is emitted only after the receiving
|
|
279
|
+
;; agency accepted the command. Hosts can therefore draw
|
|
280
|
+
;; the real society traffic without reimplementing route
|
|
281
|
+
;; matching, credit admission, or required-edge rules.
|
|
282
|
+
;; Emitting directly to the character event stream also
|
|
283
|
+
;; prevents this diagnostic event from entering routing
|
|
284
|
+
;; again and recursively producing more commands.
|
|
285
|
+
(emit-event {:type "society.routeActivated"
|
|
286
|
+
:agency "character"
|
|
287
|
+
:edgeId (:edgeId route)
|
|
288
|
+
:from source
|
|
289
|
+
:to (:to route)
|
|
290
|
+
:eventType (:type event)
|
|
291
|
+
:credit (:credit route)
|
|
292
|
+
:at (.now js/Date)})))))
|
|
293
|
+
|
|
294
|
+
(emit-agency-event! [source event]
|
|
295
|
+
(let [payload (canonical-agency-event
|
|
296
|
+
source
|
|
297
|
+
(js->clj event :keywordize-keys true))]
|
|
298
|
+
(route-event! source payload)
|
|
299
|
+
(emit-event payload)))
|
|
126
300
|
|
|
127
301
|
(dispatch! [message]
|
|
128
302
|
(when-not @disposed?
|
|
@@ -139,7 +313,7 @@
|
|
|
139
313
|
:agency (or name "unknown")
|
|
140
314
|
:message "Unknown Polymer agency"})
|
|
141
315
|
|
|
142
|
-
(not (society/agency-enabled? agency-society name))
|
|
316
|
+
(not (society/agency-enabled? @agency-society name))
|
|
143
317
|
(emit-event {:type "agencyDisabled"
|
|
144
318
|
:agency name
|
|
145
319
|
:message "Polymer agency is disabled by agencySociety"})
|
|
@@ -159,313 +333,71 @@
|
|
|
159
333
|
:lipSync (js->clj (.snapshot ^js lipsync-agency) :keywordize-keys true)
|
|
160
334
|
:prosodic (js->clj (.snapshot ^js prosodic-agency) :keywordize-keys true)
|
|
161
335
|
:animation (js->clj (.snapshot ^js animation-agency) :keywordize-keys true)
|
|
162
|
-
:agencySociety agency-society}))
|
|
163
|
-
|
|
164
|
-
(route-blink-event! [event]
|
|
165
|
-
(case (:type event)
|
|
166
|
-
"animation.requestScheduleSnippet"
|
|
167
|
-
(schedule-animation! event)
|
|
168
|
-
|
|
169
|
-
"signal"
|
|
170
|
-
(when (and (= "blink" (:agency event))
|
|
171
|
-
(= "blink-fast" (:signal event)))
|
|
172
|
-
(route-command! "blink"
|
|
173
|
-
event
|
|
174
|
-
"prosodic"
|
|
175
|
-
{:type "blinkFast"
|
|
176
|
-
:sourceAgency "blink"
|
|
177
|
-
:plan (:plan event)}))
|
|
178
|
-
|
|
179
|
-
nil))
|
|
180
|
-
|
|
181
|
-
(route-gaze-event! [event]
|
|
182
|
-
(case (:type event)
|
|
183
|
-
("eyeHeadTracking.requestGaze"
|
|
184
|
-
"eyeHeadTracking.requestReset"
|
|
185
|
-
"eyeHeadTracking.requestCancel")
|
|
186
|
-
(route-command! "gaze" event "eyeHeadTracking" event)
|
|
187
|
-
|
|
188
|
-
nil))
|
|
189
|
-
|
|
190
|
-
(route-eye-head-event! [event]
|
|
191
|
-
(case (:type event)
|
|
192
|
-
"animation.requestScheduleSnippet"
|
|
193
|
-
(schedule-animation! event)
|
|
194
|
-
|
|
195
|
-
"animation.requestRemoveSnippet"
|
|
196
|
-
(remove-animation! event)
|
|
197
|
-
|
|
198
|
-
nil))
|
|
199
|
-
|
|
200
|
-
(route-gesture-event! [event]
|
|
201
|
-
(case (:type event)
|
|
202
|
-
"animation.requestScheduleSnippet"
|
|
203
|
-
(schedule-animation! event)
|
|
204
|
-
|
|
205
|
-
"animation.requestRemoveSnippet"
|
|
206
|
-
(remove-animation! event)
|
|
207
|
-
|
|
208
|
-
nil))
|
|
209
|
-
|
|
210
|
-
(route-camera-context-event! [event]
|
|
211
|
-
(case (:type event)
|
|
212
|
-
"camera.fact"
|
|
213
|
-
(route-command! "cameraContext" event "gaze" event)
|
|
214
|
-
|
|
215
|
-
"camera.stale"
|
|
216
|
-
(route-command! "cameraContext" event "gaze" event)
|
|
217
|
-
|
|
218
|
-
nil))
|
|
336
|
+
:agencySociety @agency-society}))
|
|
219
337
|
|
|
220
|
-
(
|
|
221
|
-
(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
(route-command! "transcription"
|
|
236
|
-
event
|
|
237
|
-
"conversation"
|
|
238
|
-
{:type "interrupt"
|
|
239
|
-
:reason "transcription-interruption"
|
|
240
|
-
:text (:text event)
|
|
241
|
-
:source "transcription"})
|
|
242
|
-
|
|
243
|
-
"transcription.audioInterruption"
|
|
244
|
-
(route-command! "transcription"
|
|
245
|
-
event
|
|
246
|
-
"conversation"
|
|
247
|
-
{:type "interrupt"
|
|
248
|
-
:reason "audio-interruption"
|
|
249
|
-
:event event
|
|
250
|
-
:source "transcription"})
|
|
251
|
-
|
|
252
|
-
nil))
|
|
253
|
-
|
|
254
|
-
(route-conversation-event! [event]
|
|
255
|
-
;; Router only: forward conversation facts/requests. Gaze and
|
|
256
|
-
;; Prosodic own local policy through their planners/schedulers.
|
|
257
|
-
(case (:type event)
|
|
258
|
-
("conversation.userUtterance"
|
|
259
|
-
"conversation.agentUtterance")
|
|
260
|
-
(let [fact (assoc event :sourceAgency "conversation")]
|
|
261
|
-
(route-command! "conversation" event "prosodic" fact)
|
|
262
|
-
(route-command! "conversation" event "gaze" fact))
|
|
263
|
-
|
|
264
|
-
"conversation.requestResponse"
|
|
265
|
-
(route-command! "conversation"
|
|
266
|
-
event
|
|
267
|
-
"prosodic"
|
|
268
|
-
(assoc event :sourceAgency "conversation"))
|
|
269
|
-
|
|
270
|
-
"tts.requestSpeak"
|
|
271
|
-
(route-command! "conversation" event "tts" (:command event))
|
|
272
|
-
|
|
273
|
-
"conversation.cancelRequested"
|
|
274
|
-
(let [cancel (assoc event :sourceAgency "conversation")]
|
|
275
|
-
(route-command! "conversation" event "prosodic" cancel)
|
|
276
|
-
(route-command! "conversation" event "gaze" cancel)
|
|
277
|
-
(route-command! "conversation"
|
|
278
|
-
event
|
|
279
|
-
"tts"
|
|
280
|
-
{:type "stop"
|
|
281
|
-
:reason (:reason event)}))
|
|
282
|
-
|
|
283
|
-
nil))
|
|
284
|
-
|
|
285
|
-
(route-tts-event! [event]
|
|
286
|
-
(case (:type event)
|
|
287
|
-
"lipSync.command"
|
|
288
|
-
(route-command! "tts" event "lipSync" (:command event))
|
|
289
|
-
|
|
290
|
-
"ttsStatusChanged"
|
|
291
|
-
(let [status (get-in event [:state :status])]
|
|
292
|
-
(route-command! "tts"
|
|
293
|
-
event
|
|
294
|
-
"conversation"
|
|
295
|
-
{:type "tts.status"
|
|
296
|
-
:status status})
|
|
297
|
-
(route-command! "tts"
|
|
298
|
-
event
|
|
299
|
-
"transcription"
|
|
300
|
-
{:type "tts.status"
|
|
301
|
-
:status status
|
|
302
|
-
:speaking (get-in event [:state :speaking])
|
|
303
|
-
:state (:state event)}))
|
|
304
|
-
|
|
305
|
-
"ttsSpeechStarted"
|
|
306
|
-
(do
|
|
307
|
-
(route-command! "tts"
|
|
308
|
-
event
|
|
309
|
-
"prosodic"
|
|
310
|
-
{:type "speechStarted"
|
|
311
|
-
:sourceAgency "tts"
|
|
312
|
-
:name (:name event)
|
|
313
|
-
:engine (:engine event)})
|
|
314
|
-
(route-command! "tts" event "transcription" event)
|
|
315
|
-
(route-command! "tts"
|
|
316
|
-
event
|
|
317
|
-
"conversation"
|
|
318
|
-
{:type "tts.status"
|
|
319
|
-
:status "speaking"}))
|
|
320
|
-
|
|
321
|
-
"ttsWordBoundary"
|
|
322
|
-
(route-command! "tts"
|
|
323
|
-
event
|
|
324
|
-
"prosodic"
|
|
325
|
-
{:type "wordBoundary"
|
|
326
|
-
:sourceAgency "tts"
|
|
327
|
-
:word (:word event)
|
|
328
|
-
:wordIndex (:wordIndex event)
|
|
329
|
-
:observedElapsedSec (:observedElapsedSec event)
|
|
330
|
-
:hostElapsedSec (:hostElapsedSec event)})
|
|
331
|
-
|
|
332
|
-
"ttsSpeechStopped"
|
|
333
|
-
(do
|
|
334
|
-
(route-command! "tts"
|
|
335
|
-
event
|
|
336
|
-
"prosodic"
|
|
337
|
-
{:type "speechStopped"
|
|
338
|
-
:sourceAgency "tts"
|
|
339
|
-
:reason (:reason event)})
|
|
340
|
-
(route-command! "tts" event "transcription" event)
|
|
341
|
-
(route-command! "tts"
|
|
342
|
-
event
|
|
343
|
-
"conversation"
|
|
344
|
-
{:type "tts.status"
|
|
345
|
-
:status "idle"}))
|
|
346
|
-
|
|
347
|
-
"ttsSpeechEnded"
|
|
348
|
-
(do
|
|
349
|
-
(route-command! "tts"
|
|
350
|
-
event
|
|
351
|
-
"prosodic"
|
|
352
|
-
{:type "speechStopped"
|
|
353
|
-
:sourceAgency "tts"
|
|
354
|
-
:reason "completed"})
|
|
355
|
-
(route-command! "tts" event "transcription" event)
|
|
356
|
-
(route-command! "tts"
|
|
357
|
-
event
|
|
358
|
-
"conversation"
|
|
359
|
-
{:type "tts.status"
|
|
360
|
-
:status "idle"}))
|
|
361
|
-
|
|
362
|
-
nil))
|
|
363
|
-
|
|
364
|
-
(route-lipsync-event! [event]
|
|
365
|
-
(case (:type event)
|
|
366
|
-
"animation.requestScheduleSnippet"
|
|
367
|
-
(schedule-animation! event)
|
|
368
|
-
|
|
369
|
-
"animation.requestRemoveSnippet"
|
|
370
|
-
(remove-animation! event)
|
|
371
|
-
|
|
372
|
-
"animation.requestSeekSnippet"
|
|
373
|
-
(seek-animation! event)
|
|
374
|
-
|
|
375
|
-
nil))
|
|
376
|
-
|
|
377
|
-
(route-prosodic-event! [event]
|
|
378
|
-
(case (:type event)
|
|
379
|
-
"animation.requestScheduleSnippet"
|
|
380
|
-
(schedule-animation! event)
|
|
381
|
-
|
|
382
|
-
"animation.requestRemoveSnippet"
|
|
383
|
-
(remove-animation! event)
|
|
384
|
-
|
|
385
|
-
nil))]
|
|
338
|
+
(update-society-routing! [next-society]
|
|
339
|
+
(when-not @disposed?
|
|
340
|
+
(let [normalized (society/normalize-agency-society next-society)]
|
|
341
|
+
;; This live update changes route admission only. Agency-local
|
|
342
|
+
;; configure/priors still apply when the character system is
|
|
343
|
+
;; created, so a graph editor cannot bypass local planners.
|
|
344
|
+
(reset! agency-society normalized)
|
|
345
|
+
(emit-input {:type "agencySociety.update"
|
|
346
|
+
:agencySociety normalized})
|
|
347
|
+
(emit-event {:type "agencySocietyUpdated"
|
|
348
|
+
:agency "character"
|
|
349
|
+
:agencySociety normalized})
|
|
350
|
+
(clj->js normalized))))
|
|
351
|
+
|
|
352
|
+
]
|
|
386
353
|
;; Fan-in agency events to one character-level event stream for tests,
|
|
387
354
|
;; workers, and future non-React observers. LoomLarge does not need to
|
|
388
355
|
;; consume this stream for Polymer animation playback.
|
|
389
|
-
(track! (.subscribeEvents ^js animation-agency
|
|
390
|
-
|
|
391
|
-
(track! (.subscribeEvents ^js
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
(track! (.subscribeEvents ^js
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
(
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
(fn [event]
|
|
438
|
-
(let [payload (js->clj event :keywordize-keys true)]
|
|
439
|
-
(route-prosodic-event! payload)
|
|
440
|
-
(emit-event payload)))))
|
|
441
|
-
#js {:dispatch dispatch!
|
|
442
|
-
:input (stream/writable-port input-stream dispatch!)
|
|
443
|
-
:events (stream/readable-port event-stream)
|
|
444
|
-
:agencySociety (clj->js agency-society)
|
|
445
|
-
:snapshot snapshot!
|
|
446
|
-
:agency (fn [name]
|
|
447
|
-
(when (society/agency-enabled? agency-society name)
|
|
448
|
-
(agency-by-name name)))
|
|
449
|
-
:subscribeInput (fn [listener] ((:subscribe input-stream) listener))
|
|
450
|
-
:subscribeEvents (fn [listener] ((:subscribe event-stream) listener))
|
|
451
|
-
:subscribe (fn [listener] ((:subscribe event-stream) listener))
|
|
452
|
-
:subscribeStatus (fn [listener] ((:subscribe event-stream) listener))
|
|
453
|
-
:dispose (fn []
|
|
454
|
-
(when-not @disposed?
|
|
455
|
-
(reset! disposed? true)
|
|
456
|
-
(doseq [unsubscribe @unsubscribers]
|
|
457
|
-
(unsubscribe))
|
|
458
|
-
(reset! unsubscribers [])
|
|
459
|
-
(.dispose ^js blink-agency)
|
|
460
|
-
(.dispose ^js gaze-agency)
|
|
461
|
-
(.dispose ^js eye-head-agency)
|
|
462
|
-
(.dispose ^js gesture-agency)
|
|
463
|
-
(.dispose ^js camera-context-agency)
|
|
464
|
-
(.dispose ^js transcription-agency)
|
|
465
|
-
(.dispose ^js conversation-agency)
|
|
466
|
-
(.dispose ^js tts-agency)
|
|
467
|
-
(.dispose ^js lipsync-agency)
|
|
468
|
-
(.dispose ^js prosodic-agency)
|
|
469
|
-
(.dispose ^js animation-agency)
|
|
470
|
-
((:dispose input-stream))
|
|
471
|
-
((:dispose event-stream))))})))
|
|
356
|
+
(track! (.subscribeEvents ^js animation-agency #(emit-agency-event! "animation" %)))
|
|
357
|
+
(track! (.subscribeEvents ^js blink-agency #(emit-agency-event! "blink" %)))
|
|
358
|
+
(track! (.subscribeEvents ^js gaze-agency #(emit-agency-event! "gaze" %)))
|
|
359
|
+
(track! (.subscribeEvents ^js eye-head-agency #(emit-agency-event! "eyeHeadTracking" %)))
|
|
360
|
+
(track! (.subscribeEvents ^js gesture-agency #(emit-agency-event! "gesture" %)))
|
|
361
|
+
(track! (.subscribeEvents ^js camera-context-agency #(emit-agency-event! "cameraContext" %)))
|
|
362
|
+
(track! (.subscribeEvents ^js transcription-agency #(emit-agency-event! "transcription" %)))
|
|
363
|
+
(track! (.subscribeEvents ^js conversation-agency #(emit-agency-event! "conversation" %)))
|
|
364
|
+
(track! (.subscribeEvents ^js tts-agency #(emit-agency-event! "tts" %)))
|
|
365
|
+
(track! (.subscribeEvents ^js lipsync-agency #(emit-agency-event! "lipSync" %)))
|
|
366
|
+
(track! (.subscribeEvents ^js prosodic-agency #(emit-agency-event! "prosodic" %)))
|
|
367
|
+
(let [api #js {:dispatch dispatch!
|
|
368
|
+
:input (stream/writable-port input-stream dispatch!)
|
|
369
|
+
:events (stream/readable-port event-stream)
|
|
370
|
+
:snapshot snapshot!
|
|
371
|
+
:updateSocietyRouting update-society-routing!
|
|
372
|
+
:agency (fn [name]
|
|
373
|
+
(when (society/agency-enabled? @agency-society name)
|
|
374
|
+
(agency-by-name name)))
|
|
375
|
+
:subscribeInput (fn [listener] ((:subscribe input-stream) listener))
|
|
376
|
+
:subscribeEvents (fn [listener] ((:subscribe event-stream) listener))
|
|
377
|
+
:subscribe (fn [listener] ((:subscribe event-stream) listener))
|
|
378
|
+
:subscribeStatus (fn [listener] ((:subscribe event-stream) listener))
|
|
379
|
+
:dispose (fn []
|
|
380
|
+
(when-not @disposed?
|
|
381
|
+
(reset! disposed? true)
|
|
382
|
+
(doseq [unsubscribe @unsubscribers]
|
|
383
|
+
(unsubscribe))
|
|
384
|
+
(reset! unsubscribers [])
|
|
385
|
+
(.dispose ^js blink-agency)
|
|
386
|
+
(.dispose ^js gaze-agency)
|
|
387
|
+
(.dispose ^js eye-head-agency)
|
|
388
|
+
(.dispose ^js gesture-agency)
|
|
389
|
+
(.dispose ^js camera-context-agency)
|
|
390
|
+
(.dispose ^js transcription-agency)
|
|
391
|
+
(.dispose ^js conversation-agency)
|
|
392
|
+
(.dispose ^js tts-agency)
|
|
393
|
+
(.dispose ^js lipsync-agency)
|
|
394
|
+
(.dispose ^js prosodic-agency)
|
|
395
|
+
(.dispose ^js animation-agency)
|
|
396
|
+
((:dispose input-stream))
|
|
397
|
+
((:dispose event-stream))))}]
|
|
398
|
+
(js/Object.defineProperty
|
|
399
|
+
api
|
|
400
|
+
"agencySociety"
|
|
401
|
+
#js {:enumerable true
|
|
402
|
+
:get #(clj->js @agency-society)})
|
|
403
|
+
api))))
|