Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vad prob states #102

Merged
merged 20 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ grpc_extra_deps()
git_repository(
name = "nvriva_common",
remote = "https://github.com/nvidia-riva/common.git",
commit = "1c7da5aed4e4df3a296d2672379c5099a193aaae"
commit = "9b31412dc43a15740f5f55a97cbd8c3eb5b43d86"
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
)

http_archive(
Expand Down
80 changes: 49 additions & 31 deletions riva/clients/asr/client_call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,63 @@ ClientCall::ClientCall(uint32_t corr_id, bool word_time_offsets)
recv_final_flags.reserve(1000);
}

ClientCall::~ClientCall(){
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
if (pipeline_states_logs_)
pipeline_states_logs_.close();
}

void
ClientCall::AppendResult(const nr_asr::StreamingRecognitionResult& result)
{
bool is_final = result.is_final();
if (latest_result_.final_transcripts.size() < 1) {
latest_result_.final_transcripts.resize(1);
latest_result_.final_transcripts[0] = "";
}

if (is_final) {
int num_alternatives = result.alternatives_size();
latest_result_.final_transcripts.resize(num_alternatives);
latest_result_.final_scores.resize(num_alternatives);
latest_result_.final_time_stamps.resize(num_alternatives);
for (int a = 0; a < num_alternatives; ++a) {
// Append to transcript
latest_result_.final_transcripts[a] += result.alternatives(a).transcript();
latest_result_.final_scores[a] += result.alternatives(a).confidence();
if (result.has_pipeline_states()) {
auto pipeline_states = result.pipeline_states();
int prob_states_count = pipeline_states.vad_probabilities_size();
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
std::string vad_log = "";
for (int i = 0; i < prob_states_count; i++) {
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
vad_log += std::to_string(pipeline_states.vad_probabilities(i)) + " ";
}
if(!pipeline_states_logs_){
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
pipeline_states_logs_.open("riva_asr_pipeline_states.log");
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
}
pipeline_states_logs_ << "VAD states: " << vad_log << std::endl;
} else {
bool is_final = result.is_final();
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
if (latest_result_.final_transcripts.size() < 1) {
latest_result_.final_transcripts.resize(1);
latest_result_.final_transcripts[0] = "";
}
VLOG(1) << "Final transcript: " << result.alternatives(0).transcript();

if (word_time_offsets_) {
if (num_alternatives > 0) {
for (int a = 0; a < num_alternatives; ++a) {
for (int w = 0; w < result.alternatives(a).words_size(); ++w) {
latest_result_.final_time_stamps[a].push_back(result.alternatives(a).words(w));
if (is_final) {
int num_alternatives = result.alternatives_size();
latest_result_.final_transcripts.resize(num_alternatives);
latest_result_.final_scores.resize(num_alternatives);
latest_result_.final_time_stamps.resize(num_alternatives);
for (int a = 0; a < num_alternatives; ++a) {
// Append to transcript
latest_result_.final_transcripts[a] += result.alternatives(a).transcript();
latest_result_.final_scores[a] += result.alternatives(a).confidence();
}
VLOG(1) << "Final transcript: " << result.alternatives(0).transcript();

if (word_time_offsets_) {
if (num_alternatives > 0) {
for (int a = 0; a < num_alternatives; ++a) {
for (int w = 0; w < result.alternatives(a).words_size(); ++w) {
latest_result_.final_time_stamps[a].push_back(result.alternatives(a).words(w));
}
}
}
}
}
} else {
if (result.alternatives_size() > 0) {
if (result.stability() == 1) {
VLOG(1) << "Intermediate transcript: " << result.alternatives(0).transcript();
} else {
latest_result_.partial_transcript += result.alternatives(0).transcript();
if (word_time_offsets_) {
for (int w = 0; w < result.alternatives(0).words_size(); ++w) {
latest_result_.partial_time_stamps.emplace_back(result.alternatives(0).words(w));
} else {
if (result.alternatives_size() > 0) {
if (result.stability() == 1) {
VLOG(1) << "Intermediate transcript: " << result.alternatives(0).transcript();
} else {
latest_result_.partial_transcript += result.alternatives(0).transcript();
if (word_time_offsets_) {
for (int w = 0; w < result.alternatives(0).words_size(); ++w) {
latest_result_.partial_time_stamps.emplace_back(result.alternatives(0).words(w));
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions riva/clients/asr/client_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace nr_asr = nvidia::riva::asr;
class ClientCall {
public:
ClientCall(uint32_t _corr_id, bool word_time_offsets);
~ClientCall();

void AppendResult(const nr_asr::StreamingRecognitionResult& result);

Expand Down Expand Up @@ -66,5 +67,6 @@ class ClientCall {
std::vector<bool> recv_final_flags;

grpc::Status finish_status;
std::ofstream pipeline_states_logs_;

}; // ClientCall
1 change: 1 addition & 0 deletions riva/clients/nmt/riva_nmt_t2t_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ main(int argc, char** argv)
if (FLAGS_text != "") {
nr_nmt::TranslateTextRequest request;
nr_nmt::TranslateTextResponse response;
VLOG(1) << "Setting up t2t config.";
atomer-nvidia marked this conversation as resolved.
Show resolved Hide resolved
request.set_model(FLAGS_model_name);
request.set_source_language(FLAGS_source_language_code);
request.set_target_language(FLAGS_target_language_code);
Expand Down