Skip to content

Commit

Permalink
Fix tts api err (#6349)
Browse files Browse the repository at this point in the history
Co-authored-by: luowei <glpat-EjySCyNjWiLqAED-YmwM>
Co-authored-by: crazywoola <[email protected]>
Co-authored-by: crazywoola <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent 0de224b commit 06fcc0c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 5 additions & 2 deletions api/controllers/console/explore/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ def post(self, installed_app):
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):
Expand All @@ -95,7 +97,8 @@ def post(self, installed_app):
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:
Expand Down
10 changes: 6 additions & 4 deletions api/controllers/service_api/app/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,28 @@ def post(self, app_model: App, end_user: EndUser):
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):
text_to_speech = app_model.workflow.features_dict.get('text_to_speech')
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
Expand Down
7 changes: 5 additions & 2 deletions api/controllers/web/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ def post(self, app_model: App, end_user):
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):
Expand All @@ -94,7 +96,8 @@ def post(self, app_model: App, end_user):
app_model=app_model,
message_id=message_id,
end_user=end_user.external_user_id,
voice=voice
voice=voice,
text=text
)

return response
Expand Down

0 comments on commit 06fcc0c

Please sign in to comment.