commit a59d743bcd373da739e6b518516df1f7ad8f48b7
parent 68a3f27de433bdb5ee557d9f8befa31c8556dd60
Author: Yuval Langer <yuval.langer@gmail.com>
Date: Sun, 18 Jun 2023 20:31:42 +0300
Make advances on the espeak-ng loop.
Diffstat:
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/clipboard-speaker.scm b/clipboard-speaker.scm
@@ -115,7 +115,6 @@
(define (mkfifo path mode)
(mknod path 'fifo mode 0))
-
(define (read-clipboard clipboard-type)
;; Popen `xsel -p` or `xsel -b` as an output port.
(define xsel-port
@@ -147,11 +146,13 @@
;; #:input input-port))
(define* (espeak-ng-speak text-to-speak words-per-minute)
- (open-pipe* OPEN_READ
- "espeak-ng"
- "-s"
- (number->string words-per-minute)
- text-to-speak))
+ (define espeak-ng-process-pid
+ (spawn "espeak-ng" `("espeak-ng"
+ "-s"
+ ,(number->string words-per-minute)
+ ,text-to-speak)))
+
+ espeak-ng-process-pid)
(define (make-fifo-ports fifo-file-path)
@@ -190,7 +191,6 @@
;; (espeak-loop fifo-read-port
;; pipe-write-port))
-
(define (espeak-loop fifo-read-port words-per-minute)
(define text-to-speak
(string-append (get-line fifo-read-port)
@@ -198,8 +198,10 @@
(display text-to-speak)
- (espeak-ng-speak text-to-speak
- words-per-minute)
+ (define espeak-ng-pid (espeak-ng-speak text-to-speak
+ words-per-minute))
+
+ (waitpid espeak-ng-pid)
(espeak-loop fifo-read-port
words-per-minute))
@@ -240,11 +242,12 @@
(define pid-file-port (open-file-locked (config:option-ref options
'pid-file-path)))
- (put-string pid-file-port (number->string (getpid)))
- (force-output pid-file-port)
-
- ;; We're the speaker server.
+ (format #t "pid file port: ~a\n" pid-file-port)
(when pid-file-port
+ ;; We're the speaker server.
+ (put-string pid-file-port (number->string (getpid)))
+ (force-output pid-file-port)
+
(espeak-loop (car fifo-r+w)
(config:option-ref options 'words-per-minute)))