feat: add encode_format to function audio.speech (#36)

Co-authored-by: yuhongxiao <hongxiao.yu@aminer.cn>
This commit is contained in:
iceAndFireisFailed 2025-09-28 12:26:09 +08:00 committed by GitHub
parent 601cbd12d7
commit 0cde756e1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Mapping, Optional, cast
import httpx
from httpx import stream
from zai.core import (
NOT_GIVEN,
@ -55,8 +56,10 @@ class Audio(BaseAPI):
extra_headers: Headers | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
encode_format: str = None,
speed: float | None = 1.0,
volume: float | None = 1.0,
stream: bool | None = False
) -> HttpxBinaryResponseContent:
"""
Generate speech audio from text input
@ -79,11 +82,13 @@ class Audio(BaseAPI):
'input': input,
'voice': voice,
'response_format': response_format,
'encode_format': encode_format,
'sensitive_word_check': sensitive_word_check,
'request_id': request_id,
'user_id': user_id,
'speed': speed,
'volume': volume,
'stream': stream
}
)
return self._post(

View file

@ -16,7 +16,8 @@ def test_audio_speech(logging_conf):
input='Hello, welcome to Z.ai Open Platform',
voice='female',
response_format='pcm',
encode_format='hex',
encode_format='base64',
stream=False,
speed=1.0,
volume=1.0,
)