From 0fd5003820b47d6220b082ae4e77e331b6239675 Mon Sep 17 00:00:00 2001 From: jiltseb Date: Fri, 24 May 2024 09:43:31 +0000 Subject: [PATCH] added compatibility for python 3.8 --- faster_whisper/transcribe.py | 1 + faster_whisper/vad.py | 16 ++++++++-------- requirements.txt | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/faster_whisper/transcribe.py b/faster_whisper/transcribe.py index 1efdd2b7..962f0503 100644 --- a/faster_whisper/transcribe.py +++ b/faster_whisper/transcribe.py @@ -2062,6 +2062,7 @@ def key_func(language): "log_prob_low_threshold": -2.0, "multilingual": False, "output_language": "en", + "hotwords": None, } diff --git a/faster_whisper/vad.py b/faster_whisper/vad.py index e3df1ea1..9092fd1a 100644 --- a/faster_whisper/vad.py +++ b/faster_whisper/vad.py @@ -4,7 +4,7 @@ import warnings from collections.abc import Callable -from typing import List, NamedTuple, Optional +from typing import List, NamedTuple, Optional, Union import numpy as np import pandas as pd @@ -314,9 +314,9 @@ class VoiceActivitySegmentation(VoiceActivityDetection): def __init__( self, segmentation: PipelineModel = "pyannote/segmentation", - device: torch.device | None = None, + device: Optional[Union[str, torch.device]]= None, fscore: bool = False, - use_auth_token: str | None = None, + use_auth_token: Optional[str] = None, **inference_kwargs, ): """Initialize the pipeline with the model name and the optional device. @@ -324,9 +324,9 @@ def __init__( Args: dict parameters of VoiceActivityDetection class from pyannote: segmentation (PipelineModel): Loaded model name. - device (torch.device | None): Device to perform the segmentation. + device (torch.device or None): Device to perform the segmentation. fscore (bool): Flag indicating whether to compute F-score during inference. - use_auth_token (str | None): Optional authentication token for model access. + use_auth_token (str or None): Optional authentication token for model access. inference_kwargs (dict): Additional arguments from VoiceActivityDetection pipeline. """ super().__init__( @@ -337,7 +337,7 @@ def __init__( **inference_kwargs, ) - def apply(self, file: AudioFile, hook: Callable | None = None) -> Annotation: + def apply(self, file: AudioFile, hook: Optional[Callable] = None) -> Annotation: """Apply voice activity detection on the audio file. Args: @@ -379,7 +379,7 @@ class BinarizeVadScores: def __init__( self, onset: float = 0.5, - offset: float | None = None, + offset: Optional[float] = None, min_duration_on: float = 0.0, min_duration_off: float = 0.0, pad_onset: float = 0.0, @@ -442,7 +442,7 @@ def __get_active_regions(self, scores: SlidingWindowFeature) -> Annotation: curr_scores = [k_scores[0]] curr_timestamps = [start] t = start - for t, y in zip(timestamps[1:], k_scores[1:], strict=False): + for t, y in zip(timestamps[1:], k_scores[1:]): #optionally add `strict=False` for python 3.10 or later # currently active if is_active: curr_duration = t - start diff --git a/requirements.txt b/requirements.txt index d02dae83..ec741c89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ tokenizers>=0.13,<1 onnxruntime>=1.14,<2 transformers pyannote-audio>=3.1.1 -pandas>=2.1.4 +pandas torch>=2.1.1 torchaudio>=2.1.2 jsons>=1.6.3 \ No newline at end of file