Skip to content

Commit

Permalink
Optimized animation for words containing "to"
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSWolf committed Mar 26, 2017
1 parent e94f7b9 commit 50a27e7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/recognition/phoneRecognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ JoiningTimeline<void> getNoiseSounds(TimeRange utteranceTimeRange, const Timelin
return noiseSounds;
}

// Some words have multiple pronunciations, one of which results in better animation than the others.
// This function returns the optimal pronunciation for a select set of these words.
string fixPronunciation(const string& word) {
const static map<string, string> replacements {
{"into(2)", "into"},
{"to(2)", "to"},
{"to(3)", "to"},
{"today(2)", "today"},
{"tomorrow(2)", "tomorrow"},
{"tonight(2)", "tonight"}
};

const auto pair = replacements.find(word);
return pair != replacements.end() ? pair->second : word;
}

Timeline<Phone> utteranceToPhones(
const AudioClip& audioClip,
TimeRange utteranceTimeRange,
Expand Down Expand Up @@ -384,7 +400,8 @@ Timeline<Phone> utteranceToPhones(
// Convert word strings to word IDs using dictionary
vector<s3wid_t> wordIds;
for (const auto& timedWord : words) {
wordIds.push_back(getWordId(timedWord.getValue(), *decoder.dict));
const string fixedWord = fixPronunciation(timedWord.getValue());
wordIds.push_back(getWordId(fixedWord, *decoder.dict));
}
if (wordIds.empty()) return {};

Expand Down

0 comments on commit 50a27e7

Please sign in to comment.