mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 18:25:54 +08:00
fix
This commit is contained in:
parent
ff3d3f71fb
commit
c3440a27fb
@ -56,7 +56,7 @@ def _process_future(
|
|||||||
|
|
||||||
|
|
||||||
class AppGeneratorTTSPublisher:
|
class AppGeneratorTTSPublisher:
|
||||||
def __init__(self, tenant_id: str, voice: str):
|
def __init__(self, tenant_id: str, voice: str, language: Optional[str] = None):
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
self.tenant_id = tenant_id
|
self.tenant_id = tenant_id
|
||||||
self.msg_text = ""
|
self.msg_text = ""
|
||||||
@ -67,7 +67,7 @@ class AppGeneratorTTSPublisher:
|
|||||||
self.model_instance = self.model_manager.get_default_model_instance(
|
self.model_instance = self.model_manager.get_default_model_instance(
|
||||||
tenant_id=self.tenant_id, model_type=ModelType.TTS
|
tenant_id=self.tenant_id, model_type=ModelType.TTS
|
||||||
)
|
)
|
||||||
self.voices = self.model_instance.get_tts_voices()
|
self.voices = self.model_instance.get_tts_voices(language=language)
|
||||||
values = [voice.get("value") for voice in self.voices]
|
values = [voice.get("value") for voice in self.voices]
|
||||||
self.voice = voice
|
self.voice = voice
|
||||||
if not voice or voice not in values:
|
if not voice or voice not in values:
|
||||||
|
@ -225,7 +225,9 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCyc
|
|||||||
and features_dict["text_to_speech"].get("enabled")
|
and features_dict["text_to_speech"].get("enabled")
|
||||||
and features_dict["text_to_speech"].get("autoPlay") == "enabled"
|
and features_dict["text_to_speech"].get("autoPlay") == "enabled"
|
||||||
):
|
):
|
||||||
tts_publisher = AppGeneratorTTSPublisher(tenant_id, features_dict["text_to_speech"].get("voice"))
|
tts_publisher = AppGeneratorTTSPublisher(
|
||||||
|
tenant_id, features_dict["text_to_speech"].get("voice"), features_dict["text_to_speech"].get("language")
|
||||||
|
)
|
||||||
|
|
||||||
for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
|
for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
|
||||||
while True:
|
while True:
|
||||||
|
@ -194,7 +194,9 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMa
|
|||||||
and features_dict["text_to_speech"].get("enabled")
|
and features_dict["text_to_speech"].get("enabled")
|
||||||
and features_dict["text_to_speech"].get("autoPlay") == "enabled"
|
and features_dict["text_to_speech"].get("autoPlay") == "enabled"
|
||||||
):
|
):
|
||||||
tts_publisher = AppGeneratorTTSPublisher(tenant_id, features_dict["text_to_speech"].get("voice"))
|
tts_publisher = AppGeneratorTTSPublisher(
|
||||||
|
tenant_id, features_dict["text_to_speech"].get("voice"), features_dict["text_to_speech"].get("language")
|
||||||
|
)
|
||||||
|
|
||||||
for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
|
for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
|
||||||
while True:
|
while True:
|
||||||
|
@ -215,7 +215,9 @@ class EasyUIBasedGenerateTaskPipeline(BasedGenerateTaskPipeline, MessageCycleMan
|
|||||||
and text_to_speech_dict.get("autoPlay") == "enabled"
|
and text_to_speech_dict.get("autoPlay") == "enabled"
|
||||||
and text_to_speech_dict.get("enabled")
|
and text_to_speech_dict.get("enabled")
|
||||||
):
|
):
|
||||||
publisher = AppGeneratorTTSPublisher(tenant_id, text_to_speech_dict.get("voice", None))
|
publisher = AppGeneratorTTSPublisher(
|
||||||
|
tenant_id, text_to_speech_dict.get("voice", None), text_to_speech_dict.get("language", None)
|
||||||
|
)
|
||||||
for response in self._process_stream_response(publisher=publisher, trace_manager=trace_manager):
|
for response in self._process_stream_response(publisher=publisher, trace_manager=trace_manager):
|
||||||
while True:
|
while True:
|
||||||
audio_response = self._listen_audio_msg(publisher, task_id)
|
audio_response = self._listen_audio_msg(publisher, task_id)
|
||||||
|
@ -59,6 +59,7 @@ class PluginBasicBooleanResponse(BaseModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
result: bool
|
result: bool
|
||||||
|
credentials: dict | None = None
|
||||||
|
|
||||||
|
|
||||||
class PluginModelSchemaEntity(BaseModel):
|
class PluginModelSchemaEntity(BaseModel):
|
||||||
|
@ -95,6 +95,9 @@ class PluginModelManager(BasePluginManager):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for resp in response:
|
for resp in response:
|
||||||
|
if resp.credentials and isinstance(resp.credentials, dict):
|
||||||
|
credentials.update(resp.credentials)
|
||||||
|
|
||||||
return resp.result
|
return resp.result
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@ -132,6 +135,9 @@ class PluginModelManager(BasePluginManager):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for resp in response:
|
for resp in response:
|
||||||
|
if resp.credentials and isinstance(resp.credentials, dict):
|
||||||
|
credentials.update(resp.credentials)
|
||||||
|
|
||||||
return resp.result
|
return resp.result
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user