Skip to content

Commit a7edd37

Browse files
authored
Merge pull request #148 from dashscope/dev/issue-1
fix: downgrade redundant logger.error(e) to debug in audio modules
2 parents 01278db + b2bc338 commit a7edd37

6 files changed

Lines changed: 20 additions & 24 deletions

File tree

dashscope/audio/asr/recognition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ def call( # type: ignore[override] # noqa: E501
444444
f.close()
445445
self._stop_stream_timestamp = time.time() * 1000
446446
except Exception as e:
447-
logger.error(e)
448-
raise e
447+
logger.debug(e)
448+
raise
449449

450450
if not self._stream_data.empty():
451451
self._running = True

dashscope/audio/asr/transcription.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

4-
import asyncio
54
import time
65
from typing import List, Union
76

8-
import aiohttp
7+
import requests
98

109
from dashscope.api_entities.dashscope_response import (
1110
DashScopeAPIResponse,
@@ -148,8 +147,8 @@ def fetch(
148147
workspace=workspace,
149148
**kwargs,
150149
)
151-
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
152-
logger.error(e)
150+
except (requests.Timeout, requests.ConnectionError) as e:
151+
logger.debug(e)
153152
try_count += 1
154153
if try_count <= Transcription.MAX_QUERY_TRY_COUNT:
155154
time.sleep(2)
@@ -230,8 +229,8 @@ def _launch_request(
230229
workspace=workspace,
231230
**kwargs,
232231
)
233-
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
234-
logger.error(e)
232+
except (requests.Timeout, requests.ConnectionError) as e:
233+
logger.debug(e)
235234
try_count += 1
236235
if try_count <= Transcription.MAX_QUERY_TRY_COUNT:
237236
time.sleep(2)

dashscope/audio/asr/translation_recognizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ def call( # type: ignore[override]
582582
f.close()
583583
self._stop_stream_timestamp = time.time() * 1000
584584
except Exception as e:
585-
logger.error(e)
586-
raise e
585+
logger.debug(e)
586+
raise
587587

588588
if not self._stream_data.empty():
589589
self._running = True

dashscope/audio/asr/vocabulary.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

4-
import asyncio
54
import time
65
from typing import List
76

8-
import aiohttp
7+
import requests
98

109
from dashscope.client.base_api import BaseApi
1110
from dashscope.common.constants import ApiProtocol, HTTPMethod
@@ -68,8 +67,8 @@ def __call_with_input(self, input): # pylint: disable=redefined-builtin
6867
workspace=self._workspace,
6968
**self._kwargs,
7069
)
71-
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
72-
logger.error(e)
70+
except (requests.Timeout, requests.ConnectionError) as e:
71+
logger.debug(e)
7372
try_count += 1
7473
if try_count <= VocabularyService.MAX_QUERY_TRY_COUNT:
7574
time.sleep(2)

dashscope/audio/qwen_asr/qwen_transcription.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

4-
import asyncio
54
import time
65
from typing import Union
76

8-
import aiohttp
7+
import requests
98

109
from dashscope.api_entities.dashscope_response import (
1110
DashScopeAPIResponse,
@@ -108,8 +107,8 @@ def fetch(
108107
workspace=workspace,
109108
**kwargs,
110109
)
111-
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
112-
logger.error(e)
110+
except (requests.Timeout, requests.ConnectionError) as e:
111+
logger.debug(e)
113112
try_count += 1
114113
if try_count <= QwenTranscription.MAX_QUERY_TRY_COUNT:
115114
time.sleep(2)
@@ -186,8 +185,8 @@ def _launch_request(
186185
workspace=workspace,
187186
**kwargs,
188187
)
189-
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
190-
logger.error(e)
188+
except (requests.Timeout, requests.ConnectionError) as e:
189+
logger.debug(e)
191190
try_count += 1
192191
if try_count <= QwenTranscription.MAX_QUERY_TRY_COUNT:
193192
time.sleep(2)

dashscope/audio/tts_v2/enrollment.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

4-
import asyncio
54
import time
65
from typing import List
76

8-
import aiohttp
7+
import requests
98

109
from dashscope.client.base_api import BaseApi
1110
from dashscope.common.constants import ApiProtocol, HTTPMethod
@@ -71,8 +70,8 @@ def __call_with_input( # pylint: disable=redefined-builtin
7170
workspace=self._workspace,
7271
**self._kwargs,
7372
)
74-
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
75-
logger.error(e)
73+
except (requests.Timeout, requests.ConnectionError) as e:
74+
logger.debug(e)
7675
try_count += 1
7776
if try_count <= VoiceEnrollmentService.MAX_QUERY_TRY_COUNT:
7877
time.sleep(2)

0 commit comments

Comments
 (0)