1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
* BRLTTY - A background process providing access to the Linux console (when in
* text mode) for a blind person using a refreshable braille display.
*
* Copyright (C) 1995-2003 by The BRLTTY Team. All rights reserved.
*
* BRLTTY comes with ABSOLUTELY NO WARRANTY.
*
* This is free software, placed under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation. Please see the file COPYING for details.
*
* Web Page: http://mielke.cc/brltty/
*
* This software is maintained by Dave Mielke <dave@mielke.cc>.
*/
/* GenericSay/speech.c - To use a generic 'say' command, like for the
* rsynth package.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Programs/spk.h"
#include "Programs/misc.h"
typedef enum {
PARM_COMMAND
} DriverParameter;
#define SPKPARMS "command"
#include "Programs/spk_driver.h"
#include "speech.h"
static const char *commandPath; /* default full path for the say command */
static FILE *commandStream = NULL;
static void
spk_identify (void)
{
LogPrint(LOG_NOTICE, "Generic Say Driver");
}
static int
spk_open (char **parameters)
{
const char *command = parameters[PARM_COMMAND];
commandPath = *command? command: SAY_CMD;
LogPrint(LOG_INFO, "Speech Command: %s", commandPath);
return 1;
}
static void
spk_say (const unsigned char *buffer, int length)
{
if (!commandStream)
commandStream = popen(commandPath, "w");
if (commandStream)
{
const char *trailer = "\n";
fwrite(buffer, length, 1, commandStream);
fwrite(trailer, strlen(trailer), 1, commandStream);
fflush(commandStream);
}
}
static void
spk_mute (void)
{
if (commandStream)
{
pclose(commandStream);
commandStream = NULL;
}
}
static void
spk_close (void)
{
spk_mute();
}
|