Skip to content

Commit a96cff6

Browse files
author
yuhongxiao
committed
tts接口支持返回mp3文件编码
1 parent fa496db commit a96cff6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tests/integration_tests/test_audio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def test_audio_speech_streaming(logging_conf):
3838
input='你好呀,欢迎来到智谱开放平台',
3939
voice='tongtong',
4040
stream=True,
41-
response_format='wav',
41+
response_format='mp3',
42+
encode_format='hex'
4243
)
4344
with open("output.pcm", "wb") as f:
4445
for item in response:

zhipuai/api_resource/audio/audio.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def speech(
5151
extra_headers: Headers | None = None,
5252
extra_body: Body | None = None,
5353
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
54+
encode_format: str,
5455
) -> _legacy_response.HttpxBinaryResponseContent | StreamResponse[AudioSpeechChunk]:
5556
body = deepcopy_minimal(
5657
{
@@ -61,7 +62,8 @@ def speech(
6162
"response_format": response_format,
6263
"sensitive_word_check": sensitive_word_check,
6364
"request_id": request_id,
64-
"user_id": user_id
65+
"user_id": user_id,
66+
"encode_format": encode_format
6567
}
6668
)
6769
return self._post(

0 commit comments

Comments
 (0)