Skip to content

Commit 1eeb4d3

Browse files
twangodevCopilot
andauthored
feat: QoL and account related APIs
* feat: add reference_id parameter to TTS conversion methods Signed-off-by: James Ding <jamesding365@gmail.com> * feat: add support for references parameter in TTS conversion methods Signed-off-by: James Ding <jamesding365@gmail.com> * feat: add tests for WebSocket streaming with reference_id and references parameters Signed-off-by: James Ding <jamesding365@gmail.com> * feat: change references parameter to Optional in TTS methods Signed-off-by: James Ding <jamesding365@gmail.com> * feat: add support for additional parameters in TTS methods (format, latency, speed) Signed-off-by: James Ding <jamesding365@gmail.com> * feat: preserve volume when overriding speed in Prosody configuration Signed-off-by: James Ding <jamesding365@gmail.com> * feat: add check_free_credit parameter and support for opus audio format Signed-off-by: James Ding <jamesding365@gmail.com> * feat: enforce value constraints on top_p and temperature parameters in TTS models Signed-off-by: James Ding <jamesding365@gmail.com> * Update src/fishaudio/resources/tts.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/fishaudio/resources/tts.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: James Ding <jamesding365@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a0eb36c commit 1eeb4d3

6 files changed

Lines changed: 1032 additions & 29 deletions

File tree

src/fishaudio/resources/account.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Optional
44

5-
from ..core import AsyncClientWrapper, ClientWrapper, RequestOptions
5+
from ..core import OMIT, AsyncClientWrapper, ClientWrapper, RequestOptions
66
from ..types import Credits, Package
77

88

@@ -15,12 +15,14 @@ def __init__(self, client_wrapper: ClientWrapper):
1515
def get_credits(
1616
self,
1717
*,
18+
check_free_credit: Optional[bool] = OMIT,
1819
request_options: Optional[RequestOptions] = None,
1920
) -> Credits:
2021
"""
2122
Get API credit balance.
2223
2324
Args:
25+
check_free_credit: Whether to check free credit availability
2426
request_options: Request-level overrides
2527
2628
Returns:
@@ -31,11 +33,21 @@ def get_credits(
3133
client = FishAudio(api_key="...")
3234
credits = client.account.get_credits()
3335
print(f"Available credits: {float(credits.credit)}")
36+
37+
# Check free credit availability
38+
credits = client.account.get_credits(check_free_credit=True)
39+
if credits.has_free_credit:
40+
print("Free credits available!")
3441
```
3542
"""
43+
params = {}
44+
if check_free_credit is not OMIT:
45+
params["check_free_credit"] = check_free_credit
46+
3647
response = self._client.request(
3748
"GET",
3849
"/wallet/self/api-credit",
50+
params=params,
3951
request_options=request_options,
4052
)
4153
return Credits.model_validate(response.json())
@@ -78,12 +90,14 @@ def __init__(self, client_wrapper: AsyncClientWrapper):
7890
async def get_credits(
7991
self,
8092
*,
93+
check_free_credit: Optional[bool] = OMIT,
8194
request_options: Optional[RequestOptions] = None,
8295
) -> Credits:
8396
"""
8497
Get API credit balance (async).
8598
8699
Args:
100+
check_free_credit: Whether to check free credit availability
87101
request_options: Request-level overrides
88102
89103
Returns:
@@ -94,11 +108,21 @@ async def get_credits(
94108
client = AsyncFishAudio(api_key="...")
95109
credits = await client.account.get_credits()
96110
print(f"Available credits: {float(credits.credit)}")
111+
112+
# Check free credit availability
113+
credits = await client.account.get_credits(check_free_credit=True)
114+
if credits.has_free_credit:
115+
print("Free credits available!")
97116
```
98117
"""
118+
params = {}
119+
if check_free_credit is not OMIT:
120+
params["check_free_credit"] = check_free_credit
121+
99122
response = await self._client.request(
100123
"GET",
101124
"/wallet/self/api-credit",
125+
params=params,
102126
request_options=request_options,
103127
)
104128
return Credits.model_validate(response.json())

0 commit comments

Comments
 (0)