Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion src/Am/AcousticModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public:

public:
AcousticModel(const Core::Configuration& c)
: Core::Component(c), Mc::Component(c) {}
: Core::Component(c),
Mc::Component(c) {}
virtual ~AcousticModel() {}

virtual void load(Mode mode = complete) = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/Am/AcousticModelAdaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
using namespace Am;

MixtureSetAdaptor::MixtureSetAdaptor(const Core::Configuration& c, Core::Ref<AcousticModel> toAdapt)
: Component(c), Precursor(c, toAdapt) {
: Component(c),
Precursor(c, toAdapt) {
Core::Ref<Mm::MixtureSet> mixtureSet = Mm::Module::instance().readMixtureSet(select("mixture-set"));
if (!mixtureSet || !setMixtureSet(mixtureSet))
criticalError("failed to initialize mixture set.");
Expand Down
3 changes: 2 additions & 1 deletion src/Am/AcousticModelAdaptor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ protected:

public:
AcousticModelAdaptor(const Core::Configuration& c, Core::Ref<AcousticModel> toAdapt)
: Component(c), toAdapt_(toAdapt) {
: Component(c),
toAdapt_(toAdapt) {
require(toAdapt_);
}
virtual ~AcousticModelAdaptor() {}
Expand Down
1 change: 1 addition & 0 deletions src/Am/ClassicAcousticModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ bool ClassicAcousticModel::loadTransitionModel() {
transitionModel_->setParentScale(scale());
return true;
}

return false;
}

Expand Down
12 changes: 8 additions & 4 deletions src/Am/ClassicAcousticModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,20 @@ public:
return (*transitionModel_)[i];
}
virtual StateTransitionIndex stateTransitionIndex(AllophoneState phone, s8 subState = 0) const {
if (allophoneStateAlphabet()->isSilence(phone))
if (allophoneStateAlphabet()->isSilence(phone)) {
return TransitionModel::silence;
else
}
else {
return transitionModel_->classify(phone, subState);
}
}
virtual StateTransitionIndex stateTransitionIndex(AllophoneStateIndex e, s8 subState = 0) const {
if (silenceAllophoneStateIndex_ != Fsa::InvalidLabelId and e == silenceAllophoneStateIndex_)
if (silenceAllophoneStateIndex_ != Fsa::InvalidLabelId and e == silenceAllophoneStateIndex_) {
return TransitionModel::silence;
else
}
else {
return transitionModel_->classifyIndex(e, subState);
}
}

virtual const ClassicHmmTopology* hmmTopology(Bliss::Phoneme::Id phoneme) const {
Expand Down
3 changes: 2 additions & 1 deletion src/Am/ClassicHmmTopologySet.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ClassicHmmTopology {

public:
ClassicHmmTopology(int nPhoneStates, int nSubStates)
: nPhoneStates_(nPhoneStates), nSubStates_(nSubStates) {}
: nPhoneStates_(nPhoneStates),
nSubStates_(nSubStates) {}
int nPhoneStates() const {
return nPhoneStates_;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Am/ClassicStateModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,9 @@ std::string AllophoneAlphabet::symbol(Fsa::LabelId id) const {

Fsa::LabelId AllophoneAlphabet::index(const std::string& symbol) const {
Fsa::LabelId lid = specialIndex(symbol);
if (lid == Fsa::InvalidLabelId)
if (lid == Fsa::InvalidLabelId) {
lid = index(fromString(symbol));
}
return lid;
}

Expand Down Expand Up @@ -798,7 +799,8 @@ struct IndexedAllophoneState {
Am::AllophoneState allophoneState;
IndexedAllophoneState() {}
IndexedAllophoneState(Fsa::LabelId id, Am::AllophoneState allophoneState)
: id(id), allophoneState(allophoneState) {}
: id(id),
allophoneState(allophoneState) {}
bool operator<(const IndexedAllophoneState& i) const {
return id < i.id;
}
Expand Down
22 changes: 15 additions & 7 deletions src/Am/ClassicStateModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ struct Allophone : public Phonology::Allophone {
Allophone()
: Precursor() {}
Allophone(Bliss::Phoneme::Id phoneme, s16 b)
: Precursor(phoneme), boundary(b) {}
: Precursor(phoneme),
boundary(b) {}
Allophone(const Phonology::Allophone& a, s16 b)
: Precursor(a), boundary(b) {}
: Precursor(a),
boundary(b) {}

bool operator==(const Allophone& allo) const {
return (boundary == allo.boundary) && Precursor::operator==(allo);
}

struct Hash {
Phonology::Allophone::Hash ah;
u32 operator()(const Allophone& a) const {

u32 operator()(const Allophone& a) const {
return ah(a) ^ (u32(a.boundary) << 13);
}
};
Expand Down Expand Up @@ -103,7 +106,8 @@ public:
private:
struct AllophonePtrHash {
Allophone::Hash h;
size_t operator()(const Allophone* const a) const {

size_t operator()(const Allophone* const a) const {
return h(*a);
}
};
Expand Down Expand Up @@ -228,11 +232,13 @@ private:

private:
AllophoneState(const Allophone* allo, s16 state)
: allo_(allo), state_(state) {}
: allo_(allo),
state_(state) {}

public:
AllophoneState()
: allo_(0), state_(0) {}
: allo_(0),
state_(0) {}

operator const Allophone*() const {
require(allo_);
Expand All @@ -258,13 +264,15 @@ public:
require(allo_);
return allo_;
}

s16 state() const {
return state_;
}

struct Hash {
Allophone::Hash ah;
u32 operator()(const AllophoneState& alloState) const {

u32 operator()(const AllophoneState& alloState) const {
return ah(alloState) ^ (u32(alloState.state()) << 21);
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/Am/ClassicStateTying.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ private:

public:
EmissionAlphabet(Mm::MixtureIndex nMixtures = 0)
: nMixtures_(nMixtures), nDisambiguators_(0) {}
: nMixtures_(nMixtures),
nDisambiguators_(0) {}
Mm::MixtureIndex nMixtures() const {
return nMixtures_;
}
Expand Down
35 changes: 23 additions & 12 deletions src/Am/ClassicTransducerBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ClassicTransducerBuilder::Statistics {
bool isCoarticulated;
PhoneBoundaryStateSetDescriptor(
const PhoneBoundaryStateDescriptor& pbsd)
: phoneBoundaryFlag(pbsd.flag), isCoarticulated(pbsd.isCoarticulated()) {
: phoneBoundaryFlag(pbsd.flag),
isCoarticulated(pbsd.isCoarticulated()) {
}

Core::XmlOpen xmlAttributes(const Core::XmlOpen&) const;
Expand Down Expand Up @@ -140,7 +141,10 @@ static const Core::ParameterBool paramFixAllophoneContextAtWordBoundaries(
ClassicTransducerBuilder::ClassicTransducerBuilder(Core::Ref<
const ClassicAcousticModel>
model)
: TransducerBuilder(), model_(model), silencesAndNoises_(0), allophoneSuffixes_(2500, AllophoneSuffix::Hash(this), AllophoneSuffix::Equality(this)) {
: TransducerBuilder(),
model_(model),
silencesAndNoises_(0),
allophoneSuffixes_(2500, AllophoneSuffix::Hash(this), AllophoneSuffix::Equality(this)) {
require(model);
allophones_ = model_->allophoneAlphabet();
allophoneList_ = &model_->allophoneAlphabet()->allophones();
Expand Down Expand Up @@ -649,8 +653,7 @@ Fsa::ConstAutomatonRef ClassicTransducerBuilder::applyTransitionModel(

const Allophone* silenceAllophone = allophones_->allophone(Allophone(
Phonology::Allophone(model_->silence_), Allophone::isInitialPhone | Allophone::isFinalPhone));
AllophoneState silenceState = allophoneStates_->allophoneState(
silenceAllophone, 0);
AllophoneState silenceState = allophoneStates_->allophoneState(silenceAllophone, 0);

Fsa::LabelId silenceLabel = Fsa::InvalidLabelId;
if (ff->inputAlphabet() == allophoneStates_)
Expand Down Expand Up @@ -921,15 +924,21 @@ struct PhoneContext : public Phones {
bool boundary_;
Fsa::LabelId disambiguator_;
PhoneContext(size_t n, bool boundary = false, Fsa::LabelId disambiguator = Fsa::Epsilon)
: Phones(n, Bliss::Phoneme::term), boundary_(boundary), disambiguator_(disambiguator) {
: Phones(n, Bliss::Phoneme::term),
boundary_(boundary),
disambiguator_(disambiguator) {
}
PhoneContext(const Phones& phones, bool boundary = false,
Fsa::LabelId disambiguator = Fsa::Epsilon)
: Phones(phones), boundary_(boundary), disambiguator_(disambiguator) {
: Phones(phones),
boundary_(boundary),
disambiguator_(disambiguator) {
}
PhoneContext(Phones::const_iterator pBegin, Phones::const_iterator pEnd,
bool boundary = false, Fsa::LabelId disambiguator = Fsa::Epsilon)
: Phones(pBegin, pEnd), boundary_(boundary), disambiguator_(disambiguator) {
: Phones(pBegin, pEnd),
boundary_(boundary),
disambiguator_(disambiguator) {
}
};

Expand All @@ -949,7 +958,9 @@ struct NoCoartBoundary {
Fsa::LabelId input_, phoneDisambiguator_;
NoCoartBoundary(Fsa::State* state, Fsa::LabelId input,
Fsa::LabelId phoneDisambiguator)
: state_(state), input_(input), phoneDisambiguator_(phoneDisambiguator) {
: state_(state),
input_(input),
phoneDisambiguator_(phoneDisambiguator) {
}
};

Expand Down Expand Up @@ -1005,10 +1016,10 @@ Fsa::ConstAutomatonRef ClassicTransducerBuilder::createMinimizedContextDependenc

Fsa::Hash<PhoneContext, PhoneContextHash> stateMap;
PhoneContext pc(maxHistory + maxFuture, true);
Fsa::State* initial = new Fsa::State(stateMap.insert(pc),
model_->isAcrossWordModelEnabled() ? Fsa::StateTagFinal
: Fsa::StateTagNone,
semiring->one());

Fsa::State* initial = new Fsa::State(stateMap.insert(pc),
model_->isAcrossWordModelEnabled() ? Fsa::StateTagFinal : Fsa::StateTagNone,
semiring->one());
_c->setState(initial);
_c->setInitialStateId(initial->id());
if (model_->isAcrossWordModelEnabled()) {
Expand Down
23 changes: 16 additions & 7 deletions src/Am/ClassicTransducerBuilder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,27 @@ private: // internal
struct PhoneBoundaryStateDescriptor {
Phonology::Context context;
u8 flag; // PhoneBoundaryFlags
bool isWordStart() const {

bool isWordStart() const {
return (flag & wordStart);
}

bool isWordEnd() const {
return (flag & wordEnd);
}

bool isCoarticulated() const {
return (!context.history.empty() && !context.future.empty());
}

bool operator==(const PhoneBoundaryStateDescriptor& r) const {
return (context == r.context) && (flag == r.flag);
}

struct Hash {
Phonology::Context::Hash ch;
u32 operator()(const PhoneBoundaryStateDescriptor& pbsd) const {

u32 operator()(const PhoneBoundaryStateDescriptor& pbsd) const {
return ch(pbsd.context) ^ (u32(pbsd.flag) << 13);
}
};
Expand All @@ -114,8 +120,10 @@ private: // internal

struct Hash {
ClassicTransducerBuilder* model;

Hash(ClassicTransducerBuilder* mm)
: model(mm) {}

size_t operator()(const AllophoneSuffix& as) const {
if (!as.hash_) {
as.hash_ = model->hashSequence(as);
Expand All @@ -128,20 +136,21 @@ private: // internal

struct Equality {
ClassicTransducerBuilder* model;

Equality(ClassicTransducerBuilder* mm)
: model(mm) {}

bool operator()(const AllophoneSuffix& l, const AllophoneSuffix& r) const {
return model->compareSequences(l, r) == 0;
}
};
};

size_t hashSequence(const AllophoneSuffix&);
int compareSequences(const AllophoneSuffix&, const AllophoneSuffix&);
typedef std::unordered_map<
AllophoneSuffix,
Fsa::StateId,
AllophoneSuffix::Hash, AllophoneSuffix::Equality>
AllophoneSuffixMap;

typedef std::unordered_map<AllophoneSuffix, Fsa::StateId, AllophoneSuffix::Hash, AllophoneSuffix::Equality> AllophoneSuffixMap;

AllophoneSuffixMap allophoneSuffixes_;

class Statistics;
Expand Down
Loading