This commit is contained in:
Vadim Mazalov 2018-11-05 16:32:59 -08:00
Родитель a19ce9ef7c
Коммит b51e8c243a
4 изменённых файлов: 47 добавлений и 0 удалений

Просмотреть файл

@ -6069,6 +6069,12 @@ namespace CNTK
///
CNTK_API Deserializer HTKMLFDeserializer(const std::wstring& streamName, const std::wstring& labelMappingFile, size_t dimension, const std::vector<std::wstring>& mlfFiles, bool phoneBoundaries = false);
///
/// Create an HTKMLFBinaryDeserializer with the specified options
///
CNTK_API Deserializer HTKMLFBinaryDeserializer(const std::wstring& streamName, const std::vector<std::wstring>& mlfFiles, size_t dimension);
///
/// Create a LatticeDeserializer with the specified options
///

Просмотреть файл

@ -512,6 +512,24 @@ namespace CNTK
return htk;
}
Deserializer HTKMLFBinaryDeserializer(const std::wstring& streamName, const std::vector<std::wstring>& mlfFiles, size_t dimension)
{
Deserializer htk;
Dictionary stream;
Dictionary labels;
std::vector<DictionaryValue> actualFiles;
std::transform(mlfFiles.begin(), mlfFiles.end(), std::back_inserter(actualFiles), [](const std::wstring& s) {return static_cast<DictionaryValue>(s); });
if (actualFiles.size() > 1)
labels[L"mlfFileList"] = actualFiles;
else if (actualFiles.size() == 1)
labels[L"mlfFile"] = actualFiles[0];
else
LogicError("HTKMLFDeserializer: No mlf files were specified");
stream[streamName] = labels;
htk.Add(L"type", L"HTKMLFBinaryDeserializer", L"input", stream);
return htk;
}
Deserializer LatticeDeserializer(const std::wstring& streamName, const std::wstring& latticeIndexFile)
{
Deserializer lattice;

Просмотреть файл

@ -208,6 +208,9 @@ public:
(const msra::math::ssematrixbase&) predstripe, (const msra::asr::simplesenonehmm&) m_hset,
(msra::math::ssematrixbase&) dengammasstripe, (msra::math::ssematrixbase&) gammasbuffer /*empty, not used*/,
lmf, wp, amf, boostmmifactor, seqsMBRmode, uidsstripe, boundariesstripe);
if (denavlogp < LOGZERO / 2)
return;
objectValue += (ElemType)((numavlogp - denavlogp) * numframes);
if (samplesInRecurrentStep == 1)

Просмотреть файл

@ -823,6 +823,26 @@ def HTKMLFDeserializer(label_mapping_file, streams, phoneBoundaries = False):
master_label_files = [master_label_files]
return cntk_py.htk_mlf_deserializer(stream_name, label_mapping_file, dimension, master_label_files, phoneBoundaries)
def HTKMLFBinaryDeserializer(mlf_file, dimension, streams):
'''
Configures a binary HTK label reader that reads speech MLF (Master
Label File)
Args:
mlf_file (str): path to the label mapping file
dimension (int): dimension of the labels
streams: any dictionary-like object that contains a mapping from stream
names to :class:`StreamDef` objects. Each StreamDef object configures
a label stream.
'''
if len(streams) != 1:
raise ValueError("HTKMLFBinaryDeserializer only accepts a single stream")
for stream_name, stream in streams.items():
if stream.stream_alias is not None:
raise ValueError("HTKMLFBinaryDeserializer does not support stream names")
return cntk_py.htk_mlf_binary_deserializer(stream_name, mlf_file, dimension)
def LatticeDeserializer(lattice_index_file, streams):
'''
Configures a lattice deserializer