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