]> gitweb.factorcode.org Git - factor.git/blob - extra/text-to-speech/text-to-speech.factor
calendar.format: make duration>human-readable more human readable
[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 {
18     { [ os macosx?  ] [ "text-to-speech.macosx"  ] }
19     { [ os linux?   ] [ "text-to-speech.linux"   ] }
20     { [ os windows? ] [ "text-to-speech.windows" ] }
21 } cond require
22
23 GENERIC: speak ( obj -- )
24
25 M: object speak present speak-text ;
26
27 M: integer speak number>text speak-text ;
28
29 [ \ present ?lookup-method ] \ speak H{ } define-operation
30
31 : speak-main ( -- )
32     command-line get [
33         [ speak ] each-line
34     ] [
35         join-words speak
36     ] if-empty ;
37
38 MAIN: speak-main