Fixed corner cases
Handling silences and last mouth shape
This commit is contained in:
parent
7b282ce50f
commit
e4b5b39504
|
@ -25,6 +25,7 @@ boost::bimap<string, Phone> phonesByName = makeBimap<string, Phone>({
|
|||
});
|
||||
|
||||
Phone stringToPhone(const string& s) {
|
||||
if (s == "SIL") return Phone::None;
|
||||
auto it = phonesByName.left.find(s);
|
||||
return (it != phonesByName.left.end()) ? it->second : Phone::Unknown;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "mouth_animation.h"
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
using std::map;
|
||||
|
||||
|
@ -69,10 +70,10 @@ Shape getShape(Phone phone) {
|
|||
map<centiseconds, Shape> animate(const map<centiseconds, Phone> &phones) {
|
||||
map<centiseconds, Shape> shapes;
|
||||
Shape lastShape = Shape::Invalid;
|
||||
for (auto& pair : phones) {
|
||||
Shape shape = getShape(pair.second);
|
||||
if (shape != lastShape) {
|
||||
shapes[pair.first] = shape;
|
||||
for (auto it = phones.cbegin(); it != phones.cend(); it++) {
|
||||
Shape shape = getShape(it->second);
|
||||
if (shape != lastShape || next(it) == phones.cend()) {
|
||||
shapes[it->first] = shape;
|
||||
lastShape = shape;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue