Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into mitruska/swiglu_g…
Browse files Browse the repository at this point in the history
…eglu_common
  • Loading branch information
mitruska committed Nov 19, 2024
2 parents b4b0e6a + 5bde1ab commit 7566bc9
Show file tree
Hide file tree
Showing 55 changed files with 1,901 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,21 @@ and use audio files in WAV format at a sampling rate of 16 kHz as input.
def infer(model_dir: str, wav_file_path: str):
raw_speech = read_wav(wav_file_path)
pipe = openvino_genai.WhisperPipeline(model_dir)
def streamer(word: str) -> bool:
print(word, end="")
return False
device = "CPU" # GPU or NPU can be used as well.
pipe = openvino_genai.WhisperPipeline(model_dir, device)
# The pipeline expects normalized audio with a sampling rate of 16kHz.
raw_speech = read_wav(wav_file_path)
result = pipe.generate(
raw_speech,
max_new_tokens=100,
language="<|en|>",
task="transcribe",
return_timestamps=True,
streamer=streamer,
)
print()
print(result)
for chunk in result.chunks:
print(f"timestamps: [{chunk.start_ts}, {chunk.end_ts}] text: {chunk.text}")
Expand All @@ -288,26 +286,21 @@ and use audio files in WAV format at a sampling rate of 16 kHz as input.
std::filesystem::path models_path = argv[1];
std::string wav_file_path = argv[2];
std::string device = "CPU"; // GPU can be used as well
std::string device = "CPU"; // GPU or NPU can be used as well.
ov::genai::WhisperPipeline pipeline(models_path, device);
ov::genai::RawSpeechInput raw_speech = utils::audio::read_wav(wav_file_path);
ov::genai::WhisperGenerationConfig config(models_path / "generation_config.json");
config.max_new_tokens = 100;
config.language = "<|en|>";
config.task = "transcribe";
config.return_timestamps = true;
auto streamer = [](std::string word) {
std::cout << word;
return false;
};
auto result = pipeline.generate(raw_speech, config, streamer);
// The pipeline expects normalized audio with a sampling rate of 16kHz.
ov::genai::RawSpeechInput raw_speech = utils::audio::read_wav(wav_file_path);
auto result = pipeline.generate(raw_speech, config);
std::cout << "\n";
std::cout << result << "\n";
for (auto& chunk : *result.chunks) {
std::cout << "timestamps: [" << chunk.start_ts << ", " << chunk.end_ts << "] text: " << chunk.text << "\n";
Expand Down
30 changes: 16 additions & 14 deletions docs/sphinx_setup/api/nodejs_api/addon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Property addon
Output <./openvino-node/interfaces/Output>
OutputInfo <./openvino-node/interfaces/OutputInfo>
OutputTensorInfo <./openvino-node/interfaces/OutputTensorInfo>
OVAny <./openvino-node/types/OVAny>
PartialShape <./openvino-node/interfaces/PartialShape>
PartialShapeConstructor <./openvino-node/interfaces/PartialShapeConstructor>
PrePostProcessor <./openvino-node/interfaces/PrePostProcessor>
Expand All @@ -39,19 +40,20 @@ The **openvino-node** package exports ``addon`` which contains the following pro

.. code-block:: ts
interface NodeAddon {
export interface NodeAddon {
Core: CoreConstructor;
PartialShape: PartialShapeConstructor;
Tensor: TensorConstructor;
element: typeof element;
PartialShape: PartialShapeConstructor;
preprocess: {
PrePostProcessor: PrePostProcessorConstructor;
resizeAlgorithm: typeof resizeAlgorithm;
resizeAlgorithm: typeof resizeAlgorithm;
PrePostProcessor: PrePostProcessorConstructor;
};
}
element: typeof element;
}
* **Defined in:**
`addon.ts:591 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L192>`__
`addon.ts:669 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L669>`__


Properties
Expand All @@ -71,7 +73,7 @@ Properties
- CoreConstructor: :doc:`CoreConstructor <./openvino-node/interfaces/CoreConstructor>`

- **Defined in:**
`addon.ts:592 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L592>`__
`addon.ts:670 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L670>`__


.. rubric:: PartialShape
Expand All @@ -87,7 +89,7 @@ Properties
- PartialShapeConstructor: :doc:`PartialShapeConstructor <./openvino-node/interfaces/PartialShapeConstructor>`

- **Defined in:**
`addon.ts:594 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L594>`__
`addon.ts:672 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L672>`__

.. rubric:: Tensor

Expand All @@ -102,7 +104,7 @@ Properties
- TensorConstructor: :doc:`TensorConstructor <./openvino-node/interfaces/TensorConstructor>`

- **Defined in:**
`addon.ts:593 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L593>`__
`addon.ts:671 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L671>`__


.. rubric:: element
Expand All @@ -118,7 +120,7 @@ Properties
- element: typeof :doc:`element <./openvino-node/enums/element>`

- **Defined in:**
`addon.ts:600 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L600>`__
`addon.ts:678 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L678>`__


.. rubric:: preprocess
Expand All @@ -128,15 +130,15 @@ Properties
.. code-block:: ts
preprocess: {
PrePostProcessor: PrePostProcessorConstructor;
resizeAlgorithm: typeof resizeAlgorithm;
PrePostProcessor: PrePostProcessorConstructor;
}
* **Type declaration:**

- PrePostProcessor: :doc:`PrePostProcessorConstructor <./openvino-node/interfaces/PrePostProcessorConstructor>`
- resizeAlgorithm: typeof :doc:`resizeAlgorithm <./openvino-node/enums/resizeAlgorithm>`
- PrePostProcessor: :doc:`PrePostProcessorConstructor <./openvino-node/interfaces/PrePostProcessorConstructor>`

- **Defined in:**
`addon.ts:596 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L596>`__
`addon.ts:674 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L674>`__

2 changes: 2 additions & 0 deletions docs/sphinx_setup/api/nodejs_api/nodejs_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ For more details, refer to the
API Development
#####################

Get started with OpenVINO Node.js API development :doc:`here <./addon>`.

OpenVINO 2024.4 has introduced the following methods:

- :ref:`Model.clone() <clone>`
Expand Down
22 changes: 11 additions & 11 deletions docs/sphinx_setup/api/nodejs_api/openvino-node/enums/element.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Enumeration element
f32: number
* **Defined in:**
`addon.ts:640 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L640>`__
`addon.ts:658 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L658>`__


.. rubric:: f64
Expand All @@ -22,7 +22,7 @@ Enumeration element
f64: number
* **Defined in:**
`addon.ts:641 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L641>`__
`addon.ts:659 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L659>`__


.. rubric:: i16
Expand All @@ -34,7 +34,7 @@ Enumeration element
i16: number
* **Defined in:**
`addon.ts:637 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L637>`__
`addon.ts:655 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L655>`__


.. rubric:: i32
Expand All @@ -46,7 +46,7 @@ Enumeration element
i32: number
* **Defined in:**
`addon.ts:638 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L638>`__
`addon.ts:656 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L656>`__


.. rubric:: i64
Expand All @@ -58,7 +58,7 @@ Enumeration element
i64: number
* **Defined in:**
`addon.ts:639 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L639>`__
`addon.ts:657 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L657>`__


.. rubric:: i8
Expand All @@ -70,7 +70,7 @@ Enumeration element
i8: number
* **Defined in:**
`addon.ts:636 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L636>`__
`addon.ts:654 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L654>`__


.. rubric:: string
Expand All @@ -82,7 +82,7 @@ Enumeration element
string: string
* **Defined in:**
`addon.ts:642 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L642>`__
`addon.ts:660 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L660>`__


.. rubric:: u16
Expand All @@ -94,7 +94,7 @@ Enumeration element
u16: number
* **Defined in:**
`addon.ts:634 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L634>`__
`addon.ts:652 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L652>`__


.. rubric:: u32
Expand All @@ -106,7 +106,7 @@ Enumeration element
u32: number
* **Defined in:**
`addon.ts:633 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L633>`__
`addon.ts:651 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L651>`__


.. rubric:: u64
Expand All @@ -118,7 +118,7 @@ Enumeration element
u64: number
* **Defined in:**
`addon.ts:635 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L635>`__
`addon.ts:653 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L653>`__


.. rubric:: u8
Expand All @@ -130,5 +130,5 @@ Enumeration element
u8: number
* **Defined in:**
`addon.ts:632 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L632>`__
`addon.ts:650 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L650>`__

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Enumeration resizeAlgorithm
RESIZE_CUBIC: number
- **Defined in:**
`addon.ts:647 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L647>`__
`addon.ts:663 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L663>`__


.. rubric:: RESIZE_LINEAR
Expand All @@ -22,7 +22,7 @@ Enumeration resizeAlgorithm
RESIZE_LINEAR: number
- **Defined in:**
`addon.ts:648 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L648>`__
`addon.ts:666 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L666>`__


.. rubric:: RESIZE_NEAREST
Expand All @@ -34,5 +34,5 @@ Enumeration resizeAlgorithm
RESIZE_NEAREST: number
- **Defined in:**
`addon.ts:646 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L646>`__
`addon.ts:664 <https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/lib/addon.ts#L664>`__

Loading

0 comments on commit 7566bc9

Please sign in to comment.