Skip to content

Commit dbbaae4

Browse files
committed
fix: update import statements and formatting across multiple files
1 parent b05410c commit dbbaae4

38 files changed

Lines changed: 177 additions & 146 deletions

examples/getting-started/01_simple_tts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
import os
22+
2223
from fishaudio import FishAudio
2324
from fishaudio.utils import save
2425

examples/getting_started.ipynb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,18 @@
3939
}
4040
},
4141
"outputs": [],
42-
"source": "from dotenv import load_dotenv\nfrom fishaudio import FishAudio\nfrom fishaudio.utils import play\n# from fishaudio.utils import save # Uncomment if saving audio to file\n\nload_dotenv()\n\nclient = FishAudio()"
42+
"source": [
43+
"from dotenv import load_dotenv\n",
44+
"\n",
45+
"from fishaudio import FishAudio\n",
46+
"from fishaudio.utils import play\n",
47+
"\n",
48+
"# from fishaudio.utils import save # Uncomment if saving audio to file\n",
49+
"\n",
50+
"load_dotenv()\n",
51+
"\n",
52+
"client = FishAudio()"
53+
]
4354
},
4455
{
4556
"cell_type": "markdown",

scripts/copy_docs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
python scripts/copy_docs.py sdk docs # In CI context
1111
"""
1212

13+
from __future__ import annotations
14+
1315
import argparse
1416
import shutil
1517
from pathlib import Path

src/fish_audio_sdk/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from .apis import Session
22
from .exceptions import HttpCodeErr, WebSocketErr
33
from .schemas import (
4+
APICreditEntity,
45
ASRRequest,
5-
TTSRequest,
6-
ReferenceAudio,
7-
Prosody,
8-
PaginatedResponse,
6+
CloseEvent,
97
ModelEntity,
10-
APICreditEntity,
8+
PaginatedResponse,
9+
Prosody,
10+
ReferenceAudio,
1111
StartEvent,
1212
TextEvent,
13-
CloseEvent,
13+
TTSRequest,
1414
)
15-
from .websocket import WebSocketSession, AsyncWebSocketSession
15+
from .websocket import AsyncWebSocketSession, WebSocketSession
1616

1717
__all__ = [
1818
"Session",

src/fish_audio_sdk/apis.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import Generator, Literal
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING, Literal
24

35
import ormsgpack
46

@@ -7,13 +9,16 @@
79
APICreditEntity,
810
ASRRequest,
911
ASRResponse,
10-
ModelEntity,
1112
Backends,
13+
ModelEntity,
1214
PackageEntity,
1315
PaginatedResponse,
1416
TTSRequest,
1517
)
1618

19+
if TYPE_CHECKING:
20+
from collections.abc import Generator
21+
1722

1823
class Session(RemoteCall):
1924
@convert_stream

src/fish_audio_sdk/io.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1+
from __future__ import annotations
2+
13
import dataclasses
24
import typing
5+
from collections.abc import AsyncGenerator, Awaitable, Generator
36
from http.client import responses as http_responses
47
from typing import (
58
Any,
6-
AsyncGenerator,
7-
Awaitable,
89
Callable,
9-
Generator,
1010
Generic,
1111
TypeVar,
1212
)
1313

14-
from typing_extensions import Concatenate, ParamSpec
15-
1614
import httpx
1715
import httpx._client
1816
import httpx._types
17+
from typing_extensions import Concatenate, ParamSpec
1918

2019
from .exceptions import HttpCodeErr
2120

@@ -194,8 +193,7 @@ def sync_wrapper(self: RemoteCall, *args: P.args, **kwargs: P.kwargs) -> R:
194193
return exc.value
195194
raise RuntimeError("Generator did not stop")
196195

197-
call = IOCallDescriptor(async_wrapper, sync_wrapper)
198-
return call
196+
return IOCallDescriptor(async_wrapper, sync_wrapper)
199197

200198

201199
GStream = G[Generator[bytes, bytes, None]]
@@ -257,5 +255,4 @@ def sync_wrapper(
257255

258256
raise RuntimeError("Generator did not stop")
259257

260-
call = StreamIOCallDescriptor(async_wrapper, sync_wrapper)
261-
return call
258+
return StreamIOCallDescriptor(async_wrapper, sync_wrapper)

src/fish_audio_sdk/schemas.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import datetime
2-
import decimal
3-
from typing import Annotated, Generic, Literal, TypeVar
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING, Annotated, Generic, Literal, TypeVar
44

55
from pydantic import BaseModel, Field
66

7+
if TYPE_CHECKING:
8+
import datetime
9+
import decimal
710

811
Backends = Literal["speech-1.5", "speech-1.6", "agent-x0", "s1", "s1-mini"]
912

src/fish_audio_sdk/websocket.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import asyncio
2+
from collections.abc import AsyncGenerator, AsyncIterable, Generator, Iterable
23
from concurrent.futures import ThreadPoolExecutor
3-
from typing import AsyncGenerator, AsyncIterable, Generator, Iterable
44

55
import httpx
66
import ormsgpack
7-
from httpx_ws import WebSocketDisconnect, connect_ws, aconnect_ws
7+
from httpx_ws import WebSocketDisconnect, aconnect_ws, connect_ws
88

99
from .exceptions import WebSocketErr
10-
11-
from .schemas import Backends, CloseEvent, StartEvent, TTSRequest, TextEvent
10+
from .schemas import Backends, CloseEvent, StartEvent, TextEvent, TTSRequest
1211

1312

1413
class WebSocketSession:

src/fishaudio/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from .core import AsyncClientWrapper, ClientWrapper
88
from .resources import (
9-
ASRClient,
109
AccountClient,
10+
ASRClient,
1111
AsyncAccountClient,
1212
AsyncASRClient,
1313
AsyncTTSClient,

src/fishaudio/core/client_wrapper.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
import os
44
from json import JSONDecodeError
5-
from typing import Any, Dict, Optional
5+
from typing import Any, Optional
66

77
import httpx
88

9-
from .._version import __version__
10-
from ..exceptions import (
9+
from fishaudio._version import __version__
10+
from fishaudio.exceptions import (
1111
APIError,
1212
AuthenticationError,
1313
NotFoundError,
1414
PermissionError,
1515
RateLimitError,
1616
ServerError,
1717
)
18+
1819
from .request_options import RequestOptions
1920

2021

@@ -32,16 +33,15 @@ def _raise_for_status(response: httpx.Response) -> None:
3233
# Raise specific exception based on status code
3334
if status == 401:
3435
raise AuthenticationError(status, message, response.text)
35-
elif status == 403:
36+
if status == 403:
3637
raise PermissionError(status, message, response.text)
37-
elif status == 404:
38+
if status == 404:
3839
raise NotFoundError(status, message, response.text)
39-
elif status == 429:
40+
if status == 429:
4041
raise RateLimitError(status, message, response.text)
41-
elif status >= 500:
42+
if status >= 500:
4243
raise ServerError(status, message, response.text)
43-
else:
44-
raise APIError(status, message, response.text)
44+
raise APIError(status, message, response.text)
4545

4646

4747
class BaseClientWrapper:
@@ -61,8 +61,8 @@ def __init__(
6161
self.base_url = base_url
6262

6363
def get_headers(
64-
self, additional_headers: Optional[Dict[str, str]] = None
65-
) -> Dict[str, str]:
64+
self, additional_headers: Optional[dict[str, str]] = None
65+
) -> dict[str, str]:
6666
"""Build headers including authentication and user agent."""
6767
headers = {
6868
"Authorization": f"Bearer {self.api_key}",
@@ -73,7 +73,7 @@ def get_headers(
7373
return headers
7474

7575
def _prepare_request_kwargs(
76-
self, request_options: Optional[RequestOptions], kwargs: Dict[str, Any]
76+
self, request_options: Optional[RequestOptions], kwargs: dict[str, Any]
7777
) -> None:
7878
"""Prepare request kwargs by merging headers, timeout, and query params."""
7979
# Merge headers

0 commit comments

Comments
 (0)