Skip to content
Snippets Groups Projects
Commit dc9b82d5 authored by Günes Minareci's avatar Günes Minareci
Browse files

Merge branch 'master' of rcs:robocup-speechrec

parents 1bb7d653 495de439
No related branches found
No related tags found
No related merge requests found
Showing
with 1943 additions and 1184 deletions
#JSGF V1.0;
grammar ToBI_room;
public <statement> = <rooms>;
<rooms> = [the] (living_room | dining_room | kitchen);
This diff is collapsed.
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/SimpleDoubleThresholdSegmenter.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/SimpleDoubleThresholdSegmenter.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/SimpleDoubleThresholdSegmenter.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_EqualizerWidget.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/measureAlsaDb.dir/moc_EqualizerWidget.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_EqualizerWidget.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/SimpleTextAddField.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/SimpleTextAddField.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/SimpleTextAddField.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_SimpleDoubleThresholdSegmenter.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/moc_SimpleDoubleThresholdSegmenter.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_SimpleDoubleThresholdSegmenter.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_PocketSphinxWrapper.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/moc_PocketSphinxWrapper.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_PocketSphinxWrapper.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/PocketSphinxWidget.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/PocketSphinxWidget.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/PocketSphinxWidget.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/PocketSphinxWrapper.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/PocketSphinxWrapper.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/PocketSphinxWrapper.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_measureDb.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/measureAlsaDb.dir/moc_measureDb.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_measureDb.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/PocketsphinxAdapter.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/PocketsphinxAdapter.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/PocketsphinxAdapter.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/measureDb.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/measureAlsaDb.dir/measureDb.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/measureDb.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_AlsaMicGrabber.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/measureAlsaDb.dir/moc_AlsaMicGrabber.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_AlsaMicGrabber.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_SimpleTextAddField.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/moc_SimpleTextAddField.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_SimpleTextAddField.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/EqualizerColorWidget.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/EqualizerColorWidget.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/EqualizerColorWidget.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/EqualizerWidget.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/measureAlsaDb.dir/EqualizerWidget.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/EqualizerWidget.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/JsgfParser.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/jsgfParser.dir/JsgfParser.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/JsgfParser.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/AlsaMicGrabber.cpp=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/measureAlsaDb.dir/AlsaMicGrabber.cpp.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/AlsaMicGrabber.cpp
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_EqualizerColorWidget.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/moc_EqualizerColorWidget.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_EqualizerColorWidget.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_PocketSphinxWidget.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/moc_PocketSphinxWidget.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_PocketSphinxWidget.cxx
/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_PocketsphinxAdapter.cxx=/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -g3 -gdwarf-2 -I/homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -o CMakeFiles/pocketsphinxAdapter.dir/moc_PocketsphinxAdapter.cxx.o -c /homes/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/moc_PocketsphinxAdapter.cxx
/home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/configFileParserTest.cpp=/home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -DRST_EXPORT= -g3 -gdwarf-2 -I/home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -I/usr/share/rsb0.9/../../include/rsb0.9 -I/usr/share/rsc0.9/../../include/rsc0.9 -I/usr/share/rsc0.9/../../include/rsc0.9/3rdparty/boost.uuid -I/usr/share/rst0.9/../../include/rst0.9/stable -o CMakeFiles/configFileParser.dir/configFileParserTest.cpp.o -c /home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/configFileParserTest.cpp
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="88">
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
<df root="." name="pocketsphinxAdapter">
<df name="build">
<df name="CMakeFiles">
<df name="2.8.10.2">
<df name="CompilerIdC">
<in>CMakeCCompilerId.c</in>
</df>
<df name="CompilerIdCXX">
<in>CMakeCXXCompilerId.cpp</in>
</df>
</df>
<df name="CMakeTmp">
</df>
</df>
<df name="src">
<df name="CMakeFiles">
<df name="jsgfParserTest.dir">
</df>
<df name="measureAlsaDb.dir">
</df>
<df name="parserToyExample.dir">
</df>
<df name="pocketsphinxAdapter.dir">
</df>
</df>
<in>moc_AlsaMicGrabber.cxx</in>
<in>moc_EqualizerColorWidget.cxx</in>
<in>moc_EqualizerWidget.cxx</in>
<in>moc_PocketSphinxWidget.cxx</in>
<in>moc_PocketSphinxWrapper.cxx</in>
<in>moc_PocketsphinxAdapter.cxx</in>
<in>moc_SimpleDoubleThresholdSegmenter.cxx</in>
<in>moc_SimpleTextAddField.cxx</in>
<in>moc_measureDb.cxx</in>
</df>
<in>pocketsphinxAdapterConfig.h</in>
</df>
<df name="cmake">
<df name="Modules">
</df>
</df>
<df name="CMakeFiles">
<df name="2.8.10.2">
<df name="CompilerIdC">
<in>CMakeCCompilerId.c</in>
</df>
<df name="CompilerIdCXX">
<in>CMakeCXXCompilerId.cpp</in>
</df>
</df>
<df name="CMakeTmp">
</df>
<df name="Progress">
</df>
</df>
<df name="src">
<df name="CMakeFiles">
<df name="jsgfParser.dir">
</df>
<df name="jsgfParserTest.dir">
</df>
<df name="measureAlsaDb.dir">
</df>
<df name="parserToyExample.dir">
</df>
<df name="pocketsphinxAdapter.dir">
</df>
</df>
<in>AlsaMicGrabber.cpp</in>
<in>AlsaMicGrabber.h</in>
<in>EqualizerColorWidget.cpp</in>
<in>EqualizerColorWidget.h</in>
<in>EqualizerWidget.cpp</in>
<in>EqualizerWidget.h</in>
<in>JsgfParser.cpp</in>
<in>JsgfParser.h</in>
<in>JsgfParserTest.cpp</in>
<in>PocketSphinxInitException.cpp</in>
<in>PocketSphinxInitException.h</in>
<in>PocketSphinxWidget.cpp</in>
<in>PocketSphinxWidget.h</in>
<in>PocketSphinxWrapper.cpp</in>
<in>PocketSphinxWrapper.h</in>
<in>PocketsphinxAdapter.cpp</in>
<in>PocketsphinxAdapter.h</in>
<in>SimpleDoubleThresholdSegmenter.cpp</in>
<in>SimpleDoubleThresholdSegmenter.h</in>
<in>SimpleTextAddField.cpp</in>
<in>SimpleTextAddField.h</in>
<in>dynamicParser.cpp</in>
<in>dynamicParser.h</in>
<in>jsgf_internal.h</in>
<in>measureDb.cpp</in>
<in>measureDb.h</in>
<in>moc_AlsaMicGrabber.cxx</in>
<in>moc_EqualizerColorWidget.cxx</in>
<in>moc_EqualizerWidget.cxx</in>
<in>moc_PocketSphinxWidget.cxx</in>
<in>moc_PocketSphinxWrapper.cxx</in>
<in>moc_PocketsphinxAdapter.cxx</in>
<in>moc_SimpleDoubleThresholdSegmenter.cxx</in>
<in>moc_SimpleTextAddField.cxx</in>
<in>moc_measureDb.cxx</in>
</df>
<in>pocketsphinxAdapterConfig.h</in>
</df>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="Default" type="0">
<toolsSet>
<developmentServer>localhost</developmentServer>
<platform>2</platform>
</toolsSet>
<dbx_gdbdebugger version="1">
<gdb_pathmaps>
</gdb_pathmaps>
<gdb_interceptlist>
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
</gdb_interceptlist>
<gdb_options>
<DebugOptions>
</DebugOptions>
</gdb_options>
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
</dbx_gdbdebugger>
<nativedebugger version="1">
<engine>gdb</engine>
</nativedebugger>
<runprofile version="9">
<runcommandpicklist>
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
</runcommandpicklist>
<runcommand>"${OUTPUT_PATH}"</runcommand>
<rundir>.</rundir>
<buildfirst>false</buildfirst>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>
......@@ -6,7 +6,7 @@
<name>pocketsphinxAdapter</name>
<c-extensions>c</c-extensions>
<cpp-extensions>cpp,cxx</cpp-extensions>
<header-extensions>h</header-extensions>
<header-extensions>h,tcc</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/>
<sourceRootList>
......
......@@ -69,8 +69,14 @@ AlsaMicGrabber::grab()
{
bool keepRunning=true;
int pcmreturn;
size_t frames_total_grabbed=0;
short* localbuffer;
short** emitbuffer;
localbuffer = new short[sampleSize];
unsigned int pushBufferSize = 2;
emitbuffer = new short*[pushBufferSize];
for (int i=0; i < pushBufferSize; i++)
emitbuffer[i] = new short[sampleSize];
if ((pcmreturn = snd_pcm_prepare (pcmHandle)) < 0)
{
cerr << "Error during sound hardware prepare: " << snd_strerror(pcmreturn) << endl;
......@@ -80,7 +86,7 @@ AlsaMicGrabber::grab()
{
try
{
pcmreturn = snd_pcm_readi(pcmHandle,localbuffer,sampleSize);
pcmreturn = snd_pcm_readi(pcmHandle,localbuffer,sampleSize);
if (pcmreturn < 0)
{
printf("Stream status error: %s\n", snd_strerror(pcmreturn));
......@@ -90,13 +96,14 @@ AlsaMicGrabber::grab()
{
boost::unique_lock<boost::mutex> lock (bufferMutex);
memcpy(buffer,localbuffer,bufferSize);
memcpy(emitbuffer[frames_total_grabbed%pushBufferSize],localbuffer,bufferSize);
}
emit pushGrab(emitbuffer[frames_total_grabbed%pushBufferSize],sampleSize);
frames_total_grabbed++;
calc_dB();
//std::cerr << "emitting signal " << std::endl;
emit updated_dB_and_clipped (static_cast<float> (signalNoiseRatioChunk), clippedChunk);
//cerr << "Read from device\n";
emit pushGrab(localbuffer,sampleSize);
//cerr << "Read from device\n";
boost::this_thread::interruption_point();
}
catch (boost::thread_interrupted &ti)
......@@ -170,6 +177,7 @@ AlsaMicGrabber::calc_dB()
e_sum += abs(buffer[i]);
}
}
//std::cerr << "amg e_sum = " << e_sum << std::endl;
e_avg = static_cast<float> (e_sum) / static_cast<float> (sampleSize);
ratio = e_avg / e_ref;
......@@ -181,6 +189,4 @@ AlsaMicGrabber::calc_dB()
clippedTotal += clipped;
clippedChunk = clipped;
/*printf("average energy %8g (%5.3g db%s)\n",
e_avg, db, (clipped) ? " clipped!" : "");*/
}
......@@ -14,7 +14,11 @@
#include <vector>
#include <boost/thread.hpp>
#include <Qt/qobject.h>
#include "defaults.h"
typedef struct alsa_sound_chunk_t {
short soundchunk[ALSAMICGRABBER_SAMPLESIZE];
} AlsaSoundChunkT;
class AlsaPcmDeviceNotFoundException: public std::exception {
public:
......@@ -40,9 +44,9 @@ private:
snd_pcm_t *pcmHandle;
snd_pcm_hw_params_t *hwParams;
std::string hardwareDeviceName;
static const unsigned int sampleRate = 16000;
static const unsigned int sampleSize = 512;
static const unsigned int bufferSize = 1024;
static const unsigned int sampleRate = ALSAMICGRABBER_SAMPLERATE;
static const unsigned int sampleSize = ALSAMICGRABBER_SAMPLESIZE;
static const unsigned int bufferSize = ALSAMICGRABBER_BUFFERSIZE;
boost::shared_ptr<boost::thread> readThreadPtr;
boost::mutex bufferMutex;
bool newDataAvailable;
......
......@@ -13,9 +13,15 @@ include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
set(jsgfParser_SRCS
JsgfParser.h
JsgfParserTest.cpp
JsgfParser.cpp)
set (listenToRsb_SRCS
listenToRsb.cpp)
set (sendSpeechRecEnable_SRCS
sendSpeechRecEnable.cpp)
set(pocketsphinxAdapter_SRCS
PocketsphinxAdapter.cpp
......@@ -24,7 +30,12 @@ set(pocketsphinxAdapter_SRCS
SimpleDoubleThresholdSegmenter.cpp
SimpleTextAddField.cpp
AlsaMicGrabber.cpp
EqualizerColorWidget.cpp)
EqualizerColorWidget.cpp
JsgfParser.cpp
publishRsb.cpp
rsbRemoteReceiver.cpp
dataRingBuffer.cpp
configFileParser.cpp)
set(pocketsphinxAdapter_MOC_HDRS
PocketsphinxAdapter.h
......@@ -33,7 +44,9 @@ set(pocketsphinxAdapter_MOC_HDRS
SimpleTextAddField.h
PocketSphinxWrapper.h
AlsaMicGrabber.h
EqualizerColorWidget.h)
EqualizerColorWidget.h
publishRsb.h
rsbRemoteReceiver.h)
set(measureAlsaDb_SRCS
measureDb.cpp
......@@ -47,6 +60,9 @@ set(measureAlsaDb_MOC_HDRS
EqualizerWidget.h
)
set(configFileParser_SRCS
configFileParserTest.cpp)
qt4_wrap_cpp(measureAlsaDb_MOC_SRCS ${measureAlsaDb_MOC_HDRS})
qt4_wrap_cpp(pocketsphinxAdapter_MOC_SRCS ${pocketsphinxAdapter_MOC_HDRS})
......@@ -57,11 +73,21 @@ include_directories( ${POCKETSPHINX_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${Boost_I
add_executable(pocketsphinxAdapter ${pocketsphinxAdapter_SRCS} ${pocketsphinxAdapter_MOC_SRCS})
#MESSAGE (STATUS "POCKETSHINX_INCLUDE_DIRS: " ${POCKETSPHINX_INCLUDE_DIRS} )
include_directories( ${POCKETSPHINX_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${QT_INCLUDE_DIR})
target_link_libraries( pocketsphinxAdapter ${POCKETSPHINX_LDFLAGS} ${ALSA_LDFLAGS} ${Boost_LIBRARIES} ${QT_LIBRARIES})
include_directories( ${POCKETSPHINX_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${QT_INCLUDE_DIR} ${RSB_INCLUDE_DIRS} ${RST_INCLUDE_DIRS})
target_link_libraries( pocketsphinxAdapter ${POCKETSPHINX_LDFLAGS} ${ALSA_LDFLAGS} ${QT_LIBRARIES} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${RSBXML_LIBRARIES} ${Boost_LIBRARIES})
add_executable(jsgfParser ${jsgfParser_SRCS})
include_directories( ${POCKETSPHINX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
add_executable(configFileParser ${configFileParser_SRCS})
include_directories(${Boost_INCLUDE_DIRS})
add_executable(listenToRsb ${listenToRsb_SRCS})
include_directories(${RSB_INCLUDE_DIRS} ${RST_INCLUDE_DIRS})
target_link_libraries( listenToRsb ${POCKETSPHINX_LDFLAGS} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${RSBXML_LIBRARIES} ${Boost_LIBRARIES})
add_executable(sendSpeechRecEnable ${sendSpeechRecEnable_SRCS})
include_directories(${RSB_INCLUDE_DIRS} ${RST_INCLUDE_DIRS})
target_link_libraries( sendSpeechRecEnable ${POCKETSPHINX_LDFLAGS} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${RSBXML_LIBRARIES} ${Boost_LIBRARIES})
install(TARGETS pocketsphinxAdapter DESTINATION bin)
\ No newline at end of file
install(TARGETS pocketsphinxAdapter jsgfParser DESTINATION bin)
\ No newline at end of file
......@@ -6,112 +6,299 @@
*/
#include "JsgfParser.h"
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <map>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/iterators/istream_iterator.hpp>
#include <boost/spirit/home/qi/parse_attr.hpp>
#include "JsgfParser.h"
#include "dynamicParser.h"
using namespace std;
/*
template <typename Iterator>
struct stringtest : qi::grammar<Iterator, std::string(), ascii::space_type> {
stringtest() : stringtest::base_type(sp) {
sr = qi::string ("Test")[qi::_val = px::val("Test")] | qi::string("EinandererTest")[qi::_val = px::val("EinandererTest")];
sq = qi::string ("Moper")[qi::_val = px::val("Moper")];
sp = sr | sq;
namespace jsgfParserTypes {
void tab(int indent) {
for (int i = 0; i < indent; ++i)
std::cout << ' ';
}
void TermWrapperTPrinter::operator()(TermT const& t) const {
TermTPrinter(indent + tabsize)(t);
}
void TermWrapperTPrinter::operator()(TermLeafT const& tl) const {
tab(indent + tabsize);
std::cout << "TermLeaf size = " << tl.symbols.size() << std::endl;
for (std::vector<jsgfParserTypes::SymbolT>::size_type i = 0; i < tl.symbols.size(); i++) {
tab(indent + tabsize);
std::cout << " '" << tl.symbols.at(i).name << "' type = " << tl.symbols.at(i).type << std::endl;
}
qi::rule<Iterator,std::string(),ascii::space_type> sr;
qi::rule<Iterator,std::string(),ascii::space_type> sq;
qi::rule<Iterator,std::string(),ascii::space_type> sp;
};
*/
int
main(int argc, char** argv) {
std::string s ("Moper");
/*
stringtest<std::string::const_iterator> myStringtest;
std::string attr;
qi::phrase_parse((std::string::const_iterator)s.begin(),(std::string::const_iterator)s.end(),myStringtest,ascii::space,attr);
std::cout << attr << std::endl;*/
std::vector<qi::rule<std::string::iterator,std::string(), qi::ascii::space_type>* > rules;
//rules.push_back (new )
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " <filename.jsgf>" << std::endl;
return -1;
}
std::ifstream input(argv[1], std::ifstream::in);
if (!input.is_open()) {
std::cerr << "Could not open file: " << argv[1] << std::endl;
}
std::string storage; // We will read the contents here.
input.unsetf(std::ios::skipws); // No white space skipping!
std::copy(
std::istream_iterator<char>(input),
std::istream_iterator<char>(),
std::back_inserter(storage));
jsgfParserTypes::GrammarT myGrammar;
jsgfParserRuleGenerator<std::string::const_iterator> myJsgfParser;
std::string::const_iterator iter = storage.begin();
std::string::const_iterator end = storage.end();
bool success = qi::phrase_parse(iter, end, myJsgfParser, ascii::space, myGrammar);
if (success && iter == end) {
std::cout << "-------------------------\n";
std::cout << "Parsing succeeded\n";
std::cout << "-------------------------\n";
} else {
std::string::const_iterator some = iter + 30;
std::string context(iter, (some > end) ? end : some);
std::cout << "-------------------------\n";
std::cout << "Parsing failed\n";
std::cout << "stopped at: \": " << context << "...\"\n";
std::cout << "-------------------------\n";
return 1;
}
if (myJsgfParser.sanitizeCheckGrammar(myGrammar,true))
{
std::cout << "JSGF check success" << std::endl;
}
else
{
std::cout << "JSGF check FAILED" << std::endl;
return 1;
}
std::cout << "My grammars Name is: " << myGrammar.name << " and the first rules name is " << myGrammar.rules.at(0).name << std::endl;
if (myJsgfParser.generateRules(myGrammar))
{
std::cout << "JSGF rules generated" << std::endl;
}
else
{
std::cout << "JSGF rule generation FAILED" << std::endl;
return 1;
}
std::vector<jsgfParserTypes::ruleTPtr> myRules = myJsgfParser.getRules();
dynamicParser<std::string::iterator> myDynamicParser (myRules);
std::string st ("this is a task");
while (0 != st.compare(""))
{
getline(std::cin,st);
std::string attr;
//std::cin >> st;
bool dynSucc = boost::spirit::qi::phrase_parse(st.begin(),st.end(), myDynamicParser, boost::spirit::qi::ascii::space,attr);
if (dynSucc)
{
std::cout << "'" << st << "' parsed successfully (" << attr << ")" << std::endl;
}
void TermTPrinter::operator()(TermT const& t) const {
tab(indent);
if (t.optional)
std::cout << "[" << std::endl;
else
std::cout << '{' << std::endl;
tab(indent);
std::cout << "#Children = " << t.children.size() << std::endl;
BOOST_FOREACH(TermWrapperT const& node, t.children) {
if (t.orTerm) {
tab(indent);
std::cout << "|" << std::endl;
}
jsgfParserTypes::TermWrapperTPrinter myTermWrapperTPrinter(indent);
boost::apply_visitor(myTermWrapperTPrinter, node);
}
tab(indent);
if (t.optional)
std::cout << "]" << std::endl;
else
std::cout << "'" << st << "' not part of the grammar (" << attr << ")" << std::endl;
std::cout << '}' << std::endl;
}
void TermWrapperExtractor::operator ()(TermT const& t) const {
TermTExtractor myExtractor(myNames);
myExtractor(t);
}
void TermWrapperExtractor::operator()(TermLeafT const& tl) const {
for (std::vector<jsgfParserTypes::SymbolT>::size_type i = 0; i < tl.symbols.size(); i++) {
if (tl.symbols.at(i).type == 1) {
std::string s(tl.symbols.at(i).name.begin(), tl.symbols.at(i).name.end());
myNames.push_back(tl.symbols.at(i).name);
}
}
}
void TermTExtractor::operator()(TermT const& t) const {
BOOST_FOREACH(TermWrapperT const& node, t.children) {
boost::apply_visitor(TermWrapperExtractor(myNames), node);
}
}
std::string trim(const std::string& str,
const std::string& whitespace) {
std::string::size_type strBegin = str.find_first_not_of(whitespace);
if (strBegin == std::string::npos)
return ""; // no content
std::string::size_type strEnd = str.find_last_not_of(whitespace);
std::string::size_type strRange = strEnd - strBegin + 1;
return str.substr(strBegin, strRange);
}
std::vector<TermWrapperT> giveChildrenAndDelete::operator()(TermT &t) const {
std::vector<TermWrapperT> temp;
for (std::vector<TermWrapperT>::iterator it = t.children.begin(); it != t.children.end(); it++) {
temp.push_back(*it);
}
t.children.clear();
return temp;
}
std::vector<TermWrapperT> giveChildrenAndDelete::operator()(TermLeafT & tl) const {
std::vector<TermWrapperT> temp;
return temp;
}
void TermWrapperSanitizer::operator() (TermT &t) const {
if (t.orTerm) {
isOrTerm = true;
}
TermSanitizer()(t);
}
void TermWrapperSanitizer::operator() (TermLeafT & tl) const {
for (std::vector<jsgfParserTypes::SymbolT>::size_type i = 0; i < tl.symbols.size(); i++) {
std::string s = trim(tl.symbols.at(i).name);
tl.symbols.at(i).name = s;
}
}
void TermSanitizer::operator()(TermT & t) const {
BOOST_FOREACH(TermWrapperT & node, t.children) {
bool isOrTerm = false;
boost::apply_visitor(TermWrapperSanitizer(isOrTerm), node);
if (isOrTerm) {
if (!t.orTerm) {
t.orTerm = true;
}
//std::cout << "Found orTerm" << std::endl;
std::vector<TermWrapperT> temp = boost::apply_visitor(giveChildrenAndDelete(), node);
t.children.pop_back();
for (unsigned int i = 0; i < temp.size(); i++) {
t.children.push_back(temp.at(i));
}
}
}
}
void TermWrapperRuleGenerator::operator ()(TermT & t) const {
TermTRuleGenerator myGenerator(myRules, myNamesToRules, myNonterminal);
myGenerator(t);
}
void TermWrapperRuleGenerator::operator()(TermLeafT & tl) const {
if (0 == tl.symbols.size())
return; //Save a lot of time and some if cases below
std::vector<SymbolT>::size_type myRulesLocalStart = myRules.size();
for (std::vector<jsgfParserTypes::SymbolT>::size_type i = 0; i < tl.symbols.size(); i++) {
if (0 == tl.symbols.at(i).type) {
myRules.push_back(new ruleT(qi::string(trim(tl.symbols.at(i).name))[px::push_back(qi::_val, px::val(trim(tl.symbols.at(i).name))) /*qi::_val = px::val('<') + px::val(myNonterminal) + px::val('>') + px::val(trim(tl.symbols.at(i).name)) + px::val("</") + px::val(myNonterminal) + px::val('>')*/]));
(*myRules.back()).name(std::string("T:").append(trim(tl.symbols.at(i).name)));
} else {
nameToRuleT::iterator pos = myNamesToRules.find(trim(tl.symbols.at(i).name));
if (pos != myNamesToRules.end()) {
if (optional) {
myRules.push_back(new ruleT((*myRules.at(pos->second))[qi::_val = px::bind(&nonTerminalInserter, qi::_1, px::val(trim(tl.symbols.at(i).name)))] || qi::eps));
(*myRules.back()).name(std::string("+N:").append(trim(tl.symbols.at(i).name)));
} else {
myRules.push_back(new ruleT((*myRules.at(pos->second))[qi::_val = px::bind(&nonTerminalInserter, qi::_1, px::val(trim(tl.symbols.at(i).name)))]));
(*myRules.back()).name(std::string("N:").append(trim(tl.symbols.at(i).name)));
}
} else {
std::cout << "Rule mismatch!! Abort!" << std::endl;
abort();
}
}
}
ruleTPtr r = new ruleT((*myRules.at(myRulesLocalStart)));
r->name(myRules.at(myRulesLocalStart)->name());
for (std::vector<SymbolT>::size_type i = (myRulesLocalStart + 1); i < myRules.size(); i++) {
(*r) = (r->copy() >> ((*myRules.at(i))))[qi::_val = px::bind(&concat2stdvectors, qi::_1, qi::_2)];
r->name(r->name() + " > " + myRules.at(i)->name());
}
myRules.push_back(r);
//std::cout << "TermLeaf created rule " << myRules.back()->name() << std::endl;
}
void TermTRuleGenerator::operator()(TermT & t) const {
std::vector<std::vector<ruleTPtr>::size_type> indices;
BOOST_FOREACH(TermWrapperT & node, t.children) {
std::vector<ruleTPtr>::size_type rulesSize = myRules.size();
boost::apply_visitor(TermWrapperRuleGenerator(myRules, myNamesToRules, myNonterminal, t.optional), node);
if (rulesSize != myRules.size()) {
indices.push_back(myRules.size() - 1);
}
}
ruleTPtr r = NULL;
if (t.orTerm) {
r = NULL;
if (indices.size() > 1) {
r = new ruleT((*myRules.at(indices.at(0))));
if (t.optional)
r->name("[" + (*myRules.at(indices.at(0))).name());
else
r->name("(" + (*myRules.at(indices.at(0))).name());
for (std::vector<ruleTPtr>::size_type i = 1; i < indices.size(); i++) {
(*r) = ((*r).copy() | (*myRules.at(indices.at(i))));
r->name(r->name() + " | " + (*myRules.at(indices.at(i))).name());
}
if (t.optional) {
r->name(r->name() + "]");
(*r) = -(*r).copy();
} else
r->name(r->name() + ")");
myRules.push_back(r);
//std::cout << "Composed rule " << r->name() << std::endl;
}
} else {
if (indices.size() > 0) {
if (t.optional)
r = new ruleT((*myRules.at(indices.at(0))) | qi::eps);
else
r = new ruleT((*myRules.at(indices.at(0))));
if (t.optional)
r->name("[" + (*myRules.at(indices.at(0))).name());
else
r->name("(" + (*myRules.at(indices.at(0))).name());
for (std::vector<ruleTPtr>::size_type i = 1; i < indices.size(); i++) {
if (t.optional)
(*r) = -((*r).copy() >> (*myRules.at(indices.at(i))))[qi::_val = px::bind(&concat2stdvectors, qi::_1, qi::_2)];
else
(*r) = ((*r).copy() >> (*myRules.at(indices.at(i))))[qi::_val = px::bind(&concat2stdvectors, qi::_1, qi::_2)];
r->name(r->name() + " >> " + (*myRules.at(indices.at(i))).name());
}
if (t.optional) {
r->name(r->name() + "]");
(*r) = -((*r).copy() || qi::eps);
} else
r->name(r->name() + ")");
myRules.push_back(r);
//std::cout << "Composed rule " << r->name() << std::endl;
}
}
}
void
printNonterminal(const std::string s1, const std::string s2) {
std::cout << " s1='" << s1 << "' s2 = '" << s2 << "'" << std::endl;
}
std::vector<std::string>
concat2stdvectors(const std::vector<std::string> &v1, const std::vector<std::string> &v2) {
std::vector<std::string> result(v1);
std::cout << "Vector1: ";
for (std::vector<std::string>::const_iterator it = v1.begin(); it != v1.end(); it++)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
std::cout << "Vector2: ";
for (std::vector<std::string>::const_iterator it = v2.begin(); it != v2.end(); it++)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
result.insert(result.end(), v2.begin(), v2.end());
return result;
}
std::vector<std::string>
nonTerminalInserter(std::vector<std::string> &v, const std::string &s1) {
for (std::vector<std::string>::iterator it = v.begin(); it != v.end(); it++) {
std::string buffer = *it;
(*it) = std::string("<nonterminal name=\"" + s1 + "\">").append(buffer).append("</nonterminal>");
}
return v;
}
void
printStringVector(std::vector<std::string> &v) {
std::cout << "Printing vector: ";
for (std::vector<std::string>::iterator it = v.begin(); it != v.end(); it++) {
std::cout << "[" << *it << "] ";
}
std::cout << std::endl;
}
jsgfParserTypes::TermT
makePTerm(jsgfParserTypes::TermT &t) {
t.optional = false;
t.orTerm = false;
return t;
}
jsgfParserTypes::TermT
makeOptTerm(jsgfParserTypes::TermT &t) {
t.optional = true;
t.orTerm = false;
return t;
}
jsgfParserTypes::TermT
makeOrTerm(jsgfParserTypes::TermT &t) {
t.optional = false;
t.orTerm = true;
return t;
}
return 0;
}
\ No newline at end of file
This diff is collapsed.
......@@ -5,56 +5,106 @@
* Created on June 2, 2013, 6:00 PM
*/
#define JSGFPARSER_DEBUG 1
#include "JsgfParser.h"
#include "dynamicParser.h"
#include <iostream>
#include <string>
#include <fstream>
int
main(int argc, char** argv) {
std::string s ("Moper");
/*
stringtest<std::string::const_iterator> myStringtest;
std::string attr;
qi::phrase_parse((std::string::const_iterator)s.begin(),(std::string::const_iterator)s.end(),myStringtest,ascii::space,attr);
std::cout << attr << std::endl;*/
std::vector<qi::rule<std::string::iterator,std::string(), qi::ascii::space_type>* > rules;
//rules.push_back (new )
/*
int attr = -1;
std::string s = "grammar DynamicTest;";
if (argc > 1)
s = std::string(argv[1]);
generatedRules gR;
std::vector<boost::spirit::qi::rule<std::string::iterator, boost::spirit::qi::ascii::space_type>* > myRules(3,NULL);
myRules.at(1) = new boost::spirit::qi::rule<std::string::iterator, boost::spirit::qi::ascii::space_type> (boost::spirit::qi::lexeme["#JSGF V1.0"]);
myRules.at(2) = new boost::spirit::qi::rule<std::string::iterator, boost::spirit::qi::ascii::space_type> (boost::spirit::qi::lexeme["grammar"] > boost::spirit::qi::lexeme[+(boost::spirit::qi::char_)]);
myRules.at(0) = new boost::spirit::qi::rule<std::string::iterator, boost::spirit::qi::ascii::space_type> (*(myRules.at(1)) | *(myRules.at(2)));
jsgfParser<std::string::iterator> myJsgfParser;
bool success = boost::spirit::qi::phrase_parse (s.begin(),s.end(), myJsgfParser,boost::spirit::qi::ascii::space, gR);
std::cout << "jsgfParser says: " << (success ? "OK" : "Error") << std::endl;
std::cout << "generatedRules: name = '" << gR.name.name << "' num of rules = " << gR.values.size() << std::endl;
for (std::vector<std::string>::size_type i = 0; i < gR.values.size(); i++)
std::cout << " type: " << gR.values.at(i).type << " name = '" << gR.values.at(i).name << "'" << std::endl;
dynamicParser<std::string::iterator> myDynamicParser(myRules);
bool dynSucc = boost::spirit::qi::phrase_parse(s.begin(),s.end(), myDynamicParser, boost::spirit::qi::ascii::space);
std::cout << "dynamicParser says: " << (dynSucc ? "OK" : "Error") << std::endl;*/
/*
std::vector<boost::spirit::qi::rule<iterator_t, void(int&)> > rules;
std::cout << "boost val: " << boost::phoenix::val(3)() << std::endl;
rules.push_back(boost::spirit::qi::char_('a')[boost::phoenix::val(0)]);
rules.push_back(boost::spirit::qi::char_('b')[boost::phoenix::val(1)]);
rules.push_back(boost::spirit::qi::char_('c')[boost::phoenix::val(2)]);
std::vector<boost::spirit::qi::rule<iterator_t, void(int&)> >::iterator i(rules.begin());
std::vector<boost::spirit::qi::rule<iterator_t, void(int&)> >::iterator last(rules.end());
boost::spirit::qi::rule<iterator_t, int()> temp;
temp = (*i)(boost::spirit::qi::_val); //[no_op]
for(++i; i!=last; ++i)
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " <filename.jsgf>" << std::endl;
return -1;
}
std::ifstream input(argv[1], std::ifstream::in);
if (!input.is_open()) {
std::cerr << "Could not open file: " << argv[1] << std::endl;
}
std::string storage; // We will read the contents here.
input.unsetf(std::ios::skipws); // No white space skipping!
std::copy(
std::istream_iterator<char>(input),
std::istream_iterator<char>(),
std::back_inserter(storage));
jsgfParserTypes::GrammarT myGrammar;
jsgfParserRuleGenerator<std::string::const_iterator> myJsgfParser;
std::string::const_iterator iter = storage.begin();
std::string::const_iterator end = storage.end();
bool success = qi::phrase_parse(iter, end, myJsgfParser, ascii::space, myGrammar);
if (success && iter == end) {
std::cout << "-------------------------\n";
std::cout << "Parsing succeeded\n";
std::cout << "-------------------------\n";
} else {
std::string::const_iterator some = iter + 30;
std::string context(iter, (some > end) ? end : some);
std::cout << "-------------------------\n";
std::cout << "Parsing failed\n";
std::cout << "stopped at: \": " << context << "...\"\n";
std::cout << "-------------------------\n";
return 1;
}
if (myJsgfParser.sanitizeCheckGrammar(myGrammar,true))
{
temp = temp.copy() | (*i)(boost::spirit::qi::_val); //[no_op]
std::cout << "JSGF check success" << std::endl;
}
boost::spirit::qi::rule<iterator_t, void(int&)> grammar;
grammar = temp;
else
{
std::cout << "JSGF check FAILED" << std::endl;
return 1;
}
std::cout << "My grammars Name is: " << myGrammar.name << " and the first rules name is " << myGrammar.rules.at(0).name << std::endl;
if (myJsgfParser.generateRules(myGrammar))
{
std::cout << "JSGF rules generated" << std::endl;
}
else
{
std::cout << "JSGF rule generation FAILED" << std::endl;
return 1;
}
std::vector<jsgfParserTypes::ruleTPtr> myRules = myJsgfParser.getRules();
dynamicParser<std::string::iterator> myDynamicParser (myRules);
std::string st ("this is a task");
while (0 != st.compare(""))
{
getline(std::cin,st);
std::string::iterator ststart = st.begin();
std::string::iterator stend = st.end();
std::vector<std::string> attr;
//std::cin >> st;
bool dynSucc = boost::spirit::qi::phrase_parse(ststart,stend, myDynamicParser, boost::spirit::qi::ascii::space,attr);
if (dynSucc)
{
if (ststart != stend)
{
std::cout << "'" << st << "' parsed PARTLY successfully "<< std::endl;
std::cout << "Leftover: '" << std::string().assign(ststart,stend) << "'" << std::endl;
}
else
std::cout << "'" << st << "' parsed successfully "<< std::endl;
std::cout << "Resultvector: ";
for (std::vector<std::string>::iterator it=attr.begin();it != attr.end();it++)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
}
else
std::cout << "'" << st << "' not part of the grammar" << std::endl;
}
return 0;
}
if(parse_full("a", grammar(boost::phoenix::ref(attr)))) std::cout << attr << std::endl;
if(parse_full("b", grammar(boost::phoenix::ref(attr)))) std::cout << attr << std::endl;
if(parse_full("c", grammar(boost::phoenix::ref(attr)))) std::cout << attr << std::endl;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');*/
\ No newline at end of file
......@@ -10,12 +10,9 @@
#include <iostream>
#include <exception>
class PocketSphinxInitException: public std::exception {
public:
virtual const char* what() const throw()
{
return "Error occurred during initialization of pocketsphinx";
}
class PocketSphinxInitException: public std::runtime_error {
public:
PocketSphinxInitException(std::string const &s):std::runtime_error(s) {}
};
......
......@@ -5,30 +5,39 @@
* Created on May 14, 2013, 5:04 PM
*/
#include <qt4/Qt/qmessagebox.h>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/filesystem.hpp>
#include "PocketSphinxWidget.h"
#include "PocketsphinxAdapter.h"
#include "publishRsb.h"
pocketSphinxWidget::pocketSphinxWidget(int id)
{
myId = id;
boost::shared_ptr<rsbRemoteReceiver> pocketSphinxWidget::myRemoteReceiver;
void
pocketSphinxWidget::setupUI(std::string name, std::string hmm, std::string lm, std::string dict, std::string jsgf, std::string rsb, bool bestpath){
formLayout = boost::make_shared<QGridLayout>();
nameLabel = boost::make_shared<QLabel>("Name: ");
nameLineEdit = boost::make_shared<QLineEdit>("Put your random name here");
nameLineEdit = boost::make_shared<QLineEdit>(name.c_str());
hmmLabel = boost::make_shared<QLabel>("HMM Directory: ");
hmmLineEdit = boost::make_shared<QLineEdit> (HMM_DEFAULT);
hmmLineEdit = boost::make_shared<QLineEdit> (hmm.c_str());
hmmBrowseButton = boost::make_shared<QPushButton> ("Browse...");
lmLabel = boost::make_shared<QLabel> ("Language Model: ");
lmLineEdit = boost::make_shared<QLineEdit> (LM_DEFAULT);
lmLineEdit = boost::make_shared<QLineEdit> (lm.c_str());
lmBrowseButton = boost::make_shared<QPushButton> ("Browse...");
dictLabel = boost::make_shared<QLabel>("Dictionary: ");
dictLineEdit = boost::make_shared<QLineEdit> (DICT_DEFAULT);
dictLineEdit = boost::make_shared<QLineEdit> (dict.c_str());
dictBrowseButton = boost::make_shared<QPushButton> ("Browse...");
jsgfLabel = boost::make_shared<QLabel> ("JSGF: ");
jsgfLineEdit = boost::make_shared<QLineEdit> (JSGF_DEFAULT);
jsgfLineEdit = boost::make_shared<QLineEdit> (jsgf.c_str());
jsgfBrowseButton = boost::make_shared<QPushButton>("Browse...");
rsbLabel = boost::make_shared<QLabel> ("RSB Scope: ");
rsbLineEdit = boost::make_shared<QLineEdit>("/robocup/pocketsphinx/default");
rsbLineEdit = boost::make_shared<QLineEdit>(rsb.c_str());
loadButton = boost::make_shared<QPushButton>("Load");
bestPathCeckBox = boost::make_shared<QCheckBox>("bestpath");
bestPathCeckBox->setChecked(bestpath);
errorMessageDialog = boost::make_shared<QErrorMessage> (this);
formLayout->addWidget(nameLabel.get(),0,0);
formLayout->addWidget(nameLineEdit.get(),0,1);
......@@ -46,7 +55,8 @@ pocketSphinxWidget::pocketSphinxWidget(int id)
formLayout->addWidget(jsgfBrowseButton.get(),4,2);
formLayout->addWidget(rsbLabel.get(),5,0);
formLayout->addWidget(rsbLineEdit.get(),5,1);
formLayout->addWidget(loadButton.get(),5,2);
formLayout->addWidget(bestPathCeckBox.get(),5,2);
formLayout->addWidget(loadButton.get(),5,3);
this->setLayout(formLayout.get());
QObject::connect (hmmBrowseButton.get(), SIGNAL ( clicked() ), this, SLOT ( hmmBrowse() ));
QObject::connect (lmBrowseButton.get(), SIGNAL ( clicked() ), this, SLOT ( lmBrowse() ));
......@@ -55,9 +65,17 @@ pocketSphinxWidget::pocketSphinxWidget(int id)
QObject::connect (loadButton.get(), SIGNAL ( clicked() ), this, SLOT ( loadPS() ));
}
pocketSphinxWidget::pocketSphinxWidget(const pocketSphinxWidget& orig) {
pocketSphinxWidget::pocketSphinxWidget(int id)
{
myId = id;
setupUI(PSW_DEFAULT_NAME,PSW_HMM_DEFAULT,PSW_LM_DEFAULT,PSW_DICT_DEFAULT,PSW_JSGF_DEFAULT,PSW_RSB_SCOPE_DEFAULT,PSW_BESTPATH_DEFAULT);
}
pocketSphinxWidget::pocketSphinxWidget(int id, boost::shared_ptr<PocketSphinxInstanceConfig> myPSIConfig) : myId(id) {
setupUI(myPSIConfig->GetName(),myPSIConfig->GetHmmDir(),myPSIConfig->GetLmDir(),myPSIConfig->GetDictDir(),myPSIConfig->GetJsgfDir(),myPSIConfig->GetRsbScope(),myPSIConfig->IsBestpath());
}
pocketSphinxWidget::~pocketSphinxWidget() {
QObject::disconnect(hmmBrowseButton.get(), SIGNAL( clicked() ), this, SLOT( hmmBrowse() ));
QObject::disconnect(lmBrowseButton.get(), SIGNAL( clicked() ), this, SLOT( lmBrowse() ));
......@@ -69,7 +87,7 @@ pocketSphinxWidget::~pocketSphinxWidget() {
void
pocketSphinxWidget::hmmBrowse()
{
QString dirname = QFileDialog::getExistingDirectory(this,tr("HMM Directory"),NULL,QFileDialog::ShowDirsOnly);
QString dirname = QFileDialog::getExistingDirectory(this,tr("HMM Directory"),hmmLineEdit->text(),QFileDialog::ShowDirsOnly);
if (dirname.compare("") != 0)
hmmLineEdit->setText(dirname);
}
......@@ -77,7 +95,7 @@ pocketSphinxWidget::hmmBrowse()
void
pocketSphinxWidget::lmBrowse()
{
QString lmname = QFileDialog::getOpenFileName(this,tr("Language Model File"),NULL,tr("Language Models (*.DMP)"));
QString lmname = QFileDialog::getOpenFileName(this,tr("Language Model File"),lmLineEdit->text(),tr("Language Models (*.DMP)"));
if (lmname.compare("") != 0)
lmLineEdit->setText(lmname);
}
......@@ -85,7 +103,7 @@ pocketSphinxWidget::lmBrowse()
void
pocketSphinxWidget::dictBrowse()
{
QString dictname = QFileDialog::getOpenFileName(this,tr("Language Model File"),NULL,tr("Dictionary (*.dic)"));
QString dictname = QFileDialog::getOpenFileName(this,tr("Language Model File"),dictLineEdit->text(),tr("Dictionary (*.dic)"));
if (dictname.compare("") != 0)
dictLineEdit->setText(dictname);
}
......@@ -93,7 +111,7 @@ pocketSphinxWidget::dictBrowse()
void
pocketSphinxWidget::jsgfBrowse()
{
QString jsgfName = QFileDialog::getOpenFileName(this,tr("Java Speech Grammar Format"), NULL, tr("JSGF (*.jsgf)"));
QString jsgfName = QFileDialog::getOpenFileName(this,tr("Java Speech Grammar Format"), jsgfLineEdit->text(), tr("JSGF (*.jsgf)"));
if (jsgfName.compare("") != 0)
jsgfLineEdit->setText(jsgfName);
}
......@@ -104,7 +122,8 @@ pocketSphinxWidget::loadPS()
if (psw.use_count() < 1)
{
try {
psw = boost::make_shared<PocketSphinxWrapper>(hmmLineEdit->text().toStdString(),lmLineEdit->text().toStdString(),dictLineEdit->text().toStdString(),jsgfLineEdit->text().toStdString());
bool bestpath = bestPathCeckBox->isChecked();
psw = boost::make_shared<PocketSphinxWrapper>(nameLineEdit->text().toStdString(), hmmLineEdit->text().toStdString(),lmLineEdit->text().toStdString(),dictLineEdit->text().toStdString(),jsgfLineEdit->text().toStdString(),bestpath);
}
catch (PocketSphinxInitException &e)
{
......@@ -113,7 +132,19 @@ pocketSphinxWidget::loadPS()
errorMessageDialog->showMessage(message);
return;
}
myPublisher = boost::make_shared<publishRsb>(rsbLineEdit->text().toStdString());
if (myRemoteReceiver.use_count() < 1)
{
boost::filesystem::path myRsbPath = rsbLineEdit->text().toStdString();
myRsbPath.remove_filename();
std::string scope = myRsbPath.string();
//scope.append("/commands");
myRemoteReceiver = boost::make_shared<rsbRemoteReceiver>(scope);
}
connect (psw.get(), SIGNAL ( xmlResult (QString) ), myPublisher.get(), SLOT ( publishMessage (QString) ) );
connect (psw.get(), SIGNAL ( uttResult (QString) ), this, SLOT ( gotUttResult(QString) ) );
connect (myRemoteReceiver.get(), SIGNAL (remoteDisable() ), psw.get(), SLOT ( disableListening() ) );
connect (myRemoteReceiver.get(), SIGNAL (remoteEnable() ), psw.get(), SLOT (enableListening() ) );
connect (this, SIGNAL (uttStart() ), psw.get(), SLOT (uttStart() ) );
connect (this, SIGNAL (uttEnd() ), psw.get(), SLOT (uttEnd() ) );
connect (this, SIGNAL (uttDiscard() ), psw.get(), SLOT (uttDiscard() ));
......@@ -142,6 +173,7 @@ pocketSphinxWidget::loadPS()
formLayout->removeWidget(jsgfBrowseButton.get());
formLayout->removeWidget(rsbLabel.get());
formLayout->removeWidget(rsbLineEdit.get());
formLayout->removeWidget(bestPathCeckBox.get());
formLayout->removeWidget(loadButton.get());
nameLabel.reset();
nameLineEdit.reset();
......@@ -159,6 +191,7 @@ pocketSphinxWidget::loadPS()
jsgfLineEdit.reset();
rsbLabel.reset();
rsbLineEdit.reset();
bestPathCeckBox.reset();
loadButton.reset();
formLayout->addWidget(finalGroupBox.get(),0,0);
setLayout(formLayout.get());
......
......@@ -8,6 +8,7 @@
#ifndef POCKETSPHINXWIDGET_H
#define POCKETSPHINXWIDGET_H
#include <fstream>
#include <QApplication>
#include <QLabel>
#include <QLayout>
......@@ -25,14 +26,14 @@
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include "PocketSphinxWrapper.h"
#include "publishRsb.h"
#include "rsbRemoteReceiver.h"
#include "defaults.h"
#include "configFileParser.h"
#define HMM_DEFAULT MODELDIR "/hmm/en_US/hub4wsj_sc_8k"
//#define LM_DEFAULT MODELDIR "/lm/en/turtle.DMP"
#define LM_DEFAULT ""
//#define DICT_DEFAULT MODELDIR "/lm/en/turtle.dic"
#define DICT_DEFAULT ""
#define JSGF_DEFAULT "/homes/mschoepf/test.jsgf"
class pocketSphinxWidget : public QWidget{
......@@ -40,7 +41,7 @@ class pocketSphinxWidget : public QWidget{
public:
pocketSphinxWidget(int id);
pocketSphinxWidget(const pocketSphinxWidget& orig);
pocketSphinxWidget(int id, boost::shared_ptr<PocketSphinxInstanceConfig> myPSIConfig);
virtual ~pocketSphinxWidget();
bool isLoaded();
QString getName();
......@@ -69,10 +70,14 @@ private:
boost::shared_ptr<QLineEdit> rsbLineEdit;
boost::shared_ptr<QPushButton> loadButton;
boost::shared_ptr<QPushButton> unLoadButton;
boost::shared_ptr<QCheckBox> bestPathCeckBox;
boost::shared_ptr<QErrorMessage> errorMessageDialog;
boost::shared_ptr<PocketSphinxWrapper> psw;
boost::shared_ptr<publishRsb> myPublisher;
QString name;
QString rsbScope;
static boost::shared_ptr<rsbRemoteReceiver> myRemoteReceiver;
void setupUI(std::string name, std::string hmm, std::string lm, std::string dict, std::string jsgf, std::string rsb, bool bestpath);
public slots:
void hmmBrowse();
void lmBrowse();
......
This diff is collapsed.
......@@ -8,19 +8,28 @@
#ifndef POCKETSPHINXWRAPPER_H_
#define POCKETSPHINXWRAPPER_H_
#define MODELDIR "/usr/share/pocketsphinx/model"
#include <Qt/qobject.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/algorithm/string.hpp>
#include <pocketsphinx/pocketsphinx.h>
#include <sphinxbase/glist.h>
#include <sphinxbase/jsgf.h>
#include "jsgf_internal.h"
#include <iostream>
#include <queue>
#include "PocketSphinxInitException.h"
#include "dynamicParser.h"
#include "JsgfParser.h"
#include "dataRingBuffer.h"
#include "AlsaMicGrabber.h"
class PocketSphinxWrapper : public QObject {
......@@ -31,24 +40,36 @@ private:
cmd_ln_t* cmdLineConfig;
bool listening;
bool dataReady;
bool haveJsgf;
std::string name;
boost::condition_variable condWaitEndUtt;
boost::mutex processOnlyOne;
boost::shared_ptr<boost::thread> analyzeThread;
jsgf_t* jsgfPtr;
public:
PocketSphinxWrapper();
PocketSphinxWrapper(std::string hmm, std::string lm, std::string dict, std::string jsgf);
boost::shared_ptr<boost::thread> processPS;
boost::shared_ptr<dynamicParser<std::string::iterator> > myParser;
jsgfParserTypes::GrammarT myGrammar;
std::vector<jsgfParserTypes::ruleTPtr> myRules;
std::string ExtractTerminalFromGrammar (const std::string &xml);
std::string ReplaceTerminalWithId (const std::string &xmlString, unsigned int &startid);
dataRingBuffer myBuffer;
size_t countChunks;
boost::mutex queueMutex;
std::queue<std::vector<AlsaSoundChunkT> > myQueue;
public:
PocketSphinxWrapper(std::string name, std::string hmm, std::string lm, std::string dict, std::string jsgf,bool bestpath);
void RecognizeFromMicrophone();
virtual ~PocketSphinxWrapper();
QString MakeXml(std::string hypothese, int score, std::vector<std::string> grammartree);
public slots:
void pushChunk (short* chunk, unsigned int size);
void uttStart();
void uttEnd();
void uttDiscard();
void enableListening();
void disableListening();
signals:
void uttResult (QString result);
void xmlResult (QString result);
};
......
#include <qt4/Qt/qlayout.h>
#include <qt4/Qt/qmessagebox.h>
#include "PocketsphinxAdapter.h"
#include "configFileParser.h"
......@@ -37,8 +39,7 @@ pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(QWidget* parent) :
vBoxMainLayout->addWidget(addPWidget.get());
vBoxMainLayout->addLayout(pWidgetLayout.get());
quitButton = boost::make_shared<QPushButton> ("Quit");
vBoxMainLayout->addWidget(quitButton.get());
vBoxMainLayout->addWidget(quitButton.get());
connect(quitButton.get(), SIGNAL ( clicked()), this, SLOT ( quit()));
connect(openAlsaDeviceCheckBox.get(), SIGNAL ( stateChanged (int) ), this, SLOT ( handleAlsa (int) ));
connect(addPWidget.get(), SIGNAL (clicked() ), this, SLOT (addPocketSphinxWidget() ) );
......@@ -46,6 +47,55 @@ pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(QWidget* parent) :
QObject::connect(&amg, SIGNAL ( updated_dB_and_clipped(float, bool) ), &w, SLOT ( update_eq_only(float, bool) ) );*/
}
pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(boost::shared_ptr<PocketSphinxGlobalConfig> myConfig, QWidget* parent) : QMainWindow(parent) {
maxDb = averageDb = 0.0;
psInstanceCount = 0;
baseFrame = boost::make_shared<QFrame>(this);
baseFrame->setGeometry(0, 0, 1200, 1024);
vBoxMainLayout = boost::make_shared<QVBoxLayout>(baseFrame.get());
hBoxAlsaControlLayout = boost::make_shared<QHBoxLayout>();
alsaDeviceLabel = boost::make_shared<QLabel> ("Alsa Device: ");
alsaDeviceLineEdit = boost::make_shared<QLineEdit>(QString(myConfig->GetAlsaDevice().c_str()));
openAlsaDeviceCheckBox = boost::make_shared<QCheckBox>("Open Alsa Device");
hBoxAlsaControlLayout->addWidget(alsaDeviceLabel.get());
hBoxAlsaControlLayout->addWidget(alsaDeviceLineEdit.get());
hBoxAlsaControlLayout->addWidget(openAlsaDeviceCheckBox.get());
vBoxMainLayout->addLayout(hBoxAlsaControlLayout.get());
equalizerWidget = boost::make_shared<EqualizerColorWidget>();
vBoxMainLayout->addWidget(equalizerWidget.get());
dbLabel = boost::make_shared<QLabel>(QString("Level: 0.0 db, LTAverage: 0.0 db, STAverage: 0.0 db, Max: 0.0 db Phase: sleeping"));
vBoxMainLayout->addWidget(dbLabel.get());
simpleSegmenterWidget = boost::make_shared<simpleDoubleThresholdSegmenter>(myConfig->GetStartDB(),myConfig->GetUttDB(),myConfig->GetSilence(),myConfig->GetTimeout());
vBoxMainLayout->addWidget(simpleSegmenterWidget.get());
wellLabel = boost::make_shared<QLabel>("Well, all I can hear is ....: ");
vBoxMainLayout->addWidget(wellLabel.get());
psResultsTab = boost::make_shared<QTabWidget>();
//psResultsTab->sizeHint(QSize(500,500));
vBoxMainLayout->addWidget(psResultsTab.get());
addPWidget = boost::make_shared<QPushButton>("Add Pocketsphinx Dialog");
pWidgetLayout = boost::make_shared<QVBoxLayout>();
vBoxMainLayout->addWidget(addPWidget.get());
vBoxMainLayout->addLayout(pWidgetLayout.get());
quitButton = boost::make_shared<QPushButton> ("Quit");
vBoxMainLayout->addWidget(quitButton.get());
connect(quitButton.get(), SIGNAL(clicked()), this, SLOT(quit()));
connect(openAlsaDeviceCheckBox.get(), SIGNAL(stateChanged(int)), this, SLOT(handleAlsa(int)));
connect(addPWidget.get(), SIGNAL(clicked()), this, SLOT(addPocketSphinxWidget()));
std::vector < boost::shared_ptr<PocketSphinxInstanceConfig> > psConfigVector = myConfig->GetPocketSphinxInstanceVector();
for (std::vector<boost::shared_ptr<PocketSphinxInstanceConfig> >::iterator it = psConfigVector.begin(); it != psConfigVector.end(); it++) {
pWidget.push_back(boost::make_shared<pocketSphinxWidget>(psInstanceCount,*it));
pWidgetLayout->addWidget(pWidget.at(psInstanceCount).get());
psResultsTextEdit.push_back(boost::make_shared<simpleTextAddField>());
connect(pWidget.at(psInstanceCount).get(), SIGNAL(psLoaded(int)), this, SLOT(psAddToText(int)));
psInstanceCount++;
if ((*it)->IsAutoload())
pWidget.back()->loadPS();
}
/*
QObject::connect(&amg, SIGNAL ( updated_dB_and_clipped(float, bool) ), &w, SLOT ( update_eq_only(float, bool) ) );*/
}
pocketsphinxAdapterMainWindow::~pocketsphinxAdapterMainWindow()
{
disconnect(quitButton.get(), SIGNAL ( clicked()), this, SLOT ( quit()));
......@@ -62,7 +112,7 @@ pocketsphinxAdapterMainWindow::addPocketSphinxWidget()
pWidgetLayout->addWidget(pWidget.at(psInstanceCount).get());
psResultsTextEdit.push_back(boost::make_shared<simpleTextAddField>());
connect (pWidget.at(psInstanceCount).get(), SIGNAL (psLoaded (int) ), this, SLOT (psAddToText(int) ) );
psInstanceCount++;
psInstanceCount++;
}
void
......@@ -73,37 +123,49 @@ pocketsphinxAdapterMainWindow::psAddToText(int id)
}
void
pocketsphinxAdapterMainWindow::handleAlsa(int state)
{
if (Qt::Unchecked == state)
{
disconnect(amg.get(), SIGNAL ( updated_dB_and_clipped(float, bool) ), this, SLOT ( update_eq_only(float, bool) ) );
disconnect(amg.get(), SIGNAL ( updated_dB_and_clipped(float, bool) ), simpleSegmenterWidget.get(), SLOT ( getDBandClipped (float, bool) ));
pocketsphinxAdapterMainWindow::handleAlsa(int state) {
disconnect(openAlsaDeviceCheckBox.get(), SIGNAL(stateChanged(int)), this, SLOT(handleAlsa(int)));
if (Qt::Unchecked == state) {
disconnect(amg.get(), SIGNAL(updated_dB_and_clipped(float, bool) ), this, SLOT(update_eq_only(float, bool)));
disconnect(amg.get(), SIGNAL(updated_dB_and_clipped(float, bool) ), simpleSegmenterWidget.get(), SLOT(getDBandClipped(float, bool)));
update_eq_only(0.0, false);
for (int i = 0; i < psInstanceCount; i++) {
if (pWidget.at(i)->isLoaded()) {
disconnect(amg.get(), SIGNAL(pushGrab(short*, unsigned int)), pWidget.at(i).get(), SLOT(gotPushChunk(short*, unsigned int)));
//connect (startUttButton, SIGNAL (clicked () ), pWidget, SLOT (gotUttStart() ) );
//connect (endUttButton, SIGNAL (clicked () ), pWidget, SLOT (gotUttEnd() ) );
disconnect(simpleSegmenterWidget.get(), SIGNAL(uttStart()), pWidget.at(i).get(), SLOT(gotUttStart()));
disconnect(simpleSegmenterWidget.get(), SIGNAL(uttEnd()), pWidget.at(i).get(), SLOT(gotUttEnd()));
disconnect(simpleSegmenterWidget.get(), SIGNAL(uttDiscard()), pWidget.at(i).get(), SLOT(gotUttDiscard()));
}
}
amg.reset();
update_eq_only(0.0,false);
openAlsaDeviceCheckBox->setChecked(false);
connect(openAlsaDeviceCheckBox.get(), SIGNAL(stateChanged(int)), this, SLOT(handleAlsa(int)));
return;
}
try {
amg = boost::make_shared<AlsaMicGrabber>(alsaDeviceLineEdit->text().toStdString());
}
catch (AlsaPcmDeviceNotFoundException &e)
{
} catch (AlsaPcmDeviceNotFoundException &e) {
std::cerr << "Device not found (permissions?): " << alsaDeviceLineEdit->text().toStdString().c_str() << std::endl;
openAlsaDeviceCheckBox->setChecked(false);
connect(openAlsaDeviceCheckBox.get(), SIGNAL(stateChanged(int)), this, SLOT(handleAlsa(int)));
return;
}
connect(amg.get(), SIGNAL ( updated_dB_and_clipped(float, bool) ), this, SLOT ( update_eq_only(float, bool) ) );
connect(amg.get(), SIGNAL ( updated_dB_and_clipped(float, bool) ), simpleSegmenterWidget.get(), SLOT ( getDBandClipped (float, bool) ));
for (int i=0; i < psInstanceCount; i++)
if (pWidget.at(i)->isLoaded())
{
connect (amg.get(), SIGNAL ( pushGrab (short*, unsigned int) ), pWidget.at(i).get(), SLOT ( gotPushChunk(short*, unsigned int) ) );
//connect (startUttButton, SIGNAL (clicked () ), pWidget, SLOT (gotUttStart() ) );
//connect (endUttButton, SIGNAL (clicked () ), pWidget, SLOT (gotUttEnd() ) );
connect (simpleSegmenterWidget.get(), SIGNAL ( uttStart() ), pWidget.at(i).get(), SLOT (gotUttStart() ) );
connect (simpleSegmenterWidget.get(), SIGNAL ( uttEnd() ), pWidget.at(i).get(), SLOT (gotUttEnd() ) );
connect (simpleSegmenterWidget.get(), SIGNAL ( uttDiscard() ), pWidget.at(i).get(), SLOT (gotUttDiscard() ) );
connect(amg.get(), SIGNAL(updated_dB_and_clipped(float, bool)), this, SLOT(update_eq_only(float, bool)));
connect(amg.get(), SIGNAL(updated_dB_and_clipped(float, bool)), simpleSegmenterWidget.get(), SLOT(getDBandClipped(float, bool)));
for (int i = 0; i < psInstanceCount; i++) {
if (pWidget.at(i)->isLoaded()) {
connect(amg.get(), SIGNAL(pushGrab(short*, unsigned int)), pWidget.at(i).get(), SLOT(gotPushChunk(short*, unsigned int)));
//connect (startUttButton, SIGNAL (clicked () ), pWidget, SLOT (gotUttStart() ) );
//connect (endUttButton, SIGNAL (clicked () ), pWidget, SLOT (gotUttEnd() ) );
connect(simpleSegmenterWidget.get(), SIGNAL(uttStart()), pWidget.at(i).get(), SLOT(gotUttStart()));
connect(simpleSegmenterWidget.get(), SIGNAL(uttEnd()), pWidget.at(i).get(), SLOT(gotUttEnd()));
connect(simpleSegmenterWidget.get(), SIGNAL(uttDiscard()), pWidget.at(i).get(), SLOT(gotUttDiscard()));
}
}
openAlsaDeviceCheckBox->setChecked(true);
connect(openAlsaDeviceCheckBox.get(), SIGNAL(stateChanged(int)), this, SLOT(handleAlsa(int)));
}
void
......@@ -146,16 +208,43 @@ pocketsphinxAdapterMainWindow::update_eq_only(float val, bool clipped) {
void
pocketsphinxAdapterMainWindow::quit()
{
emit gotQuit();
if (openAlsaDeviceCheckBox->isChecked())
{
switch ( QMessageBox::warning(
this, "Do you REALLY want to do that?",
"Really Quit??",
"&Yes", "&No", QString::null, 1, 1 ) )
{
case 0:
emit gotQuit();
break;
default:
break;
}
}
else
emit gotQuit();
}
int
main (int argc, char** argv)
{
QApplication myapp (argc,argv);
pocketsphinxAdapterMainWindow w;
w.setGeometry(200,100,1200,1024);
w.show();
QObject::connect(&w, SIGNAL ( gotQuit() ), &myapp, SLOT ( quit() ));
return myapp.exec();
main(int argc, char** argv) {
QApplication myapp(argc, argv);
boost::shared_ptr<PocketSphinxGlobalConfig> myConfig;
if (argc > 1) {
parseConfigFile myConfigFileParser(argv[1]); //I know, argv[1] may be NULL
myConfigFileParser.doParse();
myConfig = myConfigFileParser.getConfig();
} else {
parseConfigFile myConfigFileParser("");
myConfig = myConfigFileParser.getConfig(); //This essentially means: get defaults
}
pocketsphinxAdapterMainWindow w(myConfig);
w.setGeometry(200, 100, 1200, 1024);
w.show();
QObject::connect(&w, SIGNAL(gotQuit()), &myapp, SLOT(quit()));
if (myConfig->IsOpenDeviceDirectly())
{
w.handleAlsa(Qt::Checked);
}
return myapp.exec();
}
......@@ -22,6 +22,8 @@
#include "PocketSphinxWidget.h"
#include "SimpleDoubleThresholdSegmenter.h"
#include "SimpleTextAddField.h"
#include "rsbRemoteReceiver.h"
#include "configFileParser.h"
class pocketsphinxAdapterMainWindow : public QMainWindow
{
......@@ -49,8 +51,8 @@ private:
boost::shared_ptr<QPushButton> addPWidget;
boost::shared_ptr<QPushButton> quitButton;
std::vector<boost::shared_ptr<pocketSphinxWidget> > pWidget;
boost::shared_ptr<AlsaMicGrabber> amg;
boost::shared_ptr<rsbRemoteReceiver> myRemoteReceiver;
boost::shared_ptr<AlsaMicGrabber> amg;
/*protected:
virtual void paintEvent(QPaintEvent *event);*/
......@@ -68,5 +70,6 @@ public slots:
public:
pocketsphinxAdapterMainWindow(QWidget *parent = 0);
pocketsphinxAdapterMainWindow(boost::shared_ptr<PocketSphinxGlobalConfig> myConfig,QWidget *parent = 0);
~pocketsphinxAdapterMainWindow();
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment