Add a simple text-to-speech challenge type.
authorCarl Worth <cworth@cworth.org>
Wed, 9 Jun 2010 14:42:26 +0000 (07:42 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 9 Jun 2010 14:44:17 +0000 (07:44 -0700)
This is implemented by doing the following:

     echo $challenge | festival --tts

But we actually make that invocation in a little script named mnemon-tts
because I'm too lazy to code up a custom invocation for this challenge
type.

mnemon-tts [new file with mode: 0755]
mnemon.c

diff --git a/mnemon-tts b/mnemon-tts
new file mode 100755 (executable)
index 0000000..d4825ce
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+arg="$@"
+
+# Strip undesired directory component
+dir=$(dirname "$arg")
+
+text="${arg#$dir/}"
+
+echo "$text" | festival --tts
index 69ac5b10cb9c639e18fcc1b6be337d6bba8648a0..3dee0347e153c5e2a5c00f93d717f57605fd787d 100644 (file)
--- a/mnemon.c
+++ b/mnemon.c
@@ -65,7 +65,8 @@ typedef enum {
     CHALLENGE_TYPE_TEXT,
     CHALLENGE_TYPE_IMAGE,
     CHALLENGE_TYPE_AUDIO,
-    CHALLENGE_TYPE_MIDI
+    CHALLENGE_TYPE_MIDI,
+    CHALLENGE_TYPE_TEXT_TO_SPEECH
 } challenge_type_t;
 
 typedef struct _category {
@@ -295,6 +296,9 @@ category_print (category_t  *category,
     case CHALLENGE_TYPE_MIDI:
        fprintf (file, "midi");
        break;
+    case CHALLENGE_TYPE_TEXT_TO_SPEECH:
+       fprintf (file, "text-to-speech");
+       break;
     }
     fprintf (file, "\n\n");
 
@@ -665,6 +669,8 @@ mnemon_load_category (mnemon_t              *mnemon,
                category->challenge_type = CHALLENGE_TYPE_AUDIO;
            } else if (strcmp (value, "midi") == 0) {
                category->challenge_type = CHALLENGE_TYPE_MIDI;
+           } else if (strcmp (value, "text-to-speech") == 0) {
+               category->challenge_type = CHALLENGE_TYPE_TEXT_TO_SPEECH;
            } else {
                fprintf (stderr, "Unknown value for \"challenge\" option \"%s\" at %s:%d\n",
                         value, path, line_count);
@@ -1208,6 +1214,9 @@ mnemon_show_challenge (mnemon_t *mnemon,
     case CHALLENGE_TYPE_MIDI:
        program = "timidity -Os";
        break;
+    case CHALLENGE_TYPE_TEXT_TO_SPEECH:
+       program = "mnemon-tts";
+       break;
     }
 
     xasprintf (&command, "%s %s/%s >/dev/null 2>&1 &",