diff --git a/dashscope/audio/asr/recognition.py b/dashscope/audio/asr/recognition.py index 8b988f6..7dc7bc4 100644 --- a/dashscope/audio/asr/recognition.py +++ b/dashscope/audio/asr/recognition.py @@ -444,8 +444,8 @@ def call( # type: ignore[override] # noqa: E501 f.close() self._stop_stream_timestamp = time.time() * 1000 except Exception as e: - logger.error(e) - raise e + logger.debug(e) + raise if not self._stream_data.empty(): self._running = True diff --git a/dashscope/audio/asr/transcription.py b/dashscope/audio/asr/transcription.py index cf8ce4d..88631ac 100644 --- a/dashscope/audio/asr/transcription.py +++ b/dashscope/audio/asr/transcription.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- # Copyright (c) Alibaba, Inc. and its affiliates. -import asyncio import time from typing import List, Union -import aiohttp +import requests from dashscope.api_entities.dashscope_response import ( DashScopeAPIResponse, @@ -148,8 +147,8 @@ def fetch( workspace=workspace, **kwargs, ) - except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e: - logger.error(e) + except (requests.Timeout, requests.ConnectionError) as e: + logger.debug(e) try_count += 1 if try_count <= Transcription.MAX_QUERY_TRY_COUNT: time.sleep(2) @@ -230,8 +229,8 @@ def _launch_request( workspace=workspace, **kwargs, ) - except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e: - logger.error(e) + except (requests.Timeout, requests.ConnectionError) as e: + logger.debug(e) try_count += 1 if try_count <= Transcription.MAX_QUERY_TRY_COUNT: time.sleep(2) diff --git a/dashscope/audio/asr/translation_recognizer.py b/dashscope/audio/asr/translation_recognizer.py index f677dd2..2f3405c 100644 --- a/dashscope/audio/asr/translation_recognizer.py +++ b/dashscope/audio/asr/translation_recognizer.py @@ -582,8 +582,8 @@ def call( # type: ignore[override] f.close() self._stop_stream_timestamp = time.time() * 1000 except Exception as e: - logger.error(e) - raise e + logger.debug(e) + raise if not self._stream_data.empty(): self._running = True diff --git a/dashscope/audio/asr/vocabulary.py b/dashscope/audio/asr/vocabulary.py index 8fd2ce8..9e8510b 100644 --- a/dashscope/audio/asr/vocabulary.py +++ b/dashscope/audio/asr/vocabulary.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- # Copyright (c) Alibaba, Inc. and its affiliates. -import asyncio import time from typing import List -import aiohttp +import requests from dashscope.client.base_api import BaseApi from dashscope.common.constants import ApiProtocol, HTTPMethod @@ -68,8 +67,8 @@ def __call_with_input(self, input): # pylint: disable=redefined-builtin workspace=self._workspace, **self._kwargs, ) - except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e: - logger.error(e) + except (requests.Timeout, requests.ConnectionError) as e: + logger.debug(e) try_count += 1 if try_count <= VocabularyService.MAX_QUERY_TRY_COUNT: time.sleep(2) diff --git a/dashscope/audio/qwen_asr/qwen_transcription.py b/dashscope/audio/qwen_asr/qwen_transcription.py index 859f0fc..f731ff9 100644 --- a/dashscope/audio/qwen_asr/qwen_transcription.py +++ b/dashscope/audio/qwen_asr/qwen_transcription.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- # Copyright (c) Alibaba, Inc. and its affiliates. -import asyncio import time from typing import Union -import aiohttp +import requests from dashscope.api_entities.dashscope_response import ( DashScopeAPIResponse, @@ -108,8 +107,8 @@ def fetch( workspace=workspace, **kwargs, ) - except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e: - logger.error(e) + except (requests.Timeout, requests.ConnectionError) as e: + logger.debug(e) try_count += 1 if try_count <= QwenTranscription.MAX_QUERY_TRY_COUNT: time.sleep(2) @@ -186,8 +185,8 @@ def _launch_request( workspace=workspace, **kwargs, ) - except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e: - logger.error(e) + except (requests.Timeout, requests.ConnectionError) as e: + logger.debug(e) try_count += 1 if try_count <= QwenTranscription.MAX_QUERY_TRY_COUNT: time.sleep(2) diff --git a/dashscope/audio/tts_v2/enrollment.py b/dashscope/audio/tts_v2/enrollment.py index 9a728c3..239606a 100644 --- a/dashscope/audio/tts_v2/enrollment.py +++ b/dashscope/audio/tts_v2/enrollment.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- # Copyright (c) Alibaba, Inc. and its affiliates. -import asyncio import time from typing import List -import aiohttp +import requests from dashscope.client.base_api import BaseApi from dashscope.common.constants import ApiProtocol, HTTPMethod @@ -71,8 +70,8 @@ def __call_with_input( # pylint: disable=redefined-builtin workspace=self._workspace, **self._kwargs, ) - except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e: - logger.error(e) + except (requests.Timeout, requests.ConnectionError) as e: + logger.debug(e) try_count += 1 if try_count <= VoiceEnrollmentService.MAX_QUERY_TRY_COUNT: time.sleep(2)