@@ -913,23 +913,31 @@ def save_application_knowledge_mapping(application_knowledge_id_list, knowledge_
913913 [ApplicationKnowledgeMapping (application_id = application_id , knowledge_id = knowledge_id ) for knowledge_id in
914914 knowledge_id_list ]) if len (knowledge_id_list ) > 0 else None
915915
916- def speech_to_text (self , instance , with_valid = True ):
916+ def speech_to_text (self , instance , debug = True , with_valid = True ):
917917 if with_valid :
918918 self .is_valid (raise_exception = True )
919919 SpeechToTextRequest (data = instance ).is_valid (raise_exception = True )
920920 application_id = self .data .get ('application_id' )
921- application = QuerySet (Application ).filter (id = application_id ).first ()
921+ if debug :
922+ application = QuerySet (Application ).filter (id = application_id ).first ()
923+ else :
924+ application = QuerySet (ApplicationVersion ).filter (application_id = application_id ).order_by (
925+ '-create_time' ).first ()
922926 if application .stt_model_enable :
923927 model = get_model_instance_by_model_workspace_id (application .stt_model_id , application .workspace_id )
924928 text = model .speech_to_text (instance .get ('file' ))
925929 return text
926930
927- def text_to_speech (self , instance , with_valid = True ):
931+ def text_to_speech (self , instance , debug = True , with_valid = True ):
928932 if with_valid :
929933 self .is_valid (raise_exception = True )
930934 TextToSpeechRequest (data = instance ).is_valid (raise_exception = True )
931935 application_id = self .data .get ('application_id' )
932- application = QuerySet (Application ).filter (id = application_id ).first ()
936+ if debug :
937+ application = QuerySet (Application ).filter (id = application_id ).first ()
938+ else :
939+ application = QuerySet (ApplicationVersion ).filter (application_id = application_id ).order_by (
940+ '-create_time' ).first ()
933941 if application .tts_model_enable :
934942 model = get_model_instance_by_model_workspace_id (application .tts_model_id , application .workspace_id ,
935943 ** application .tts_model_params_setting )
0 commit comments