From 69ab2b8dabd5517fbf4f24823195673924098d0b Mon Sep 17 00:00:00 2001 From: park sang-hoon Date: Fri, 26 Apr 2024 17:43:32 +0900 Subject: [PATCH 1/4] 8k and 16k support --- runtime/core/bin/websocket_client_main.cc | 6 ++++-- runtime/core/websocket/websocket_client.h | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/core/bin/websocket_client_main.cc b/runtime/core/bin/websocket_client_main.cc index 3eaa96069d..1c02090901 100644 --- a/runtime/core/bin/websocket_client_main.cc +++ b/runtime/core/bin/websocket_client_main.cc @@ -22,18 +22,20 @@ DEFINE_int32(port, 10086, "port of websocket server"); DEFINE_int32(nbest, 1, "n-best of decode result"); DEFINE_string(wav_path, "", "test wav file path"); DEFINE_bool(continuous_decoding, false, "continuous decoding mode"); +DEFINE_int32(sr, 16000, "audio sample rate"); int main(int argc, char* argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, false); google::InitGoogleLogging(argv[0]); wenet::WebSocketClient client(FLAGS_hostname, FLAGS_port); client.set_nbest(FLAGS_nbest); + client.set_sr(FLAGS_sr); client.set_continuous_decoding(FLAGS_continuous_decoding); client.SendStartSignal(); wenet::WavReader wav_reader(FLAGS_wav_path); - const int sample_rate = 16000; - // Only support 16K + int sample_rate = client.sample_rate_; + // 8K and 16K support CHECK_EQ(wav_reader.sample_rate(), sample_rate); const int num_samples = wav_reader.num_samples(); // Send data every 0.5 second diff --git a/runtime/core/websocket/websocket_client.h b/runtime/core/websocket/websocket_client.h index 76ec3aa451..3459ef822c 100644 --- a/runtime/core/websocket/websocket_client.h +++ b/runtime/core/websocket/websocket_client.h @@ -32,13 +32,13 @@ namespace wenet { namespace beast = boost::beast; // from namespace http = beast::http; // from namespace websocket = beast::websocket; // from -namespace asio = boost::asio; // from +namespace asio = boost::asio; // from or using tcp = boost::asio::ip::tcp; // from class WebSocketClient { public: WebSocketClient(const std::string& host, int port); - + int sample_rate_; void SendTextData(const std::string& data); void SendBinaryData(const void* data, size_t size); void ReadLoopFunc(); @@ -47,6 +47,7 @@ class WebSocketClient { void SendStartSignal(); void SendEndSignal(); void set_nbest(int nbest) { nbest_ = nbest; } + void set_sr(int sr) { sample_rate_ = sr; } void set_continuous_decoding(bool continuous_decoding) { continuous_decoding_ = continuous_decoding; } From f7417593445a6b80597e185340bd90be643ce70f Mon Sep 17 00:00:00 2001 From: park sang-hoon Date: Tue, 30 Apr 2024 16:26:28 +0900 Subject: [PATCH 2/4] 8k and 16k support --- runtime/core/websocket/websocket_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/core/websocket/websocket_client.h b/runtime/core/websocket/websocket_client.h index 3459ef822c..6e1b42e595 100644 --- a/runtime/core/websocket/websocket_client.h +++ b/runtime/core/websocket/websocket_client.h @@ -32,7 +32,7 @@ namespace wenet { namespace beast = boost::beast; // from namespace http = beast::http; // from namespace websocket = beast::websocket; // from -namespace asio = boost::asio; // from or +namespace asio = boost::asio; // from using tcp = boost::asio::ip::tcp; // from class WebSocketClient { From ce79563e952eb5343c68a4fd939a3eb57dd7ab56 Mon Sep 17 00:00:00 2001 From: park sang-hoon Date: Tue, 30 Apr 2024 16:36:35 +0900 Subject: [PATCH 3/4] 8k and 16k support --- runtime/core/bin/websocket_client_main.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/core/bin/websocket_client_main.cc b/runtime/core/bin/websocket_client_main.cc index 1c02090901..c240fdc92a 100644 --- a/runtime/core/bin/websocket_client_main.cc +++ b/runtime/core/bin/websocket_client_main.cc @@ -34,8 +34,7 @@ int main(int argc, char* argv[]) { client.SendStartSignal(); wenet::WavReader wav_reader(FLAGS_wav_path); - int sample_rate = client.sample_rate_; - // 8K and 16K support + int sample_rate = client.sample_rate_; CHECK_EQ(wav_reader.sample_rate(), sample_rate); const int num_samples = wav_reader.num_samples(); // Send data every 0.5 second From 3df48eeadbd556964135480d84864e0657e0eb6b Mon Sep 17 00:00:00 2001 From: park sang-hoon Date: Tue, 30 Apr 2024 16:38:57 +0900 Subject: [PATCH 4/4] 8k and 16k support --- runtime/core/bin/websocket_client_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/core/bin/websocket_client_main.cc b/runtime/core/bin/websocket_client_main.cc index c240fdc92a..6a96f37574 100644 --- a/runtime/core/bin/websocket_client_main.cc +++ b/runtime/core/bin/websocket_client_main.cc @@ -34,7 +34,7 @@ int main(int argc, char* argv[]) { client.SendStartSignal(); wenet::WavReader wav_reader(FLAGS_wav_path); - int sample_rate = client.sample_rate_; + int sample_rate = client.sample_rate_; CHECK_EQ(wav_reader.sample_rate(), sample_rate); const int num_samples = wav_reader.num_samples(); // Send data every 0.5 second