Edinburgh Speech Tools 2.4-release
mplayer.cc
1/*************************************************************************/
2/* */
3/* Centre for Speech Technology Research */
4/* University of Edinburgh, UK */
5/* Copyright (c) 1995,1996 */
6/* All Rights Reserved. */
7/* */
8/* Permission is hereby granted, free of charge, to use and distribute */
9/* this software and its documentation without restriction, including */
10/* without limitation the rights to use, copy, modify, merge, publish, */
11/* distribute, sublicense, and/or sell copies of this work, and to */
12/* permit persons to whom this work is furnished to do so, subject to */
13/* the following conditions: */
14/* 1. The code must retain the above copyright notice, this list of */
15/* conditions and the following disclaimer. */
16/* 2. Any modifications must be clearly marked as such. */
17/* 3. Original authors' names are not deleted. */
18/* 4. The authors' names are not used to endorse or promote products */
19/* derived from this software without specific prior written */
20/* permission. */
21/* */
22/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30/* THIS SOFTWARE. */
31/* */
32/*************************************************************************/
33/* Author : Richard Caley */
34/* Date : August 1997 */
35/*-----------------------------------------------------------------------*/
36/* Optional 16bit linear support for Windows NT/95 */
37/* */
38/*=======================================================================*/
39
40#include <cstdio>
41#include "EST_cutils.h"
42#include "EST_Wave.h"
43#include "EST_Option.h"
44#include "EST_io_aux.h"
45#include "EST_Pathname.h"
46
47#ifdef SUPPORT_MPLAYER
48
49int mplayer_supported = TRUE;
50
51static EST_Pathname tempfile;
52static EST_Pathname temppath;
53static EST_Pathname tempdir;
54
55static void find_tempfile(void)
56{
57 const char *s=NULL;
58
59 if (!(s=getenv("TMP")))
60 if (!(s=getenv("TMPDIR")))
61 if (!(s=getenv("TEMPDIR")))
62 s="\tmp";
63
64 tempdir = s;
65
66 char buffer[512];
67 sprintf(buffer, "est%4d.wav", getpid());
68 tempfile = buffer;
69 temppath = EST_Pathname::append(tempdir.as_directory(), tempfile);
70}
71
72int play_mplayer_wave(EST_Wave &inwave, EST_Option &al)
73{
74
75 if (tempfile == "")
76 find_tempfile();
77
78 inwave.save(temppath, "riff");
79
80 char command[1000];
81
82 sprintf(command,
83 "mplayer /play %s\\%s",
84 (const char *)tempdir,
85 (const char *)tempfile);
86
87 cout << "command '" << command <<"'\n";
88 system(command);
89
90 unlink(temppath);
91
92 return 1;
93}
94
95#else
96int mplayer_supported = FALSE;
97
98int play_mplayer_wave(EST_Wave &inwave, EST_Option &al)
99{
100 (void)inwave;
101 (void)al;
102 cerr << "Windows mplayer not supported" << endl;
103 return -1;
104}
105
106#endif