Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix tts api err (#6349)

Charlie.Wei06fcc0c6505d
diff --git a/api/controllers/console/explore/audio.py b/api/controllers/console/explore/audio.py
index 920b1d8383d..27cc83042a7 100644
--- a/api/controllers/console/explore/audio.py
+++ b/api/controllers/console/explore/audio.py
@@ -78,10 +78,12 @@ class ChatTextApi(InstalledAppResource):
parser = reqparse.RequestParser()
parser.add_argument('message_id', type=str, required=False, location='json')
parser.add_argument('voice', type=str, location='json')
+ parser.add_argument('text', type=str, location='json')
parser.add_argument('streaming', type=bool, location='json')
args = parser.parse_args()
- message_id = args.get('message_id')
+ message_id = args.get('message_id', None)
+ text = args.get('text', None)
if (app_model.mode in [AppMode.ADVANCED_CHAT.value, AppMode.WORKFLOW.value]
and app_model.workflow
and app_model.workflow.features_dict):
@@ -95,7 +97,8 @@ class ChatTextApi(InstalledAppResource):
response = AudioService.transcript_tts(
app_model=app_model,
message_id=message_id,
- voice=voice
+ voice=voice,
+ text=text
)
return response
except services.errors.app_model_config.AppModelConfigBrokenError:
diff --git a/api/controllers/service_api/app/audio.py b/api/controllers/service_api/app/audio.py
index 607d71598f7..3c009af3435 100644
--- a/api/controllers/service_api/app/audio.py
+++ b/api/controllers/service_api/app/audio.py
@@ -76,10 +76,12 @@ class TextApi(Resource):
parser = reqparse.RequestParser()
parser.add_argument('message_id', type=str, required=False, location='json')
parser.add_argument('voice', type=str, location='json')
+ parser.add_argument('text', type=str, location='json')
parser.add_argument('streaming', type=bool, location='json')
args = parser.parse_args()
- message_id = args.get('message_id')
+ message_id = args.get('message_id', None)
+ text = args.get('text', None)
if (app_model.mode in [AppMode.ADVANCED_CHAT.value, AppMode.WORKFLOW.value]
and app_model.workflow
and app_model.workflow.features_dict):
@@ -87,15 +89,15 @@ class TextApi(Resource):
voice = args.get('voice') if args.get('voice') else text_to_speech.get('voice')
else:
try:
- voice = args.get('voice') if args.get('voice') else app_model.app_model_config.text_to_speech_dict.get(
- 'voice')
+ voice = args.get('voice') if args.get('voice') else app_model.app_model_config.text_to_speech_dict.get('voice')
except Exception:
voice = None
response = AudioService.transcript_tts(
app_model=app_model,
message_id=message_id,
end_user=end_user.external_user_id,
- voice=voice
+ voice=voice,
+ text=text
)
return response
diff --git a/api/controllers/web/audio.py b/api/controllers/web/audio.py
index 8be872f5f99..0e905f905a7 100644
--- a/api/controllers/web/audio.py
+++ b/api/controllers/web/audio.py
@@ -74,10 +74,12 @@ class TextApi(WebApiResource):
parser = reqparse.RequestParser()
parser.add_argument('message_id', type=str, required=False, location='json')
parser.add_argument('voice', type=str, location='json')
+ parser.add_argument('text', type=str, location='json')
parser.add_argument('streaming', type=bool, location='json')
args = parser.parse_args()
- message_id = args.get('message_id')
+ message_id = args.get('message_id', None)
+ text = args.get('text', None)
if (app_model.mode in [AppMode.ADVANCED_CHAT.value, AppMode.WORKFLOW.value]
and app_model.workflow
and app_model.workflow.features_dict):
@@ -94,7 +96,8 @@ class TextApi(WebApiResource):
app_model=app_model,
message_id=message_id,
end_user=end_user.external_user_id,
- voice=voice
+ voice=voice,
+ text=text
)
return response