diff widgets/SpeechFileHandler.cpp @ 262:3f41cb822166

first code for the speech recognition
author benoitrigolleau
date Fri, 20 Jun 2008 12:33:08 +0000
parents
children 63a485275ed6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/SpeechFileHandler.cpp	Fri Jun 20 12:33:08 2008 +0000
@@ -0,0 +1,54 @@
+#include "SpeechFileHandler.h"
+
+SpeechFileHandler::SpeechFileHandler(){
+	_tag_vocal_query_result="vocal_query_result";
+	_tag_word="word";
+	_tag_confidence = "confidence";
+	_result = "";
+}
+SpeechFileHandler::~SpeechFileHandler(){
+
+}
+bool SpeechFileHandler::fatalError (const QXmlParseException & exception){
+	return false;
+}
+
+bool SpeechFileHandler::characters ( const QString &str){
+	return true;
+}
+
+bool SpeechFileHandler::endDocument (){
+	return true;
+}
+
+bool SpeechFileHandler::endElement (const QString &namespaceURI, const QString &localName, const QString &qName ){
+	_currentTag = "";
+	if(localName==_tag_vocal_query_result){
+		_result+="<br>";
+	}
+	return true;
+}
+
+bool SpeechFileHandler::startDocument (){
+	return true;
+}
+
+bool SpeechFileHandler::startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attribs ){
+	_currentTag = localName;
+	if(localName == _tag_vocal_query_result){
+		for(int i = 0 ; i < attribs.length() ; i++){
+			QString aux = attribs.localName(i);
+			if(aux==_tag_word){
+				_result+=attribs.value(i);
+			}else if(aux == _tag_confidence){
+				_result+="\t";
+				_result+=attribs.value(i);
+			}
+		}
+	}
+	return true;
+}
+	
+QString SpeechFileHandler::getResult(){
+	return _result;
+}
\ No newline at end of file