|
|
|
@ -12,14 +12,14 @@
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#include "recognizer/u2_recognizer.h"
|
|
|
|
|
#include "common/base/thread_pool.h"
|
|
|
|
|
#include "common/utils/strings.h"
|
|
|
|
|
#include "common/utils/file_utils.h"
|
|
|
|
|
#include "common/utils/strings.h"
|
|
|
|
|
#include "decoder/param.h"
|
|
|
|
|
#include "frontend/wave-reader.h"
|
|
|
|
|
#include "nnet/u2_nnet.h"
|
|
|
|
|
#include "kaldi/util/table-types.h"
|
|
|
|
|
#include "recognizer/u2_recognizer.h"
|
|
|
|
|
#include "nnet/u2_nnet.h"
|
|
|
|
|
|
|
|
|
|
DEFINE_string(wav_rspecifier, "", "test feature rspecifier");
|
|
|
|
|
DEFINE_string(result_wspecifier, "", "test result wspecifier");
|
|
|
|
@ -60,8 +60,8 @@ void recognizer_func(const ppspeech::U2RecognizerResource& resource,
|
|
|
|
|
int chunk_sample_size = FLAGS_streaming_chunk * FLAGS_sample_rate;
|
|
|
|
|
if (wavlist.empty()) return;
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ppspeech::U2Recognizer> recognizer_ptr(
|
|
|
|
|
new ppspeech::U2Recognizer(resource, nnet));
|
|
|
|
|
std::shared_ptr<ppspeech::U2Recognizer> recognizer_ptr =
|
|
|
|
|
std::make_shared<ppspeech::U2Recognizer>(resource, nnet);
|
|
|
|
|
|
|
|
|
|
results->reserve(wavlist.size());
|
|
|
|
|
for (size_t idx = 0; idx < wavlist.size(); ++idx) {
|
|
|
|
@ -157,11 +157,16 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
vector<vector<string>> uttlist;
|
|
|
|
|
vector<vector<string>> resultlist(njob);
|
|
|
|
|
vector<std::future<void>> futurelist;
|
|
|
|
|
std::thread threads[njob];
|
|
|
|
|
std::shared_ptr<ppspeech::U2Nnet> nnet(new ppspeech::U2Nnet(resource.model_opts));
|
|
|
|
|
std::shared_ptr<ppspeech::U2Nnet> nnet(
|
|
|
|
|
new ppspeech::U2Nnet(resource.model_opts));
|
|
|
|
|
SplitUtt(FLAGS_wav_rspecifier, &uttlist, &wavlist, njob);
|
|
|
|
|
for (size_t i = 0; i < njob; ++i) {
|
|
|
|
|
std::future<void> f = threadpool.enqueue(recognizer_func, resource, nnet->Clone(), wavlist[i], uttlist[i], &resultlist[i]);
|
|
|
|
|
std::future<void> f = threadpool.enqueue(recognizer_func,
|
|
|
|
|
resource,
|
|
|
|
|
nnet->Clone(),
|
|
|
|
|
wavlist[i],
|
|
|
|
|
uttlist[i],
|
|
|
|
|
&resultlist[i]);
|
|
|
|
|
futurelist.push_back(std::move(f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|