Skip to content

Commit 0cde756

Browse files
iceAndFireisFailedyuhongxiao
andauthored
feat: add encode_format to function audio.speech (#36)
Co-authored-by: yuhongxiao <[email protected]>
1 parent 601cbd1 commit 0cde756

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/zai/api_resource/audio/audio.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import TYPE_CHECKING, Mapping, Optional, cast
44

55
import httpx
6+
from httpx import stream
67

78
from zai.core import (
89
NOT_GIVEN,
@@ -55,8 +56,10 @@ def speech(
5556
extra_headers: Headers | None = None,
5657
extra_body: Body | None = None,
5758
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
59+
encode_format: str = None,
5860
speed: float | None = 1.0,
5961
volume: float | None = 1.0,
62+
stream: bool | None = False
6063
) -> HttpxBinaryResponseContent:
6164
"""
6265
Generate speech audio from text input
@@ -79,11 +82,13 @@ def speech(
7982
'input': input,
8083
'voice': voice,
8184
'response_format': response_format,
85+
'encode_format': encode_format,
8286
'sensitive_word_check': sensitive_word_check,
8387
'request_id': request_id,
8488
'user_id': user_id,
8589
'speed': speed,
8690
'volume': volume,
91+
'stream': stream
8792
}
8893
)
8994
return self._post(

tests/integration_tests/test_audio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def test_audio_speech(logging_conf):
1616
input='Hello, welcome to Z.ai Open Platform',
1717
voice='female',
1818
response_format='pcm',
19-
encode_format='hex',
19+
encode_format='base64',
20+
stream=False,
2021
speed=1.0,
2122
volume=1.0,
2223
)

0 commit comments

Comments
 (0)