2626
2727public class AudioTranscript extends Feature {
2828
29-
3029 public AudioTranscript (@ NonNull ClassLoader classLoader , @ NonNull XSharedPreferences preferences ) {
3130 super (classLoader , preferences );
3231 }
@@ -44,24 +43,28 @@ public void doHook() throws Throwable {
4443 XposedBridge .hookMethod (transcribeMethod , new XC_MethodHook () {
4544 @ Override
4645 protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
47- DebugUtils .debugArgs (param .args );
4846 var pttTranscriptionRequest = param .args [0 ];
4947 var fieldFMessage = ReflectionUtils .getFieldByExtendType (pttTranscriptionRequest .getClass (), FMessageWpp .TYPE );
5048 var fmessageObj = fieldFMessage .get (pttTranscriptionRequest );
5149 var fmessage = new FMessageWpp (fmessageObj );
5250 File file = fmessage .getMediaFile ();
5351 var callback = param .args [1 ];
54- var mEnglishInstance = ReflectionUtils .getFieldByExtendType (unkTranscriptClass , unkTranscriptClass ).get (null );
5552 var onComplete = ReflectionUtils .findMethodUsingFilter (callback .getClass (), method -> method .getParameterCount () == 4 );
5653 String transcript = runTranscript (file );
5754 var segments = new ArrayList <>();
58- var words = transcript .split (" " );
55+ var words = transcript .split ("\\ s " );
5956 var totalLength = 0 ;
6057 for (var word : words ) {
6158 segments .add (XposedHelpers .newInstance (TranscriptionSegmentClass , totalLength , word .length (), 100 , -1 , -1 ));
6259 totalLength += word .length () + 1 ;
6360 }
64- ReflectionUtils .callMethod (onComplete , callback , mEnglishInstance , fmessageObj , transcript , segments );
61+ // In version 2.25.7.80 the language has been changed to an enum, but I will maintain for compatibility with old versions
62+ if (unkTranscriptClass != null ) {
63+ var mEnglishInstance = ReflectionUtils .getFieldByExtendType (unkTranscriptClass , unkTranscriptClass ).get (null );
64+ ReflectionUtils .callMethod (onComplete , callback , mEnglishInstance , fmessageObj , transcript , segments );
65+ } else {
66+ ReflectionUtils .callMethod (onComplete , callback , fmessageObj , transcript , segments , 1 );
67+ }
6568 param .setResult (null );
6669 }
6770 });
0 commit comments