|
@ -16,7 +16,7 @@ |
|
|
#include "grpc/grpc_client.h"
|
|
|
#include "grpc/grpc_client.h"
|
|
|
#include "utils/flags.h"
|
|
|
#include "utils/flags.h"
|
|
|
#include "utils/timer.h"
|
|
|
#include "utils/timer.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "gflags/gflags.h"
|
|
|
DEFINE_string(hostname, "127.0.0.1", "hostname of websocket server"); |
|
|
DEFINE_string(hostname, "127.0.0.1", "hostname of websocket server"); |
|
|
DEFINE_int32(port, 10086, "port of websocket server"); |
|
|
DEFINE_int32(port, 10086, "port of websocket server"); |
|
|
DEFINE_int32(nbest, 1, "n-best of decode result"); |
|
|
DEFINE_int32(nbest, 1, "n-best of decode result"); |
|
@ -24,22 +24,22 @@ DEFINE_string(wav_path, "", "test wav file path"); |
|
|
DEFINE_bool(continuous_decoding, false, "continuous decoding mode"); |
|
|
DEFINE_bool(continuous_decoding, false, "continuous decoding mode"); |
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { |
|
|
int main(int argc, char* argv[]) { |
|
|
gflags::ParseCommandLineFlags(&argc, &argv, false); |
|
|
|
|
|
google::InitGoogleLogging(argv[0]); |
|
|
|
|
|
wenet::GrpcClient client(FLAGS_hostname, FLAGS_port, FLAGS_nbest, |
|
|
|
|
|
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, false); |
|
|
|
|
|
google::InitGoogleLogging(argv[0]); |
|
|
|
|
|
wenet::GrpcClient client(FLAGS_hostname, FLAGS_port, FLAGS_nbest, |
|
|
FLAGS_continuous_decoding); |
|
|
FLAGS_continuous_decoding); |
|
|
|
|
|
|
|
|
wenet::WavReader wav_reader(FLAGS_wav_path); |
|
|
|
|
|
const int sample_rate = 16000; |
|
|
|
|
|
// Only support 16K
|
|
|
|
|
|
CHECK_EQ(wav_reader.sample_rate(), sample_rate); |
|
|
|
|
|
const int num_samples = wav_reader.num_samples(); |
|
|
|
|
|
std::vector<float> pcm_data(wav_reader.data(), |
|
|
|
|
|
|
|
|
wenet::WavReader wav_reader(FLAGS_wav_path); |
|
|
|
|
|
const int sample_rate = 16000; |
|
|
|
|
|
// Only support 16K
|
|
|
|
|
|
CHECK_EQ(wav_reader.sample_rate(), sample_rate); |
|
|
|
|
|
const int num_samples = wav_reader.num_samples(); |
|
|
|
|
|
std::vector<float> pcm_data(wav_reader.data(), |
|
|
wav_reader.data() + num_samples); |
|
|
wav_reader.data() + num_samples); |
|
|
// Send data every 0.5 second
|
|
|
|
|
|
const float interval = 0.5; |
|
|
|
|
|
const int sample_interval = interval * sample_rate; |
|
|
|
|
|
for (int start = 0; start < num_samples; start += sample_interval) { |
|
|
|
|
|
|
|
|
// Send data every 0.5 second
|
|
|
|
|
|
const float interval = 0.5; |
|
|
|
|
|
const int sample_interval = interval * sample_rate; |
|
|
|
|
|
for (int start = 0; start < num_samples; start += sample_interval) { |
|
|
if (client.done()) { |
|
|
if (client.done()) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -55,10 +55,10 @@ int main(int argc, char* argv[]) { |
|
|
VLOG(2) << "Send " << data.size() << " samples"; |
|
|
VLOG(2) << "Send " << data.size() << " samples"; |
|
|
std::this_thread::sleep_for( |
|
|
std::this_thread::sleep_for( |
|
|
std::chrono::milliseconds(static_cast<int>(interval * 1000))); |
|
|
std::chrono::milliseconds(static_cast<int>(interval * 1000))); |
|
|
} |
|
|
|
|
|
wenet::Timer timer; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
wenet::Timer timer; |
|
|
|
|
|
|
|
|
client.Join(); |
|
|
|
|
|
VLOG(2) << "Total latency: " << timer.Elapsed() << "ms."; |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
client.Join(); |
|
|
|
|
|
VLOG(2) << "Total latency: " << timer.Elapsed() << "ms."; |
|
|
|
|
|
return 0; |
|
|
} |
|
|
} |