https://github.com/brianium/vocloj
Clojure(Script) voice recognition and synthesis
https://github.com/brianium/vocloj
Last synced: about 1 year ago
JSON representation
Clojure(Script) voice recognition and synthesis
- Host: GitHub
- URL: https://github.com/brianium/vocloj
- Owner: brianium
- Created: 2022-01-09T01:44:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-01T13:39:42.000Z (over 4 years ago)
- Last Synced: 2025-03-18T05:56:28.064Z (about 1 year ago)
- Language: Clojure
- Homepage: https://brianium.github.io/vocloj/
- Size: 2.68 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vocloj
You talk to the computer. The computer talks to you. Brought to you by
sweet sweet parens.
[](https://cljdoc.org/d/com.github.brianium/vocloj/CURRENT) [](https://clojars.org/com.github.brianium/vocloj)
## Table of contents
- [Using vocloj](#using-vocloj)
- [Web](#voclojweb)
- [Demo](https://brianium.github.io/vocloj/)
- [src](https://github.com/brianium/vocloj/blob/main/dev/cljs/vocloj/dev.cljs)
- [API Docs](https://cljdoc.org/d/com.github.brianium/vocloj/CURRENT)
- [State machines](#state-machines)
- [add-effect](#add-effect)
- [current-state](#current-state)
- [Recognition](#recognition)
- [Synthesis](#synthesis)
- [Microphone Streams](#microphone-streams)
## Using vocloj
Clojure(Script) is great. Speech synthesis and recognition are fun and probably useful. The aim of vocloj is to make working with speech synthesis and recognition across different platforms simple. For now only native browser APIs are supported.
```clojure
(require '[vocloj.core :as vocloj.core]
'[vocloj.web :as vocloj.web])
;;; Recognition
(def recognizer (vocloj.web/create-recognizer {:continuous? true}))
(vocloj.core/listen recognizer #(println %))
;; Omitting a handler will return a core.async channel
(let [ch (vocloj.core/listen recognizer)]
(go-loop []
(println ( (web/create-synthesizer)
(core/add-effect ::logger (fn [synth old-state new-state]
(println new-state)))
(core/add-effect ::resumed :paused :speaking #(println "speaking again"))))
```
### current-state
Returns the current state of a state machine as a hash map. For instance, the web based implementation of speech synthesis stores available voices in state:
```clojure
(require '[vocloj.web :as web]
'[vocloj.core :as core])
(def synthesizer (web/create-synthesizer))
;; Get available voices
(def voices (-> synthesizer core/current-state :voices))
```
## Recognition
Recognizers are started and stopped. The easiest way to leverage a recognizer is to create one and use
`vocloj.core/listen` to obtain a channel or use a callback.
```clojure
(require '[vocloj.core :as vocloj.core]
'[vocloj.web :as vocloj.web])
(def recognizer (vocloj.web/create-recognizer {:continuous? true}))
(vocloj.core/listen recognizer #(println %))
;; Omitting a handler will return a core.async channel
(let [ch (vocloj.core/listen recognizer)]
(go-loop []
(println (