Skip to content

Commit 372d99c

Browse files
iceAndFireisFailedyuhongxiaotomsun28
authored
feat: add tts param volume and speed (#34)
Co-authored-by: yuhongxiao <[email protected]> Co-authored-by: Tom <[email protected]>
1 parent e7e2af0 commit 372d99c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/zai/api_resource/audio/audio.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def speech(
5555
extra_headers: Headers | None = None,
5656
extra_body: Body | None = None,
5757
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
58+
speed: float | None = 1.0,
59+
volume: float | None = 1.0,
5860
) -> HttpxBinaryResponseContent:
5961
"""
6062
Generate speech audio from text input
@@ -80,6 +82,8 @@ def speech(
8082
'sensitive_word_check': sensitive_word_check,
8183
'request_id': request_id,
8284
'user_id': user_id,
85+
'speed': speed,
86+
'volume': volume,
8387
}
8488
)
8589
return self._post(

tests/integration_tests/test_audio.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ def test_audio_speech(logging_conf):
1010
logging.config.dictConfig(logging_conf) # type: ignore
1111
client = ZaiClient() # Fill in your own API Key
1212
try:
13-
speech_file_path = Path(__file__).parent / 'asr1.wav'
13+
speech_file_path = Path(__file__).parent / 'asr1.pcm'
1414
response = client.audio.speech(
1515
model='cogtts',
1616
input='Hello, welcome to Z.ai Open Platform',
1717
voice='female',
18-
response_format='wav',
18+
response_format='pcm',
19+
encode_format='hex',
20+
speed=1.0,
21+
volume=1.0,
1922
)
2023
response.stream_to_file(speech_file_path)
2124

0 commit comments

Comments
 (0)