apply formatting with black (#1038)
* applying black (with the default 88-column limit) * add flake8 * add isort * fix isort
This commit is contained in:
@@ -2,7 +2,7 @@ import os.path
|
||||
|
||||
import numpy as np
|
||||
|
||||
from whisper.audio import load_audio, log_mel_spectrogram, SAMPLE_RATE
|
||||
from whisper.audio import SAMPLE_RATE, load_audio, log_mel_spectrogram
|
||||
|
||||
|
||||
def test_audio():
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from whisper.normalizers import EnglishTextNormalizer
|
||||
from whisper.normalizers.english import EnglishNumberNormalizer, EnglishSpellingNormalizer
|
||||
from whisper.normalizers.english import (
|
||||
EnglishNumberNormalizer,
|
||||
EnglishSpellingNormalizer,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("std", [EnglishNumberNormalizer(), EnglishTextNormalizer()])
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
import scipy.ndimage
|
||||
import torch
|
||||
|
||||
from whisper.timing import dtw_cpu, dtw_cuda, median_filter
|
||||
|
||||
|
||||
sizes = [
|
||||
(10, 20), (32, 16), (123, 1500), (234, 189),
|
||||
(10, 20),
|
||||
(32, 16),
|
||||
(123, 1500),
|
||||
(234, 189),
|
||||
]
|
||||
shapes = [
|
||||
(10,), (1, 15), (4, 5, 345), (6, 12, 240, 512),
|
||||
(10,),
|
||||
(1, 15),
|
||||
(4, 5, 345),
|
||||
(6, 12, 240, 512),
|
||||
]
|
||||
|
||||
|
||||
@@ -68,8 +73,12 @@ def test_median_filter(shape):
|
||||
|
||||
# using np.pad to reflect-pad, because Scipy's behavior is different near the edges.
|
||||
pad_width = filter_width // 2
|
||||
padded_x = np.pad(x, [(0, 0)] * (x.ndim - 1) + [(pad_width, pad_width)], mode="reflect")
|
||||
scipy_filtered = scipy.ndimage.median_filter(padded_x, [1] * (x.ndim - 1) + [filter_width])
|
||||
padded_x = np.pad(
|
||||
x, [(0, 0)] * (x.ndim - 1) + [(pad_width, pad_width)], mode="reflect"
|
||||
)
|
||||
scipy_filtered = scipy.ndimage.median_filter(
|
||||
padded_x, [1] * (x.ndim - 1) + [filter_width]
|
||||
)
|
||||
scipy_filtered = scipy_filtered[..., pad_width:-pad_width]
|
||||
|
||||
assert np.allclose(filtered, scipy_filtered)
|
||||
|
||||
@@ -13,7 +13,9 @@ def test_transcribe(model_name: str):
|
||||
audio_path = os.path.join(os.path.dirname(__file__), "jfk.flac")
|
||||
|
||||
language = "en" if model_name.endswith(".en") else None
|
||||
result = model.transcribe(audio_path, language=language, temperature=0.0, word_timestamps=True)
|
||||
result = model.transcribe(
|
||||
audio_path, language=language, temperature=0.0, word_timestamps=True
|
||||
)
|
||||
assert result["language"] == "en"
|
||||
|
||||
transcription = result["text"].lower()
|
||||
|
||||
Reference in New Issue
Block a user