|
1 | | -from zhipuai import ZhipuAI |
2 | | -import zhipuai |
3 | | - |
4 | | -import logging |
5 | | -import logging.config |
6 | | - |
7 | | - |
8 | | -def test_transcriptions(logging_conf): |
9 | | - logging.config.dictConfig(logging_conf) # type: ignore |
10 | | - client = ZhipuAI() # 填写您自己的APIKey |
11 | | - try: |
12 | | - with open("asr1.wav", "rb") as audio_file: |
13 | | - transcriptResponse = client.audio.transcriptions.create( |
14 | | - model="glm-asr", |
15 | | - file=audio_file, |
16 | | - stream=False |
17 | | - ) |
18 | | - print(transcriptResponse) |
19 | | - except zhipuai.core._errors.APIRequestFailedError as err: |
20 | | - print(err) |
21 | | - except zhipuai.core._errors.APIInternalError as err: |
22 | | - print(err) |
23 | | - except zhipuai.core._errors.APIStatusError as err: |
24 | | - print(err) |
25 | | - |
26 | | - |
27 | | -def test_transcriptions_stream(logging_conf): |
28 | | - logging.config.dictConfig(logging_conf) # type: ignore |
29 | | - client = ZhipuAI() # 填写您自己的APIKey |
30 | | - try: |
31 | | - with open("asr1.wav", "rb") as audio_file: |
32 | | - transcriptResponse = client.audio.transcriptions.create( |
33 | | - model="glm-asr", |
34 | | - file=audio_file, |
35 | | - stream=True |
36 | | - ) |
37 | | - for item in transcriptResponse: |
38 | | - print(item) |
39 | | - except zhipuai.core._errors.APIRequestFailedError as err: |
40 | | - print(err) |
41 | | - except zhipuai.core._errors.APIInternalError as err: |
42 | | - print(err) |
43 | | - except zhipuai.core._errors.APIStatusError as err: |
44 | | - print(err) |
45 | | - |
| 1 | +# from zhipuai import ZhipuAI |
| 2 | +# import zhipuai |
| 3 | +# |
| 4 | +# import logging |
| 5 | +# import logging.config |
| 6 | +# |
| 7 | +# |
| 8 | +# def test_transcriptions(logging_conf): |
| 9 | +# logging.config.dictConfig(logging_conf) # type: ignore |
| 10 | +# client = ZhipuAI() # 填写您自己的APIKey |
| 11 | +# try: |
| 12 | +# with open("asr1.wav", "rb") as audio_file: |
| 13 | +# transcriptResponse = client.audio.transcriptions.create( |
| 14 | +# model="glm-asr", |
| 15 | +# file=audio_file, |
| 16 | +# stream=False |
| 17 | +# ) |
| 18 | +# print(transcriptResponse) |
| 19 | +# except zhipuai.core._errors.APIRequestFailedError as err: |
| 20 | +# print(err) |
| 21 | +# except zhipuai.core._errors.APIInternalError as err: |
| 22 | +# print(err) |
| 23 | +# except zhipuai.core._errors.APIStatusError as err: |
| 24 | +# print(err) |
| 25 | +# |
| 26 | +# |
| 27 | +# def test_transcriptions_stream(logging_conf): |
| 28 | +# logging.config.dictConfig(logging_conf) # type: ignore |
| 29 | +# client = ZhipuAI() # 填写您自己的APIKey |
| 30 | +# try: |
| 31 | +# with open("asr1.wav", "rb") as audio_file: |
| 32 | +# transcriptResponse = client.audio.transcriptions.create( |
| 33 | +# model="glm-asr", |
| 34 | +# file=audio_file, |
| 35 | +# stream=True |
| 36 | +# ) |
| 37 | +# for item in transcriptResponse: |
| 38 | +# print(item) |
| 39 | +# except zhipuai.core._errors.APIRequestFailedError as err: |
| 40 | +# print(err) |
| 41 | +# except zhipuai.core._errors.APIInternalError as err: |
| 42 | +# print(err) |
| 43 | +# except zhipuai.core._errors.APIStatusError as err: |
| 44 | +# print(err) |
| 45 | +# |
0 commit comments