Update README.md
Browse files
README.md
CHANGED
|
@@ -47,6 +47,7 @@ pip install optimum[openvino]
|
|
| 47 |
2. Run model inference:
|
| 48 |
|
| 49 |
```
|
|
|
|
| 50 |
from transformers import AutoProcessor
|
| 51 |
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
| 52 |
|
|
@@ -57,14 +58,14 @@ model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)
|
|
| 57 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
| 58 |
sample = dataset[0]
|
| 59 |
|
| 60 |
-
input_features =
|
| 61 |
sample["audio"]["array"],
|
| 62 |
sampling_rate=sample["audio"]["sampling_rate"],
|
| 63 |
return_tensors="pt",
|
| 64 |
).input_features
|
| 65 |
|
| 66 |
outputs = model.generate(input_features)
|
| 67 |
-
text =
|
| 68 |
print(text)
|
| 69 |
```
|
| 70 |
|
|
@@ -98,7 +99,7 @@ device = "CPU"
|
|
| 98 |
pipe = ov_genai.WhisperPipeline(model_path, device)
|
| 99 |
|
| 100 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
| 101 |
-
sample = dataset[0]["audio]["array"]
|
| 102 |
print(pipe.generate(sample))
|
| 103 |
```
|
| 104 |
|
|
|
|
| 47 |
2. Run model inference:
|
| 48 |
|
| 49 |
```
|
| 50 |
+
from datasets import load_dataset
|
| 51 |
from transformers import AutoProcessor
|
| 52 |
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
| 53 |
|
|
|
|
| 58 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
| 59 |
sample = dataset[0]
|
| 60 |
|
| 61 |
+
input_features = tokenizer(
|
| 62 |
sample["audio"]["array"],
|
| 63 |
sampling_rate=sample["audio"]["sampling_rate"],
|
| 64 |
return_tensors="pt",
|
| 65 |
).input_features
|
| 66 |
|
| 67 |
outputs = model.generate(input_features)
|
| 68 |
+
text = tokenizer.batch_decode(outputs)[0]
|
| 69 |
print(text)
|
| 70 |
```
|
| 71 |
|
|
|
|
| 99 |
pipe = ov_genai.WhisperPipeline(model_path, device)
|
| 100 |
|
| 101 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
| 102 |
+
sample = dataset[0]["audio"]["array"]
|
| 103 |
print(pipe.generate(sample))
|
| 104 |
```
|
| 105 |
|