-
Notifications
You must be signed in to change notification settings - Fork 28
/
updater.scm
94 lines (73 loc) · 2.27 KB
/
updater.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
;; File: updater.scm
;; Author: Eskender Besrat <[email protected]>
;; License: AGPL
;; Date: June, 2018
;;; -----------------------------------------------------------------------------
;;; This file contains temporary code that updates global variables for detectors
;;; for demo purpose
;;; -----------------------------------------------------------------------------
; Make global variables
(define-public global-face (make-hash-table))
(hash-set! global-face 'update-time -100)
(define-public global-smile (make-hash-table))
(hash-set! global-smile 'update-time -100)
(define-public global-salient (make-hash-table))
(hash-set! global-salient 'update-time -100)
(define (updater)
(define txt-str-prev "")
(while #t
(let ((ret-face (det-face))
(ret-smile (det-face-smile))
(ret-salient (det-salient-point))
(txt-str "")
(ghost-result '()))
(if (not (string-null? ret-face))
(begin
(hash-set! global-face 'faces (string-split ret-face #\;))
(hash-set! global-face 'update-time (current-time))
)
)
(if (not (string-null? ret-smile))
(begin
; For the time being only detect smile for the first face
(let* ((faces (string-split ret-smile #\;))
(face (list-ref faces 0))
(smile (list-ref (string-split face #\,) 3)))
(if (equal? smile "true")
(begin
(hash-set! global-smile 'face face)
(hash-set! global-smile 'update-time (current-time))
)
)
)
)
)
(if (not (string-null? ret-salient))
(begin
(hash-set! global-salient 'loc (string-split ret-salient #\,))
(hash-set! global-salient 'update-time (current-time))
)
)
#|
; Finally send text output to stt when there is one
; Note: This code is only for demo (stt input should be read from port)
(set! ghost-result (ghost-get-result))
(for-each (lambda (a)
(set! txt-str (string-trim (string-append txt-str " " (cog-name a))))
)ghost-result
)
(if (equal? txt-str txt-str-prev)
(continue)
(begin
(display (string-append "updater: " txt-str))
(act-say txt-str)
(set! txt-str-prev txt-str)
)
)
|#
)
(usleep 10000)
)
)
; Start the update function in a thread
(define update-thread (call-with-new-thread updater))