From 59ec7f599e314160385fe02ff420f3cd626031cb Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 1 Apr 2015 14:05:55 -0700 Subject: [PATCH] text-to-speech: simple cross-platform text-to-speech. --- extra/text-to-speech/authors.txt | 1 + extra/text-to-speech/linux/linux.factor | 10 ++++++++ extra/text-to-speech/macosx/macosx.factor | 9 +++++++ extra/text-to-speech/summary.txt | 1 + extra/text-to-speech/text-to-speech.factor | 28 +++++++++++++++++++++ extra/text-to-speech/windows/platforms.txt | 1 + extra/text-to-speech/windows/windows.factor | 9 +++++++ 7 files changed, 59 insertions(+) create mode 100644 extra/text-to-speech/authors.txt create mode 100644 extra/text-to-speech/linux/linux.factor create mode 100644 extra/text-to-speech/macosx/macosx.factor create mode 100644 extra/text-to-speech/summary.txt create mode 100644 extra/text-to-speech/text-to-speech.factor create mode 100644 extra/text-to-speech/windows/platforms.txt create mode 100644 extra/text-to-speech/windows/windows.factor diff --git a/extra/text-to-speech/authors.txt b/extra/text-to-speech/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/text-to-speech/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/text-to-speech/linux/linux.factor b/extra/text-to-speech/linux/linux.factor new file mode 100644 index 0000000000..a23f3f29e1 --- /dev/null +++ b/extra/text-to-speech/linux/linux.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: formatting io io.encodings.utf8 io.launcher system +text-to-speech ; + +IN: text-to-speech.linux + +M: linux speak-text + "festival --tts" utf8 [ print ] with-process-writer ; diff --git a/extra/text-to-speech/macosx/macosx.factor b/extra/text-to-speech/macosx/macosx.factor new file mode 100644 index 0000000000..5258332f27 --- /dev/null +++ b/extra/text-to-speech/macosx/macosx.factor @@ -0,0 +1,9 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: formatting io.launcher system text-to-speech ; + +IN: text-to-speech.macosx + +M: macosx speak-text + "say \"%s\"" sprintf try-process ; diff --git a/extra/text-to-speech/summary.txt b/extra/text-to-speech/summary.txt new file mode 100644 index 0000000000..d4f3650d59 --- /dev/null +++ b/extra/text-to-speech/summary.txt @@ -0,0 +1 @@ +Text-to-speech utility diff --git a/extra/text-to-speech/text-to-speech.factor b/extra/text-to-speech/text-to-speech.factor new file mode 100644 index 0000000000..088d745f96 --- /dev/null +++ b/extra/text-to-speech/text-to-speech.factor @@ -0,0 +1,28 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: combinators generic kernel math math.text.english present +strings system ui.operations vocabs ; + +IN: text-to-speech + +! 1. "say" +! 2. festival, freetts, gnuspeech, espeech, flite, etc. +! 3. core-audio? +! 4. use google-translate-tts, download and play? + +HOOK: speak-text os ( str -- ) + +{ + { [ os macosx? ] [ "text-to-speech.macosx" ] } + { [ os linux? ] [ "text-to-speech.linux" ] } + { [ os windows? ] [ "text-to-speech.windows" ] } +} cond require + +GENERIC: speak ( obj -- ) + +M: object speak present speak-text ; + +M: integer speak number>text speak-text ; + +[ \ present ?lookup-method ] \ speak H{ } define-operation diff --git a/extra/text-to-speech/windows/platforms.txt b/extra/text-to-speech/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/extra/text-to-speech/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/extra/text-to-speech/windows/windows.factor b/extra/text-to-speech/windows/windows.factor new file mode 100644 index 0000000000..d941ce1f43 --- /dev/null +++ b/extra/text-to-speech/windows/windows.factor @@ -0,0 +1,9 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: google.translate system text-to-speech windows.winmm ; + +IN: text-to-speech.windows + +M: windows speak-text + translate-tts open-command play-command close-command ;