Upload folder using huggingface_hub
Browse files- asr_diarization/pipeline.py +16 -8
asr_diarization/pipeline.py
CHANGED
|
@@ -21,16 +21,24 @@ class ASR_Diarization:
|
|
| 21 |
# Load diarization model
|
| 22 |
self.diar_pipeline = Pipeline.from_pretrained(diar_model, use_auth_token=HF_TOKEN)
|
| 23 |
|
| 24 |
-
processor = WhisperProcessor.from_pretrained(asr_model, token=HF_TOKEN)
|
| 25 |
-
model = WhisperForConditionalGeneration.from_pretrained(asr_model, token=HF_TOKEN).to(self.device)
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
self.asr_pipeline = hf_pipeline(
|
| 28 |
"automatic-speech-recognition",
|
| 29 |
-
model=
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
device=0 if self.device == "cuda" else -1,
|
| 33 |
-
return_timestamps=True
|
| 34 |
)
|
| 35 |
|
| 36 |
def run_diarization(self, audio_path):
|
|
|
|
| 21 |
# Load diarization model
|
| 22 |
self.diar_pipeline = Pipeline.from_pretrained(diar_model, use_auth_token=HF_TOKEN)
|
| 23 |
|
| 24 |
+
# processor = WhisperProcessor.from_pretrained(asr_model, token=HF_TOKEN)
|
| 25 |
+
# model = WhisperForConditionalGeneration.from_pretrained(asr_model, token=HF_TOKEN).to(self.device)
|
| 26 |
+
|
| 27 |
+
# self.asr_pipeline = hf_pipeline(
|
| 28 |
+
# "automatic-speech-recognition",
|
| 29 |
+
# model=model,
|
| 30 |
+
# tokenizer=processor.tokenizer,
|
| 31 |
+
# feature_extractor=processor.feature_extractor,
|
| 32 |
+
# device=0 if self.device == "cuda" else -1,
|
| 33 |
+
# return_timestamps=True
|
| 34 |
+
# )
|
| 35 |
+
|
| 36 |
+
model_id = "Capstone04/TrainedWhisper"
|
| 37 |
self.asr_pipeline = hf_pipeline(
|
| 38 |
"automatic-speech-recognition",
|
| 39 |
+
model=model_id,
|
| 40 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 41 |
+
device=0 if torch.cuda.is_available() else -1,
|
|
|
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
def run_diarization(self, audio_path):
|