From 0b187e217e9336b41ffa436dae08d6be8f23e7a0 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 30 Jan 2016 10:46:56 +0000 Subject: [PATCH] Use the same logic when calling sox in readclause.c as compiledata.c for portability. --- src/libespeak-ng/readclause.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 2f7cba39..a615a68f 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -806,7 +806,6 @@ static espeak_ng_STATUS LoadSoundFile(const char *fname, int index, espeak_ng_ER } f = NULL; -#ifdef PLATFORM_POSIX if ((f = fopen(fname, "rb")) != NULL) { int ix; int fd_temp; @@ -827,16 +826,19 @@ static espeak_ng_STATUS LoadSoundFile(const char *fname, int index, espeak_ng_ER fclose(f); f = NULL; +#ifdef PLATFORM_POSIX strcpy(fname_temp, "/tmp/espeakXXXXXX"); - if ((fd_temp = mkstemp(fname_temp)) >= 0) { + if ((fd_temp = mkstemp(fname_temp)) >= 0) close(fd_temp); - sprintf(command, "sox \"%s\" -r %d -c1 -t wav %s\n", fname, samplerate, fname_temp); - if (system(command) == 0) - fname = fname_temp; - } +#else + strcpy(fname_temp, tmpnam(NULL)); +#endif + + sprintf(command, "sox \"%s\" -r %d -c1 -t wav %s\n", fname, samplerate, fname_temp); + if (system(command) == 0) + fname = fname_temp; } } -#endif if (f == NULL) { f = fopen(fname, "rb");