]> gitweb.factorcode.org Git - factor.git/blob - extra/text-to-speech/text-to-speech.factor
factor: more top level forms.
[factor.git] / extra / text-to-speech / text-to-speech.factor
1 ! Copyright (C) 2013 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: combinators command-line generic io kernel math
5 math.text.english namespaces present sequences splitting
6 strings system ui.operations vocabs ;
7
8 IN: text-to-speech
9
10 ! 1. "say"
11 ! 2. festival, freetts, gnuspeech, espeech, flite, etc.
12 ! 3. core-audio?
13 ! 4. use google-translate-tts, download and play?
14
15 HOOK: speak-text os ( str -- )
16
17 USE-LINUX: text-to-speech.linux
18 USE-MACOSX: text-to-speech.macosx
19 USE-WINDOWS: text-to-speech.windows
20
21 GENERIC: speak ( obj -- )
22
23 M: object speak present speak-text ;
24
25 M: integer speak number>text speak-text ;
26
27 [ \ present ?lookup-method ] \ speak H{ } define-operation
28
29 : speak-main ( -- )
30     command-line get [
31         [ speak ] each-line
32     ] [
33         join-words speak
34     ] if-empty ;
35
36 MAIN: speak-main