Skip to content

Commit

Permalink
plugin: noise_suppression_interface: chromeos support
Browse files Browse the repository at this point in the history
Update plugins.xml path to /etc/openvino/plugins.xml

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
  • Loading branch information
yongzhi1 committed Jun 25, 2024
1 parent 078d7ca commit c930929
Showing 1 changed file with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>


#define _GLIBCXX_USE_CXX11_ABI 0
#include <stddef.h>
#include <module/module/interface.h>
#include <sof/audio/audio_stream.h>
Expand All @@ -13,6 +13,15 @@
#include "noise_suppression_interface.h"
#define NS_MAX_SOURCE_CHANNELS 2

void printVector(const std::vector<std::string>& vec) {
std::cout << "Print any plugin" << std::endl;
for (const auto& str : vec) {
std::cout << str << " ";
}
std::cout << std::endl;
std::cout << "Print any plugin done" << std::endl;
}

extern "C" {
struct ns_data {
std::shared_ptr<ov::Model> model;
Expand All @@ -25,12 +34,31 @@ extern "C" {
int ov_ns_init(ns_handle *handle) {
struct ns_data *nd;
ov::OutputVector inputs, outputs;
ov::Core core;
ov::Core core("/etc/openvino/plugins.xml");
size_t state_size = 0;
const char* model_name = std::getenv("NOISE_SUPPRESSION_MODEL_NAME");
std::string device("CPU");
int i;

/*
* query the list of available devices and use NPU if available, otherwise use
* CPU by default
*/
std::vector<std::string> available_devices = core.get_available_devices();
printVector(available_devices);

if (available_devices.empty()) {
std::cout << "Not able to find any plugin" << std::endl;
return -EINVAL;
}

for (auto &s: available_devices) {
if (!s.compare("NPU")) {
device.assign("NPU");
break;
}
}

nd = new ns_data();
if(!nd)
return -ENOMEM;
Expand Down Expand Up @@ -67,18 +95,6 @@ extern "C" {
if (!state_size)
return -EINVAL;

/*
* query the list of available devices and use NPU if available, otherwise use
* CPU by default
*/
std::vector<std::string> available_devices = core.get_available_devices();
for (auto &s: available_devices) {
if (!s.compare("NPU")) {
device.assign("NPU");
break;
}
}

/* save the infer_request objects for each channel separately */
ov::CompiledModel compiled_model = core.compile_model(nd->model, device, {});
for (i = 0; i < NS_MAX_SOURCE_CHANNELS; i++)
Expand Down Expand Up @@ -171,7 +187,6 @@ extern "C" {
if (out >= sink->end_addr)
out = (char *)sink->addr +
((char *)out - (char *)sink->end_addr);

v = std::clamp(v, -1.0f, +1.0f);
*(int16_t *)out = (int16_t)(v * std::numeric_limits<int16_t>::max());
}
Expand Down

0 comments on commit c930929

Please sign in to comment.