示例#1
0
文件: main.cpp 项目: KDE/simon-tools
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath("app/native/plugins");
    QApplication app(argc, argv);

    SimondConnector connector;
    QMLSimoneView view;

    QObject::connect(&view, SIGNAL(connectToServer()), &connector, SLOT(connectToServer()));
    QObject::connect(&view, SIGNAL(disconnectFromServer()), &connector, SLOT(disconnectFromServer()));
    QObject::connect(&view, SIGNAL(startRecording()), &connector, SLOT(startRecording()));
    QObject::connect(&view, SIGNAL(commitRecording()), &connector, SLOT(commitRecording()));
    QObject::connect(&view, SIGNAL(configurationChanged()), &connector, SLOT(configurationChanged()));

    QObject::connect(&connector, SIGNAL(connectionState(ConnectionState)), &view, SLOT(displayConnectionState(ConnectionState)));
    QObject::connect(&connector, SIGNAL(status(QString)), &view, SLOT(displayStatus(QString)));
    QObject::connect(&connector, SIGNAL(error(QString)), &view, SLOT(displayError(QString)));
    QObject::connect(&connector, SIGNAL(listening()), &view, SLOT(displayListening()));
    QObject::connect(&connector, SIGNAL(recognizing()), &view, SLOT(displayRecognizing()));
    QObject::connect(&connector, SIGNAL(microphoneLevel(int,int,int)), &view, SLOT(displayMicrophoneLevel(int,int,int)));
    QObject::connect(&connector, SIGNAL(recognized(RecognitionResultList)), &view, SLOT(recognized(RecognitionResultList)));

    view.show();
    connector.init();

    return app.exec();
}
示例#2
0
void SimondConnector::commitRecording()
{
    qDebug() << "Committing recording";
    emit recognizing();
    passThroughSound = false;

    QByteArray body;
    QDataStream bodyStream(&body, QIODevice::WriteOnly|QIODevice::Unbuffered);
    bodyStream << (qint8) 1 /* mic id */;

    sendRequest(Simond::RecognitionSampleFinished, body, false);
}
示例#3
0
文件: main.cpp 项目: bedahr/recomment
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath("app/native/plugins");
    QApplication app(argc, argv);

    bool voiceControlled = true;
    SimondConnector *connector;
    if (voiceControlled)
        connector = new SimondConnector;
    else
        connector = 0;

    Recomment recomment;
    QMLRecommentView view(&recomment, voiceControlled);

    if (voiceControlled) {
        QObject::connect(&view, SIGNAL(connectToServer()), connector, SLOT(connectToServer()));
        QObject::connect(&view, SIGNAL(disconnectFromServer()), connector, SLOT(disconnectFromServer()));
        QObject::connect(&view, SIGNAL(startRecording()), connector, SLOT(startRecording()));
        QObject::connect(&view, SIGNAL(commitRecording()), connector, SLOT(commitRecording()));
        QObject::connect(&view, SIGNAL(configurationChanged()), connector, SLOT(configurationChanged()));

        QObject::connect(connector, SIGNAL(connectionState(ConnectionState)), &view, SLOT(displayConnectionState(ConnectionState)));
        QObject::connect(connector, SIGNAL(status(QString)), &view, SLOT(displayStatus(QString)));
        QObject::connect(connector, SIGNAL(error(QString)), &view, SLOT(displayError(QString)));
        QObject::connect(connector, SIGNAL(listening()), &view, SLOT(displayListening()));
        QObject::connect(connector, SIGNAL(recognizing()), &view, SLOT(displayRecognizing()));
        QObject::connect(connector, SIGNAL(microphoneLevel(int,int,int)), &view, SLOT(displayMicrophoneLevel(int,int,int)));
        //QObject::connect(connector, SIGNAL(recognized(QString)), &view, SLOT(displayExecutedAction(QString)));
        QObject::connect(connector, SIGNAL(recognized(QString)), &recomment, SLOT(critique(QString)));
    }

    QObject::connect(&recomment, SIGNAL(recommend(const Offer*, QString)), &view, SLOT(displayRecommendation(const Offer*, QString)));
    QObject::connect(&recomment, SIGNAL(noMatchFor(QString)), &view, SLOT(displayNoMatch(QString)));

    view.show();
    if (voiceControlled)
        connector->init();
    if (!recomment.init()) {
        qWarning() << "Failed to initialize Recomment; Aborting";
        return -1;
    }

    int ret = app.exec();
    delete connector;
    return ret;
}