mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: use the new kspeech library for Text-To-Speech
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b74771806a
commit
27fc8002d6
9 changed files with 52 additions and 154 deletions
|
@ -4,6 +4,7 @@ target_link_libraries(kate_kttsd
|
|||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KTEXTEDITOR_LIBS}
|
||||
${KDE4_KPARTS_LIBS}
|
||||
${KDE4_KSPEECH_LIBS}
|
||||
kateinterfaces
|
||||
)
|
||||
|
||||
|
|
|
@ -3,61 +3,10 @@ Type=Service
|
|||
ServiceTypes=Kate/Plugin
|
||||
X-KDE-Library=kate_kttsd
|
||||
X-Kate-Version=3.0
|
||||
Icon=kttsd
|
||||
Name=Jovie Text-to-Speech
|
||||
Name[bg]=Jovie - четене на текст
|
||||
Name[bs]=Jovie (tekst‑u‑govor)
|
||||
Name[ca]=Text a veu Jovie
|
||||
Name[ca@valencia]=Text a veu Jovie
|
||||
Name[cs]=Hlasová syntéza Jovie
|
||||
Name[da]=Jovie tekst-til-tale
|
||||
Name[de]=Jovie-Sprachausgabe
|
||||
Name[el]=Jovie Text-to-Speech
|
||||
Name[en_GB]=Jovie Text-to-Speech
|
||||
Name[es]=Complemento de texto hablado Jovie para KTextEditor
|
||||
Name[et]=Jovie teksti ettelugemine
|
||||
Name[eu]=Jovie testutik-hizketara
|
||||
Name[fi]=Jovie-puhesyntetisaattori
|
||||
Name[fr]=Synthèse vocale « Jovie »
|
||||
Name[ga]=Téacs-go-Caint Jovie
|
||||
Name[gl]=Texto-para-fala mediante Jovie
|
||||
Name[he]=מנוע טקסט לדיבור Jovie
|
||||
Name[hu]=Jovie szövegfelolvasó
|
||||
Name[ia]=Texto-a-Discurso (TextToSpeech) Jovie
|
||||
Name[is]=Jovie texti-í-tal
|
||||
Name[it]=Pronuncia di Jovie
|
||||
Name[ja]=Jovie 読み上げプラグイン
|
||||
Name[kk]=Jovie - мәтінді дауыстап оқу
|
||||
Name[km]=អត្ថបទត្រូវនិយាយរបស់ Jovie
|
||||
Name[ko]=Jovie 텍스트 음성 변환
|
||||
Name[lt]=Jovie teksto vertimas į kalbą
|
||||
Name[lv]=Jovie no teksta uz runu
|
||||
Name[mr]=जोव्ही मजकुर बोलून दाखवणारा
|
||||
Name[nb]=Jovie tekst til tale
|
||||
Name[nds]=Vörlesermoduul "Jovie"
|
||||
Name[nl]=Jovie tekst-naar-spraak
|
||||
Name[nn]=Jovie tekst-til-tale
|
||||
Name[pa]=ਜੋਵੀ ਟੈਕਸਟ ਤੋਂ ਬੋਲੀ
|
||||
Name[pl]=Tekst-na-mowę Jovie
|
||||
Name[pt]=Texto-para-Fala do Jovie
|
||||
Name[pt_BR]=Texto-para-fala Jovie
|
||||
Name[ro]=Text-în-vorbire Jovi
|
||||
Name[ru]=Служба синтеза речи Jovie
|
||||
Name[si]=Jovie පෙල-කියවීමට
|
||||
Name[sk]=Jovie Text-na-Reč
|
||||
Name[sl]=Besedilo-v-govor Jovie
|
||||
Name[sr]=Џови (текст‑у‑говор)
|
||||
Name[sr@ijekavian]=Џови (текст‑у‑говор)
|
||||
Name[sr@ijekavianlatin]=Džovi (tekst‑u‑govor)
|
||||
Name[sr@latin]=Džovi (tekst‑u‑govor)
|
||||
Name[sv]=Jovie text-till-tal
|
||||
Name[tg]=Барномаи талаффузи матни Jovie
|
||||
Name[tr]=Jovie Metin Okuma
|
||||
Name[ug]=Jovie تېكىستتىن ئاۋازغا
|
||||
Name[uk]=Синтез мовлення з тексту Jovie
|
||||
Name[x-test]=xxJovie Text-to-Speechxx
|
||||
Name[zh_CN]=Jovie 语音合成
|
||||
Name[zh_TW]=Jovie 文字轉語音
|
||||
Icon=preferences-desktop-text-to-speech
|
||||
Name=Text-to-Speech
|
||||
Name[bg]=Четене на текст
|
||||
Name[x-test]=xxText-to-Speechxx
|
||||
Comment=Adds a menu entry for speaking the text
|
||||
Comment[ar]=يضيف مُدخلة قائمة لنطق النصّ
|
||||
Comment[ast]=Amestar una entrada al menú pa lleer el testu
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <ktexteditor/document.h>
|
||||
// Qt includes.
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
// KDE includes.
|
||||
#include <kmessagebox.h>
|
||||
|
@ -34,10 +33,11 @@
|
|||
#include <ktoolinvocation.h>
|
||||
#include <KActionCollection>
|
||||
#include <KAboutData>
|
||||
#include <KSpeech>
|
||||
#include <kate/mainwindow.h>
|
||||
|
||||
K_PLUGIN_FACTORY(KateKttsdFactory, registerPlugin<KateKttsdPlugin>();)
|
||||
K_EXPORT_PLUGIN(KateKttsdFactory(KAboutData("kate_kttsd","kate_kttsd",ki18n("Jovie Text-to-Speech Plugin"), "0.1", ki18n("Jovie Text-to-Speech Plugin"), KAboutData::License_LGPL_V2)) )
|
||||
K_EXPORT_PLUGIN(KateKttsdFactory(KAboutData("kate_kttsd","kate_kttsd",ki18n("Text-to-Speech Plugin"), "0.1", ki18n("Text-to-Speech Plugin"), KAboutData::License_LGPL_V2)) )
|
||||
|
||||
KateKttsdPlugin::KateKttsdPlugin(QObject* parent, const QList<QVariant>&)
|
||||
: Kate::Plugin ((Kate::Application*)parent)
|
||||
|
@ -84,22 +84,14 @@ void KateKttsdPluginView::slotReadOut()
|
|||
if ( text.isEmpty() )
|
||||
return;
|
||||
|
||||
// If KTTSD not running, start it.
|
||||
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kttsd"))
|
||||
if (!KSpeech::isSupported())
|
||||
{
|
||||
QString error;
|
||||
if (KToolInvocation::startServiceByDesktopName("kttsd", QStringList(), &error))
|
||||
{
|
||||
KMessageBox::error(0, i18n( "Starting Jovie Text-to-Speech Service Failed"), error );
|
||||
return;
|
||||
}
|
||||
KMessageBox::error(0, i18n( "Text-to-Speech not supported") );
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusInterface kttsd( "org.kde.kttsd", "/KSpeech", "org.kde.KSpeech" );
|
||||
|
||||
QDBusReply<int> reply = kttsd.call("say", text,0);
|
||||
if ( !reply.isValid())
|
||||
KMessageBox::error( 0, i18n( "D-Bus Call Failed" ),
|
||||
i18n( "The D-Bus call say failed." ));
|
||||
KSpeech kspeech(this);
|
||||
kspeech.setSpeechID(QString::fromLatin1("kate"));
|
||||
kspeech.say(text);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,13 +26,11 @@ set(knotifyplugin_HEADERS
|
|||
${CMAKE_CURRENT_BINARY_DIR}/knotify_export.h
|
||||
)
|
||||
|
||||
qt4_add_dbus_interfaces(knotify_SRCS ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.KSpeech.xml)
|
||||
|
||||
add_executable( knotify ${knotify_SRCS})
|
||||
|
||||
add_library( knotifyplugin SHARED ${knotifyplugin_SRCS})
|
||||
|
||||
target_link_libraries( knotify ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} knotifyplugin kmediaplayer)
|
||||
target_link_libraries( knotify ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} ${KDE4_KSPEECH_LIBS} knotifyplugin kmediaplayer)
|
||||
|
||||
target_link_libraries( knotifyplugin ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS})
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "knotify.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
// KDE headers
|
||||
#include <kapplication.h>
|
||||
#include <kconfig.h>
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <klocale.h>
|
||||
#include <knotifyconfig.h>
|
||||
|
||||
NotifyByKTTS::NotifyByKTTS(QObject *parent) : KNotifyPlugin(parent),m_kspeech(0), tryToStartKttsd( false )
|
||||
NotifyByKTTS::NotifyByKTTS(QObject *parent)
|
||||
: KNotifyPlugin(parent),
|
||||
m_kspeech(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,67 +38,39 @@ NotifyByKTTS::~NotifyByKTTS()
|
|||
{
|
||||
}
|
||||
|
||||
void NotifyByKTTS::setupKttsd()
|
||||
{
|
||||
m_kspeech = new org::kde::KSpeech("org.kde.kttsd", "/KSpeech", QDBusConnection::sessionBus());
|
||||
m_kspeech->setParent(this);
|
||||
m_kspeech->setApplicationName("KNotify");
|
||||
|
||||
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(this);
|
||||
watcher->setConnection(QDBusConnection::sessionBus());
|
||||
watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
||||
watcher->addWatchedService("org.kde.kttsd");
|
||||
connect(watcher, SIGNAL(serviceUnregistered( const QString & ) ), this, SLOT( removeSpeech() ));
|
||||
}
|
||||
|
||||
void NotifyByKTTS::notify( int id, KNotifyConfig * config )
|
||||
{
|
||||
if( !m_kspeech)
|
||||
{
|
||||
if ( tryToStartKttsd ) //don't try to restart it all the time.
|
||||
return;
|
||||
// If KTTSD not running, start it.
|
||||
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kttsd"))
|
||||
{
|
||||
QString error;
|
||||
if (KToolInvocation::startServiceByDesktopName("kttsd", QStringList(), &error))
|
||||
{
|
||||
KMessageBox::error(0, i18n( "Starting Jovie Text-to-Speech Service Failed"), error );
|
||||
tryToStartKttsd = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
setupKttsd();
|
||||
}
|
||||
if ( !KSpeech::isSupported() )
|
||||
return;
|
||||
|
||||
QString say = config->readEntry( "KTTS" );
|
||||
if (!m_kspeech) {
|
||||
m_kspeech = new KSpeech(this);
|
||||
}
|
||||
|
||||
if (!say.isEmpty()) {
|
||||
QHash<QChar,QString> subst;
|
||||
subst.insert( 'e', config->eventid );
|
||||
subst.insert( 'a', config->appname );
|
||||
subst.insert( 's', config->text );
|
||||
subst.insert( 'w', QString::number( (quintptr)config->winId ));
|
||||
subst.insert( 'i', QString::number( id ));
|
||||
subst.insert( 'm', config->text );
|
||||
say = KMacroExpander::expandMacrosShellQuote( say, subst );
|
||||
}
|
||||
QString say = config->readEntry( "KTTS" );
|
||||
QString appId = config->appname;
|
||||
if (appId.isEmpty()) {
|
||||
appId = QString::fromLatin1("KNotify");
|
||||
}
|
||||
|
||||
if ( say.isEmpty() )
|
||||
say = config->text; // fallback
|
||||
if (!say.isEmpty()) {
|
||||
QHash<QChar,QString> subst;
|
||||
subst.insert( 'e', config->eventid );
|
||||
subst.insert( 'a', config->appname );
|
||||
subst.insert( 's', config->text );
|
||||
subst.insert( 'w', QString::number( (quintptr)config->winId ));
|
||||
subst.insert( 'i', QString::number( id ));
|
||||
subst.insert( 'm', config->text );
|
||||
say = KMacroExpander::expandMacrosShellQuote( say, subst );
|
||||
}
|
||||
|
||||
m_kspeech->setApplicationName(config->appname);
|
||||
m_kspeech->call(QDBus::NoBlock, "say", say, 0);
|
||||
if ( say.isEmpty() )
|
||||
say = config->text; // fallback
|
||||
|
||||
finished(id);
|
||||
}
|
||||
m_kspeech->setSpeechID(appId);
|
||||
m_kspeech->say(say);
|
||||
|
||||
void NotifyByKTTS::removeSpeech()
|
||||
{
|
||||
tryToStartKttsd = false;
|
||||
|
||||
delete m_kspeech;
|
||||
m_kspeech = 0;
|
||||
finished(id);
|
||||
}
|
||||
|
||||
#include "moc_notifybyktts.cpp"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "knotifyplugin.h"
|
||||
|
||||
#include "kspeechinterface.h"
|
||||
#include <KSpeech>
|
||||
|
||||
class NotifyByKTTS : public KNotifyPlugin
|
||||
{
|
||||
|
@ -37,15 +37,8 @@ public:
|
|||
virtual QString optionName() { return "KTTS"; }
|
||||
virtual void notify(int id , KNotifyConfig *config);
|
||||
|
||||
private slots:
|
||||
void removeSpeech();
|
||||
|
||||
private:
|
||||
void setupKttsd();
|
||||
|
||||
private:
|
||||
org::kde::KSpeech *m_kspeech;
|
||||
bool tryToStartKttsd;
|
||||
KSpeech *m_kspeech;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@ target_link_libraries(plasmaclock
|
|||
${KDE4_PLASMA_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KSPEECH_LIBS}
|
||||
)
|
||||
|
||||
set_target_properties(plasmaclock PROPERTIES
|
||||
|
|
|
@ -32,11 +32,8 @@
|
|||
#include <QtGui/QGraphicsProxyWidget>
|
||||
#include <QtGui/qgraphicssceneevent.h>
|
||||
#include <QtGui/QGraphicsView>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusPendingCall>
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtDBus/QDBusConnectionInterface>
|
||||
|
||||
#include <KColorScheme>
|
||||
#include <KConfigDialog>
|
||||
|
@ -54,6 +51,7 @@
|
|||
#include <KTimeZone>
|
||||
#include <KToolInvocation>
|
||||
#include <KMessageBox>
|
||||
#include <KSpeech>
|
||||
|
||||
#include <Plasma/Containment>
|
||||
#include <Plasma/Corona>
|
||||
|
@ -186,17 +184,6 @@ void ClockApplet::speakTime(const QTime &time)
|
|||
}
|
||||
|
||||
if ((time.minute() % d->announceInterval) == 0) {
|
||||
// If KTTSD not running, start it.
|
||||
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kttsd")) {
|
||||
QString error;
|
||||
if (KToolInvocation::startServiceByDesktopName("kttsd", QStringList(), &error)) {
|
||||
KPassivePopup::message(i18n("Starting Jovie Text-to-Speech Service Failed"), error, static_cast<QWidget *>(0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QDBusInterface ktts("org.kde.kttsd", "/KSpeech", "org.kde.KSpeech");
|
||||
ktts.asyncCall("setApplicationName", "plasmaclock");
|
||||
QString text;
|
||||
if (time.minute() == 0) {
|
||||
if (KGlobal::locale()->use12Clock()) {
|
||||
|
@ -240,7 +227,9 @@ void ClockApplet::speakTime(const QTime &time)
|
|||
time.minute());
|
||||
}
|
||||
}
|
||||
ktts.asyncCall("say", text, 0);
|
||||
KSpeech kspeech(this);
|
||||
kspeech.setSpeechID(QString::fromLatin1("plasmaclock"));
|
||||
kspeech.say(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +354,7 @@ void ClockApplet::createConfigurationInterface(KConfigDialog *parent)
|
|||
{
|
||||
createClockConfigurationInterface(parent);
|
||||
|
||||
d->kttsAvailable = KService::serviceByDesktopName("kttsd");
|
||||
d->kttsAvailable = KSpeech::isSupported();
|
||||
|
||||
if (d->kttsAvailable) {
|
||||
QWidget *generalWidget = new QWidget();
|
||||
|
|
Loading…
Add table
Reference in a new issue