1 /*****************************************************************************
2 * speaker.cpp - QStarDict, a StarDict clone written using Qt *
3 * Copyright (C) 2008 Alexander Rodin *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License along *
16 * with this program; if not, write to the Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 *****************************************************************************/
30 m_speechProcess = new QProcess;
32 m_speechCmd = settings.value("Speaker/speechCmd", "espeak").toString();
38 settings.setValue("Speaker/speechCmd", m_speechCmd);
39 delete m_speechProcess;
42 void Speaker::speak(const QString &word)
44 if (m_speechCmd.isEmpty())
47 if (m_speechProcess->state() != QProcess::NotRunning)
48 m_speechProcess->kill();
50 QString s = m_speechCmd;
51 s.replace("%s", word);
52 m_speechProcess->start(s, QIODevice::WriteOnly);
53 if (! m_speechProcess->waitForStarted())
55 if (! m_speechCmd.contains("%s"))
57 m_speechProcess->write(word.toUtf8());
58 m_speechProcess->closeWriteChannel();
64 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc