add more log in tongyi

pull/21891/head
ytqh 1 year ago
parent d12e412e6b
commit 0073c1f805

@ -1,16 +1,16 @@
import threading import threading
from queue import Queue from queue import Queue
from typing import Any, Optional from typing import Any, Optional
from venv import logger
import dashscope # type: ignore import dashscope # type: ignore
from dashscope import SpeechSynthesizer # type: ignore
from dashscope.api_entities.dashscope_response import SpeechSynthesisResponse # type: ignore
from dashscope.audio.tts import ResultCallback, SpeechSynthesisResult # type: ignore
from core.model_runtime.errors.invoke import InvokeBadRequestError from core.model_runtime.errors.invoke import InvokeBadRequestError
from core.model_runtime.errors.validate import CredentialsValidateFailedError from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.__base.tts_model import TTSModel from core.model_runtime.model_providers.__base.tts_model import TTSModel
from core.model_runtime.model_providers.tongyi._common import _CommonTongyi from core.model_runtime.model_providers.tongyi._common import _CommonTongyi
from dashscope import SpeechSynthesizer # type: ignore
from dashscope.api_entities.dashscope_response import SpeechSynthesisResponse # type: ignore
from dashscope.audio.tts import ResultCallback, SpeechSynthesisResult # type: ignore
class TongyiText2SpeechModel(_CommonTongyi, TTSModel): class TongyiText2SpeechModel(_CommonTongyi, TTSModel):
@ -70,12 +70,14 @@ class TongyiText2SpeechModel(_CommonTongyi, TTSModel):
""" """
word_limit = self._get_model_word_limit(model, credentials) word_limit = self._get_model_word_limit(model, credentials)
audio_type = self._get_model_audio_type(model, credentials) audio_type = self._get_model_audio_type(model, credentials)
logger.info(f"TONGYI: summary content length is less than word limit, content: {content_text}, voice: {voice}")
try: try:
audio_queue: Queue = Queue() audio_queue: Queue = Queue()
callback = Callback(queue=audio_queue) callback = Callback(queue=audio_queue)
def invoke_remote(content, v, api_key, cb, at, wl): def invoke_remote(content, v, api_key, cb, at, wl):
if len(content) < word_limit: if len(content) < word_limit:
logger.info(f"TONGYI: content length is less than word limit, content: {content}, voice: {v}")
sentences = [content] sentences = [content]
else: else:
sentences = list(self._split_text_into_sentences(org_text=content, max_length=wl)) sentences = list(self._split_text_into_sentences(org_text=content, max_length=wl))

Loading…
Cancel
Save