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