An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# vocloj

You talk to the computer. The computer talks to you. Brought to you by
sweet sweet parens.

[![cljdoc badge](https://cljdoc.org/badge/com.github.brianium/vocloj)](https://cljdoc.org/d/com.github.brianium/vocloj/CURRENT) [![Clojars Project](https://img.shields.io/clojars/v/com.github.brianium/vocloj.svg)](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 (