We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2aef58 commit ca91296Copy full SHA for ca91296
tests/integration_tests/test_audio.py
@@ -1,3 +1,5 @@
1
+import base64
2
+import json
3
import logging
4
import logging.config
5
from pathlib import Path
@@ -38,8 +40,14 @@ def test_audio_speech_streaming(logging_conf):
38
40
stream=True,
39
41
response_format='wav',
42
)
- for item in response:
- print(item)
43
+ with open("output.pcm", "wb") as f:
44
+ for item in response:
45
+ info_dict = json.loads(item)
46
+ index = info_dict.get('sequence')
47
+ is_finished = info_dict.get('is_finished')
48
+ audio_delta = info_dict.get('audio')
49
+ f.write(base64.b64decode(audio_delta))
50
+ print(f"{index}.is_finished = {is_finished}, audio_delta = {len(audio_delta)}")
51
52
except zhipuai.core._errors.APIRequestFailedError as err:
53
print(err)
0 commit comments