Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ grpc_extra_deps()

git_repository(
name = "nvriva_common",
remote = "https://github.com/nvidia-riva/common.git",
commit = "71df98266725320a6b6b3a9f32a6da832dc93691"
# Fork of nvidia-riva/common@71df982 (current upstream main) plus the TTS
# word-timestamp proto fields (enable_word_time_offsets / WordTiming).
remote = "https://github.com/ydharavath/common.git",
commit = "560795e"
)

http_archive(
Expand Down
17 changes: 17 additions & 0 deletions riva/clients/tts/riva_tts_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ DEFINE_string(
"Input audio prompt file for Zero Shot Model. Audio length should be between 3-10 seconds.");
DEFINE_int32(zero_shot_quality, 20, "Required quality of output audio, ranges between 1-40.");
DEFINE_string(custom_dictionary, "", " User dictionary containing graph-to-phone custom words");
DEFINE_bool(
word_time_offsets, false,
"If true, request per-word start/end timestamps (returned in response metadata).");
DEFINE_string(zero_shot_transcript, "", "Transcript corresponding to Zero shot audio prompt.");
DEFINE_uint64(timeout_ms, 10000, "Timeout for GRPC channel creation");
DEFINE_uint64(max_grpc_message_size, MAX_GRPC_MESSAGE_SIZE, "Max GRPC message size");
Expand Down Expand Up @@ -239,6 +242,7 @@ main(int argc, char** argv)

request.set_sample_rate_hz(rate);
request.set_voice_name(FLAGS_voice_name);
request.set_enable_word_time_offsets(FLAGS_word_time_offsets);
if (not FLAGS_zero_shot_audio_prompt.empty()) {
auto zero_shot_data = request.mutable_zero_shot_data();
std::vector<std::shared_ptr<WaveData>> audio_prompt;
Expand Down Expand Up @@ -301,6 +305,12 @@ main(int argc, char** argv)

auto audio = response.audio();
LOG(INFO) << "Got " << audio.length() << " bytes back from server" << std::endl;
if (FLAGS_word_time_offsets) {
for (const auto& word : response.meta().words()) {
LOG(INFO) << "word: \"" << word.word() << "\" start: " << word.start_time()
<< " ms end: " << word.end_time() << " ms" << std::endl;
}
}
// Write to WAV file
if (FLAGS_audio_encoding.empty() || FLAGS_audio_encoding == "pcm") {
::riva::utils::wav::Write(
Expand Down Expand Up @@ -353,6 +363,13 @@ main(int argc, char** argv)
std::copy(opus_data, opus_data + len, std::back_inserter(opus_buffer));
audio_len += len;
}
// Word timestamps arrive in the final chunk's metadata.
if (FLAGS_word_time_offsets) {
for (const auto& word : chunk.meta().words()) {
LOG(INFO) << "word: \"" << word.word() << "\" start: " << word.start_time()
<< " ms end: " << word.end_time() << " ms" << std::endl;
}
}
}
grpc::Status rpc_status = reader->Finish();
auto end = std::chrono::steady_clock::now();
Expand Down
5 changes: 5 additions & 0 deletions riva/clients/tts/riva_tts_perf_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ DEFINE_string(
language, "en-US",
"Language code as per [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.");
DEFINE_string(voice_name, "", "Desired voice name");
DEFINE_bool(
word_time_offsets, false,
"If true, request per-word start/end timestamps (returned in response metadata).");
DEFINE_int32(num_iterations, 1, "Number of times to loop over audio files");
DEFINE_int32(num_parallel_requests, 1, "Number of parallel requests to keep in flight");
DEFINE_int32(num_sentences, 1, "Number of sentences to send");
Expand Down Expand Up @@ -153,6 +156,7 @@ synthesizeBatch(
request.set_language_code(language);
request.set_sample_rate_hz(rate);
request.set_voice_name(voice_name);
request.set_enable_word_time_offsets(FLAGS_word_time_offsets);
if (FLAGS_audio_encoding.empty() || FLAGS_audio_encoding == "pcm") {
request.set_encoding(nr::LINEAR_PCM);
} else if (FLAGS_audio_encoding == "opus") {
Expand Down Expand Up @@ -251,6 +255,7 @@ synthesizeOnline(
request.set_language_code(language);
request.set_sample_rate_hz(rate);
request.set_voice_name(voice_name);
request.set_enable_word_time_offsets(FLAGS_word_time_offsets);
auto ae = nr::AudioEncoding::ENCODING_UNSPECIFIED;
if (FLAGS_audio_encoding.empty() || FLAGS_audio_encoding == "pcm") {
ae = nr::LINEAR_PCM;
Expand Down