feat: add tts param volume and speed (#34)
Co-authored-by: yuhongxiao <hongxiao.yu@aminer.cn> Co-authored-by: Tom <tomsun28@outlook.com>
This commit is contained in:
parent
e7e2af0727
commit
372d99cc4d
2 changed files with 9 additions and 2 deletions
|
|
@ -55,6 +55,8 @@ class Audio(BaseAPI):
|
|||
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
|
||||
|
|
@ -80,6 +82,8 @@ class Audio(BaseAPI):
|
|||
'sensitive_word_check': sensitive_word_check,
|
||||
'request_id': request_id,
|
||||
'user_id': user_id,
|
||||
'speed': speed,
|
||||
'volume': volume,
|
||||
}
|
||||
)
|
||||
return self._post(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue