Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/zai/api_resource/audio/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def speech(
extra_headers: Headers | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
speed: float | None = 1.0,
volume: float | None = 1.0,
) -> HttpxBinaryResponseContent:
"""
Generate speech audio from text input
Expand All @@ -80,6 +82,8 @@ def speech(
'sensitive_word_check': sensitive_word_check,
'request_id': request_id,
'user_id': user_id,
'speed': speed,
'volume': volume,
}
)
return self._post(
Expand Down
7 changes: 5 additions & 2 deletions tests/integration_tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ def test_audio_speech(logging_conf):
logging.config.dictConfig(logging_conf) # type: ignore
client = ZaiClient() # Fill in your own API Key
try:
speech_file_path = Path(__file__).parent / 'asr1.wav'
speech_file_path = Path(__file__).parent / 'asr1.pcm'
response = client.audio.speech(
model='cogtts',
input='Hello, welcome to Z.ai Open Platform',
voice='female',
response_format='wav',
response_format='pcm',
encode_format='hex',
speed=1.0,
volume=1.0,
)
response.stream_to_file(speech_file_path)

Expand Down