Update README.md
Browse files
README.md
CHANGED
@@ -39,6 +39,7 @@ pip install optimum[openvino]
|
|
39 |
2. Run model inference:
|
40 |
|
41 |
```
|
|
|
42 |
from transformers import AutoProcessor
|
43 |
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
44 |
|
@@ -49,14 +50,14 @@ model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)
|
|
49 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
50 |
sample = dataset[0]
|
51 |
|
52 |
-
input_features =
|
53 |
sample["audio"]["array"],
|
54 |
sampling_rate=sample["audio"]["sampling_rate"],
|
55 |
return_tensors="pt",
|
56 |
).input_features
|
57 |
|
58 |
outputs = model.generate(input_features)
|
59 |
-
text =
|
60 |
print(text)
|
61 |
```
|
62 |
|
@@ -90,7 +91,7 @@ device = "CPU"
|
|
90 |
pipe = ov_genai.WhisperPipeline(model_path, device)
|
91 |
|
92 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
93 |
-
sample = dataset[0]["audio]["array"]
|
94 |
print(pipe.generate(sample))
|
95 |
```
|
96 |
|
|
|
39 |
2. Run model inference:
|
40 |
|
41 |
```
|
42 |
+
from datasets import load_dataset
|
43 |
from transformers import AutoProcessor
|
44 |
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
45 |
|
|
|
50 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
51 |
sample = dataset[0]
|
52 |
|
53 |
+
input_features = tokenizer(
|
54 |
sample["audio"]["array"],
|
55 |
sampling_rate=sample["audio"]["sampling_rate"],
|
56 |
return_tensors="pt",
|
57 |
).input_features
|
58 |
|
59 |
outputs = model.generate(input_features)
|
60 |
+
text = tokenizer.batch_decode(outputs)[0]
|
61 |
print(text)
|
62 |
```
|
63 |
|
|
|
91 |
pipe = ov_genai.WhisperPipeline(model_path, device)
|
92 |
|
93 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
94 |
+
sample = dataset[0]["audio"]["array"]
|
95 |
print(pipe.generate(sample))
|
96 |
```
|
97 |
|