[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [simon] /: Auto-advance based on VAD when using power training
From: Peter Grasch <grasch () simon-listens ! org>
Date: 2013-02-14 12:10:22
Message-ID: 20130214121022.4D12FA6091 () git ! kde ! org
[Download RAW message or body]
Git commit b6cd3e8812f381b13efefbd6a5c4a6ed9ebfcdad by Peter Grasch.
Committed on 14/02/2013 at 13:09.
Pushed by grasch into branch 'master'.
Auto-advance based on VAD when using power training
M +7 -1 simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.cpp
M +3 -0 simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.h
M +19 -1 simonlib/simonsound/recwidget.cpp
M +7 -0 simonlib/simonsound/recwidget.h
M +3 -0 simonlib/simonsound/wavfilewidget.cpp
M +3 -0 simonlib/simonsound/wavfilewidget.h
M +13 -11 simonlib/simonsound/wavrecorderclient.cpp
M +7 -4 simonlib/simonsound/wavrecorderclient.h
http://commits.kde.org/simon/b6cd3e8812f381b13efefbd6a5c4a6ed9ebfcdad
diff --git a/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.cpp \
b/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.cpp index \
2251daa..c0c9da1 100644
--- a/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.cpp
+++ b/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.cpp
@@ -59,9 +59,9 @@ fileName( prompt_.replace(' ', \
'_').replace('/','_').remove('?').replace('\\', ' connect(recorder, \
SIGNAL(recording()), this, SIGNAL(completeChanged())); connect(recorder, \
SIGNAL(recordingFinished()), this, SIGNAL(completeChanged())); \
connect(recorder, SIGNAL(sampleDeleted()), this, \
SIGNAL(completeChanged())); + connect(recorder, SIGNAL(speakingStopped()), \
this, SLOT(speakingStopped())); }
-
void TrainSamplePage::initializePage()
{
if (field("powerRecording").toBool()) {
@@ -154,6 +154,12 @@ bool TrainSamplePage::isComplete() const
return recorder->hasRecordingReady();
}
+void TrainSamplePage::speakingStopped()
+{
+ kDebug() << "Speaking stopped";
+ if (field("powerRecording").toBool())
+ wizard()->next();
+}
TrainSamplePage::~TrainSamplePage()
{
diff --git a/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.h \
b/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.h index \
7da5b03..8f81cfb 100644
--- a/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.h
+++ b/simon/src/simonmodelmanagementui/TrainSamples/trainsamplepage.h
@@ -36,6 +36,9 @@ class TrainSamplePage : public QWizardPage
QStringList getFileNames() const;
+ private slots:
+ void speakingStopped();
+
public:
TrainSamplePage(QString prompt, int nowPage, int maxPage, const \
QString name, QWidget *parent=0); ~TrainSamplePage();
diff --git a/simonlib/simonsound/recwidget.cpp \
b/simonlib/simonsound/recwidget.cpp index 62f29ed..8ac94cc 100644
--- a/simonlib/simonsound/recwidget.cpp
+++ b/simonlib/simonsound/recwidget.cpp
@@ -64,7 +64,8 @@ RecWidget::RecWidget(QString name, QString text, QString \
fileTemplate, bool forc statusTimer(new QTimer(this)),
ui(new Ui::RecWidgetUi()),
m_simpleMode(forceSimpleMode),
-m_playbackOnly(playbackOnly)
+m_playbackOnly(playbackOnly),
+m_speakingCount(0)
{
this->fileTemplate = fileTemplate;
@@ -150,6 +151,8 @@ void RecWidget::registerDevice(const \
SimonSound::DeviceConfiguration& device, co connect(wg, \
SIGNAL(sampleDeleted()), this, SLOT(slotSampleDeleted())); connect(wg, \
SIGNAL(playing()), this, SLOT(slotEnableDeleteAll())); connect(wg, \
SIGNAL(playbackFinished()), this, SLOT(slotEnableDeleteAll())); + \
connect(wg, SIGNAL(speaking()), this, SLOT(clientReportedSpeaking())); + \
connect(wg, SIGNAL(speakingStopped()), this, \
SLOT(clientReportedSilence()));
waves << wg;
}
@@ -303,6 +306,7 @@ void RecWidget::setTitle(QString newTitle)
*/
void RecWidget::record()
{
+ m_speakingCount = 0;
foreach (WavFileWidget *wav, waves)
wav->record();
@@ -385,6 +389,20 @@ void RecWidget::slotEnableDeleteAll()
ui->pbDeleteAll->setEnabled(shouldEnableDelete);
}
+void RecWidget::clientReportedSpeaking()
+{
+ if (m_speakingCount == 0)
+ emit speaking();
+ ++m_speakingCount;
+}
+
+void RecWidget::clientReportedSilence()
+{
+ --m_speakingCount;
+ if (m_speakingCount == 0)
+ emit speakingStopped();
+}
+
/**
* \brief Deletes the file at fileTemplate (member)
diff --git a/simonlib/simonsound/recwidget.h \
b/simonlib/simonsound/recwidget.h index e1c806c..b5d6c00 100644
--- a/simonlib/simonsound/recwidget.h
+++ b/simonlib/simonsound/recwidget.h
@@ -54,6 +54,8 @@ class SIMONSOUND_EXPORT RecWidget : public QWidget
void progress(int);
void recordingFinished();
void playbackFinished();
+ void speaking();
+ void speakingStopped();
private:
QTimer *statusTimer;
@@ -61,6 +63,8 @@ class SIMONSOUND_EXPORT RecWidget : public QWidget
bool m_simpleMode;
bool m_playbackOnly;
+ int m_speakingCount;
+
QList<WavFileWidget*> waves;
QString fileTemplate;
@@ -88,6 +92,9 @@ class SIMONSOUND_EXPORT RecWidget : public QWidget
void showFinishPrompt();
void showWaitPrompt();
+ void clientReportedSpeaking();
+ void clientReportedSilence();
+
public slots:
void record();
void stopRecording();
diff --git a/simonlib/simonsound/wavfilewidget.cpp \
b/simonlib/simonsound/wavfilewidget.cpp index aac53c9..e35840d 100644
--- a/simonlib/simonsound/wavfilewidget.cpp
+++ b/simonlib/simonsound/wavfilewidget.cpp
@@ -116,6 +116,9 @@ void WavFileWidget::setupSignalsSlots()
connect(rec, SIGNAL(clippingOccured()), this, SLOT(clippingOccured()));
connect(rec, SIGNAL(signalToNoiseRatioLow()), this, \
SLOT(signalToNoiseRatioLow()));
+ connect(rec, SIGNAL(speaking()), this, SIGNAL(speaking()));
+ connect(rec, SIGNAL(speakingStopped()), this, \
SIGNAL(speakingStopped())); +
connect(play, SIGNAL(finished()), this, SLOT(finishPlayback()));
}
diff --git a/simonlib/simonsound/wavfilewidget.h \
b/simonlib/simonsound/wavfilewidget.h index f837082..e13c00b 100644
--- a/simonlib/simonsound/wavfilewidget.h
+++ b/simonlib/simonsound/wavfilewidget.h
@@ -79,6 +79,9 @@ class SIMONSOUND_EXPORT WavFileWidget : public QWidget
void playbackFinished();
void error(const QString& error);
+ void speaking();
+ void speakingStopped();
+
private:
SimonSamples::SampleProblems m_problems;
diff --git a/simonlib/simonsound/wavrecorderclient.cpp \
b/simonlib/simonsound/wavrecorderclient.cpp index 1825c6a..42ebdde 100644
--- a/simonlib/simonsound/wavrecorderclient.cpp
+++ b/simonlib/simonsound/wavrecorderclient.cpp
@@ -22,7 +22,7 @@
#include <soundconfig.h>
#include "soundserver.h"
-#include "loudnessmetersoundprocessor.h"
+#include "vadsoundprocessor.h"
#include <QObject>
@@ -35,9 +35,11 @@ WavRecorderClient::WavRecorderClient(const \
SimonSound::DeviceConfiguration& devi QObject(parent),
SoundInputClient(deviceConfiguration),
wavData(0),
-loudness(new LoudnessMeterSoundProcessor())
+vad(new VADSoundProcessor(deviceConfiguration, true))
{
- registerSoundProcessor(loudness);
+ registerSoundProcessor(vad);
+ connect(vad, SIGNAL(listening()), this, SIGNAL(speaking()));
+ connect(vad, SIGNAL(complete()), this, SIGNAL(speakingStopped()));
}
@@ -69,9 +71,9 @@ void WavRecorderClient::processPrivate(const QByteArray& \
data, qint64 currentTim {
wavData->write(data);
- float peak = loudness->peak() / 32768.0f;
+ float peak = vad->peak() / 32768.0f;
emit currentProgress(currentTime, peak);
- if (loudness->clipping())
+ if (vad->clipping())
emit clippingOccured();
}
@@ -88,16 +90,16 @@ bool WavRecorderClient::finish()
succ = SoundServer::getInstance()->deRegisterInputClient(this);
- kDebug() << "Min: " << loudness->absoluteMinAverage();
- kDebug() << "Max: " << loudness->absolutePeak();
- kDebug() << "Theoretical max: " << loudness->maxAmp();
- int absoluteMinAverage = loudness->absoluteMinAverage();
+ kDebug() << "Min: " << vad->absoluteMinAverage();
+ kDebug() << "Max: " << vad->absolutePeak();
+ kDebug() << "Theoretical max: " << vad->maxAmp();
+ int absoluteMinAverage = vad->absoluteMinAverage();
if (absoluteMinAverage == 0)
absoluteMinAverage = 1;
//ratio is in percent
- float ratio = ((float) loudness->absolutePeak() / (float) \
absoluteMinAverage) * 100; + float ratio = ((float) vad->absolutePeak() / \
(float) absoluteMinAverage) * 100; kDebug() << "Ratio: " << ratio;
if (ratio < SoundConfiguration::minimumSNR())
@@ -109,7 +111,7 @@ bool WavRecorderClient::finish()
wavData->deleteLater();
wavData = 0;
- loudness->reset();
+ vad->reset();
return succ;
}
diff --git a/simonlib/simonsound/wavrecorderclient.h \
b/simonlib/simonsound/wavrecorderclient.h index e18a656..8e186bc 100644
--- a/simonlib/simonsound/wavrecorderclient.h
+++ b/simonlib/simonsound/wavrecorderclient.h
@@ -25,21 +25,24 @@
#include "soundinputclient.h"
class WAV;
-class LoudnessMeterSoundProcessor;
+class VADSoundProcessor;
class WavRecorderClient :public QObject, public SoundInputClient
{
Q_OBJECT
- private:
+ private:
WAV *wavData;
- LoudnessMeterSoundProcessor *loudness;
+ VADSoundProcessor *vad;
- signals:
+ signals:
void currentProgress(int msecs, float level);
void clippingOccured();
void signalToNoiseRatioLow();
+ void speaking();
+ void speakingStopped();
+
public:
explicit WavRecorderClient(const SimonSound::DeviceConfiguration& \
deviceConfiguration, QObject *parent=0); bool finish();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic