Skip to content

Commit ca91296

Browse files
author
yuhongxiao
committed
优化
1 parent f2aef58 commit ca91296

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/integration_tests/test_audio.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import base64
2+
import json
13
import logging
24
import logging.config
35
from pathlib import Path
@@ -38,8 +40,14 @@ def test_audio_speech_streaming(logging_conf):
3840
stream=True,
3941
response_format='wav',
4042
)
41-
for item in response:
42-
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)}")
4351

4452
except zhipuai.core._errors.APIRequestFailedError as err:
4553
print(err)

0 commit comments

Comments
 (0)