Skip to content

Commit

Permalink
added compatibility for python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiltseb committed May 24, 2024
1 parent 8fd2ec0 commit 0fd5003
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions faster_whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@ def key_func(language):
"log_prob_low_threshold": -2.0,
"multilingual": False,
"output_language": "en",
"hotwords": None,
}


Expand Down
16 changes: 8 additions & 8 deletions faster_whisper/vad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -314,19 +314,19 @@ 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.
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__(
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0fd5003

Please sign in to comment.