University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

Adding subtitles, SpeechBehavior.getUtterance() always returning empty string | General SmartBody Discussion | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Adding subtitles, SpeechBehavior.getUtterance() always returning empty string
June 30, 2015
12:03 pm
Avatar
Member
Members
Forum Posts: 29
Member Since:
September 30, 2014
sp_UserOfflineSmall Offline

Hi,

For the needs of my project, I would like to add subtitles. To do that, I attempted to get speech behaviors on the character and call the getUtterance() method. Unfortunatelly, it seems that the _utterance attribute in SpeechBehavior object never gets filled. As a result, the return value is always an empty string. I ran through the source code and could not find an easy fix so far.

What should I do to fix this? If too much trouble, is there another way to get the speech content of a BML command so I can display it?

Thanks,

Pierre

June 30, 2015
5:37 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Just added a fix for this in r6125. Use the SVN repository and update to get this code. getUtterance() should work properly now.

Ari

July 1, 2015
7:56 am
Avatar
Member
Members
Forum Posts: 29
Member Since:
September 30, 2014
sp_UserOfflineSmall Offline

Hi Ari,

This is great news. I'll download the latest release.

Thanks,

Pierre

July 2, 2015
12:03 pm
Avatar
Member
Members
Forum Posts: 29
Member Since:
September 30, 2014
sp_UserOfflineSmall Offline

Hi,

I have tested with the changes you made in r6125. getUtterance() does not returns empty strings anymore, however, when using the SSML "break" command in my speech BML instruction, I only get the text untill the "<break/>" tag. How can I fix this ?

Thanks,

Pierre

July 2, 2015
4:46 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

In the file bml_speech.cpp, the code that does it is here:

 

void recurseSpeechNodes(rapidxml::xml_node<>* curNode, std::stringstream& strstr)
{
strstr<< curNode->value();
rapidxml::xml_node<>* childNode = curNode->first_node(NULL);
while (childNode)
{
recurseSpeechNodes(childNode, strstr);
childNode = childNode->first_node(NULL);
}

rapidxml::xml_node<>* siblingNode = curNode->next_sibling(NULL);
while (siblingNode)
{
recurseSpeechNodes(siblingNode, strstr);
siblingNode = siblingNode->next_sibling(NULL);
}
}

std::string BML::SpeechRequest::getSpeechText()
{
// if the speech text is empty but speech xml is not, extract the text from the XML
if (speechText == "" && speechXML != "")
{
std::stringstream strstr;
vector<char> xml_copy(speechXML.begin(), speechXML.end());
xml_copy.push_back('');

rapidxml::xml_document<> doc;

//doc.parse<rapidxml::parse_declaration_node | rapidxml::parse_no_data_nodes>(&xml_copy[0]);
doc.parse<rapidxml::parse_declaration_node>(&xml_copy[0]);

rapidxml::xml_node<>* speechNode = doc.first_node("speech");
if (speechNode)
{
recurseSpeechNodes(speechNode, strstr);
}
speechText = strstr.str();
}

return speechText;
}

There must be a bug in there that doesn't parse past the &lt;break&gt; node

 

Ari

July 3, 2015
3:01 am
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Ok, found and fixed the problem in r6130. Update SVN and please try again.

 

Ari

July 3, 2015
10:20 am
Avatar
Member
Members
Forum Posts: 29
Member Since:
September 30, 2014
sp_UserOfflineSmall Offline

Hi Ari,

It works perfectly now. Thanks.

Pierre

Forum Timezone: America/Los_Angeles

Top Posters:

jwwalker: 80

jyambao: 52

rbaral: 47

adiaz: 30

WargnierP: 29

lucky7456969: 28

mbarros: 28

avida.matt: 26

JonathanW: 24

laguerre: 23

Member Stats:

Guest Posters: 67

Members: 99543

Moderators: 3

Admins: 4

Forum Stats:

Groups: 1

Forums: 5

Topics: 458

Posts: 2401