diff --git a/samples/cpp/speech_sample/main.cpp b/samples/cpp/speech_sample/main.cpp index dc5fad5c4b6..fd484be240e 100644 --- a/samples/cpp/speech_sample/main.cpp +++ b/samples/cpp/speech_sample/main.cpp @@ -506,13 +506,42 @@ int main(int argc, char* argv[]) { inferRequest.frameIndex = -1; continue; } + ptrInputBlobs.clear(); + if (FLAGS_iname.empty()) { + for (auto& input : cInputInfo) { + ptrInputBlobs.push_back(inferRequest.inferRequest.get_tensor(input)); + } + } else { + std::vector inputNameBlobs = convert_str_to_vector(FLAGS_iname); + for (const auto& input : inputNameBlobs) { + ov::Tensor blob = inferRequests.begin()->inferRequest.get_tensor(input); + if (!blob) { + std::string errMessage("No blob with name : " + input); + throw std::logic_error(errMessage); + } + ptrInputBlobs.push_back(blob); + } + } + + /** Iterate over all the input blobs **/ + for (size_t i = 0; i < numInputFiles; ++i) { + ov::Tensor minput = ptrInputBlobs[i]; + if (!minput) { + std::string errMessage("We expect ptrInputBlobs[" + std::to_string(i) + + "] to be inherited from Tensor, " + + "but in fact we were not able to cast input to Tensor"); + throw std::logic_error(errMessage); + } + memcpy(minput.data(), inputFrame[i], minput.get_byte_size()); + // Used to infer fewer frames than the batch size + if (batchSize != numFramesThisBatch) { + memset(minput.data() + numFramesThisBatch * numFrameElementsInput[i], + 0, + (batchSize - numFramesThisBatch) * numFrameElementsInput[i]); + } + } // ----------------------------------------------------------------------------------------------------- int index = static_cast(frameIndex) - (FLAGS_cw_l + FLAGS_cw_r); - for (int i = 0; i < executableNet.inputs().size(); i++) { - inferRequest.inferRequest.set_input_tensor( - i, - ov::Tensor(ov::element::f32, executableNet.inputs()[i].get_shape(), inputFrame[i])); - } /* Starting inference in asynchronous mode*/ inferRequest.inferRequest.start_async(); inferRequest.frameIndex = index < 0 ? -2 : index;