text
stringlengths 0
2.2M
|
---|
FLAGS_criterion,
|
FLAGS_surround,
|
false /* isSeq2SeqCrit */,
|
FLAGS_replabel,
|
FLAGS_usewordpiece,
|
FLAGS_wordseparator);
|
std::vector<std::string> wordPrediction =
|
tkn2Wrd(letterPrediction, FLAGS_wordseparator);
|
float lmScore = 0;
|
if (!FLAGS_lm.empty()) {
|
// LM score
|
auto inState = lm->start(0);
|
for (const auto& word : wordPrediction) {
|
auto lmReturn = lm->score(inState, wordDict.getIndex(word));
|
inState = lmReturn.first;
|
lmScore += lmReturn.second;
|
}
|
auto lmReturn = lm->finish(inState);
|
lmScore += lmReturn.second;
|
}
|
// Determine results basename. In case the sample id contains an extension,
|
// else a noop
|
fl::lib::dirCreateRecursive(FLAGS_outpath);
|
auto baseName = fl::lib::pathsConcat(
|
FLAGS_outpath, sampleId.substr(0, sampleId.find_last_of(".")));
|
// Output chunk-level tokens outputs (or blanks)
|
std::ofstream tknOutStream(baseName + kTknFrameWiseTokensExt);
|
for (auto token : tokenPrediction) {
|
tknOutStream << tokenDict.getEntry(token) << " ";
|
}
|
tknOutStream << std::endl;
|
tknOutStream.close();
|
int blank = tokenDict.getIndex(kBlankToken);
|
int N = rawEmission.dims(0);
|
int T = rawEmission.dims(1);
|
float vadFrameCnt = 0;
|
auto emissions = afToVector<float>(softmax(rawEmission, 0).array());
|
for (int i = 0; i < T; i++) {
|
if (emissions[i * N + blank] < FLAGS_vad_threshold) {
|
vadFrameCnt += 1;
|
}
|
}
|
// Output chunk-level VAD probabilities
|
std::ofstream vadProbOutStream(baseName + kVadExt);
|
for (int i = 0; i < T; i++) {
|
vadProbOutStream << std::setprecision(4) << emissions[i * N + blank]
|
<< " ";
|
}
|
vadProbOutStream << std::endl;
|
vadProbOutStream.close();
|
// Token transcript
|
std::ofstream tScriptOutStream(baseName + kLtrTranscriptExt);
|
tScriptOutStream << join("", letterPrediction) << std::endl;
|
tScriptOutStream.close();
|
// Perplexity under the given LM and % of audio containing speech given VAD
|
// threshold
|
std::ofstream statsOutStream(baseName + kPerplexityPctSpeechExt);
|
statsOutStream << sampleId << " " << vadFrameCnt / T;
|
if (!FLAGS_lm.empty()) {
|
statsOutStream << " " << std::pow(10.0, -lmScore / wordPrediction.size());
|
}
|
statsOutStream << std::endl;
|
statsOutStream.close();
|
++cnt;
|
if (cnt == FLAGS_maxload) {
|
break;
|
}
|
}
|
return 0;
|
}
|
/*
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
*
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
* you may not use this file except in compliance with the License.
|
* You may obtain a copy of the License at
|
*
|
* http://www.apache.org/licenses/LICENSE-2.0
|
*
|
* Unless required by applicable law or agreed to in writing, software
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* See the License for the specific language governing permissions and
|
* limitations under the License.
|
*/
|
#include <folly/futures/detail/Core.h>
|
#include <new>
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.