Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi committed Oct 31, 2024
1 parent 3811a12 commit 4bc76df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/faster_whisper_server/text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import re
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from collections.abc import Iterable

Expand Down
21 changes: 11 additions & 10 deletions tests/speech_test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import io

from openai import APIConnectionError, AsyncOpenAI, UnprocessableEntityError
import pytest
import soundfile as sf

from faster_whisper_server.routers.speech import (
DEFAULT_MODEL,
DEFAULT_RESPONSE_FORMAT,
DEFAULT_VOICE,
SUPPORTED_RESPONSE_FORMATS,
ResponseFormat,
)
from openai import APIConnectionError, AsyncOpenAI, UnprocessableEntityError
import pytest
import soundfile as sf

DEFAULT_INPUT = "Hello, world!"


@pytest.mark.asyncio()
@pytest.mark.asyncio
@pytest.mark.parametrize("response_format", SUPPORTED_RESPONSE_FORMATS)
async def test_create_speech_formats(openai_client: AsyncOpenAI, response_format: ResponseFormat) -> None:
await openai_client.audio.speech.create(
Expand All @@ -34,7 +35,7 @@ async def test_create_speech_formats(openai_client: AsyncOpenAI, response_format
]


@pytest.mark.asyncio()
@pytest.mark.asyncio
@pytest.mark.parametrize(("model", "voice"), GOOD_MODEL_VOICE_PAIRS)
async def test_create_speech_good_model_voice_pair(openai_client: AsyncOpenAI, model: str, voice: str) -> None:
await openai_client.audio.speech.create(
Expand All @@ -54,7 +55,7 @@ async def test_create_speech_good_model_voice_pair(openai_client: AsyncOpenAI, m
]


@pytest.mark.asyncio()
@pytest.mark.asyncio
@pytest.mark.parametrize(("model", "voice"), BAD_MODEL_VOICE_PAIRS)
async def test_create_speech_bad_model_voice_pair(openai_client: AsyncOpenAI, model: str, voice: str) -> None:
# NOTE: not sure why `APIConnectionError` is sometimes raised
Expand All @@ -70,7 +71,7 @@ async def test_create_speech_bad_model_voice_pair(openai_client: AsyncOpenAI, mo
SUPPORTED_SPEEDS = [0.25, 0.5, 1.0, 2.0, 4.0]


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_create_speech_with_varying_speed(openai_client: AsyncOpenAI) -> None:
previous_size: int | None = None
for speed in SUPPORTED_SPEEDS:
Expand All @@ -90,7 +91,7 @@ async def test_create_speech_with_varying_speed(openai_client: AsyncOpenAI) -> N
UNSUPPORTED_SPEEDS = [0.1, 4.1]


@pytest.mark.asyncio()
@pytest.mark.asyncio
@pytest.mark.parametrize("speed", UNSUPPORTED_SPEEDS)
async def test_create_speech_with_unsupported_speed(openai_client: AsyncOpenAI, speed: float) -> None:
with pytest.raises(UnprocessableEntityError):
Expand All @@ -106,7 +107,7 @@ async def test_create_speech_with_unsupported_speed(openai_client: AsyncOpenAI,
VALID_SAMPLE_RATES = [16000, 22050, 24000, 48000]


@pytest.mark.asyncio()
@pytest.mark.asyncio
@pytest.mark.parametrize("sample_rate", VALID_SAMPLE_RATES)
async def test_speech_valid_resample(openai_client: AsyncOpenAI, sample_rate: int) -> None:
res = await openai_client.audio.speech.create(
Expand All @@ -123,7 +124,7 @@ async def test_speech_valid_resample(openai_client: AsyncOpenAI, sample_rate: in
INVALID_SAMPLE_RATES = [7999, 48001]


@pytest.mark.asyncio()
@pytest.mark.asyncio
@pytest.mark.parametrize("sample_rate", INVALID_SAMPLE_RATES)
async def test_speech_invalid_resample(openai_client: AsyncOpenAI, sample_rate: int) -> None:
with pytest.raises(UnprocessableEntityError):
Expand Down

0 comments on commit 4bc76df

Please sign in to comment.