(self, features: np.ndarray)
| 93 | return {'text': text, 'avg_logprob': avg_logprobs} |
| 94 | |
| 95 | def encode(self, features: np.ndarray) -> ctranslate2.StorageView: |
| 96 | # When the model is running on multiple GPUs, the encoder output should be moved |
| 97 | # to the CPU since we don't know which GPU will handle the next job. |
| 98 | to_cpu = self.model.device == "cuda" and len(self.model.device_index) > 1 |
| 99 | # unsqueeze if batch size = 1 |
| 100 | if len(features.shape) == 2: |
| 101 | features = np.expand_dims(features, 0) |
| 102 | features = get_ctranslate2_storage(features) |
| 103 | |
| 104 | return self.model.encode(features, to_cpu=to_cpu) |
| 105 | |
| 106 | class FasterWhisperPipeline(Pipeline): |
| 107 | """ |
no outgoing calls
no test coverage detected