├── .gitignore ├── DocumentPictures ├── ASRG_Begin.png ├── ASRG_Console.png ├── ASRG_ReqInfo.png ├── ASRG_Show.png ├── All_Frame.png ├── D_ProjectSettings.png ├── DocImg │ ├── B_ShowCode.png │ ├── D_GameInstance.png │ ├── D_MainUI_Designer.png │ ├── D_MainUI_Graph.png │ └── D_ProjectSettings.png ├── Product │ ├── G_ASRG_Code.png │ ├── G_AllMethod.png │ ├── G_CategoryList.png │ ├── G_FaceCompare_Code.png │ ├── G_FunctionList_1.png │ ├── G_FunctionList_2.png │ ├── G_ImgUnderstand_Code.png │ ├── G_ObjectRecognition_Code.png │ ├── G_PlaceRecognition.png │ ├── G_SFR_Code.png │ ├── G_STT_Code.png │ ├── G_SceneRecognition_Code.png │ ├── G_SparkHelper_Code.png │ ├── G_SparkHint_Code.png │ ├── G_SparkV3FunctionCall_Code.png │ ├── G_Spark_Code.png │ ├── G_TCO_Code.png │ ├── G_TTSG_Code.png │ ├── G_TTS_Code.png │ ├── G_UCR_Code.png │ ├── G_UCRintsig_Code.png │ ├── G_VD_Code.png │ └── T_Main_3.png ├── STTBegin.png ├── STTCenterWeb.png ├── STTCenterWeb_E.png ├── STTFreeEntry.png ├── STTReqInfo.png ├── STTResult.png ├── STTSettins.png ├── STT_Audio_48000_2_16.png ├── Spark_Begin.png ├── Spark_Center_E.png ├── Spark_Delegate.png ├── Spark_ReqInfo_Header.png ├── Spark_ReqInfo_Main.png ├── Spark_ReqInfo_ParameterInfo.png ├── Spark_ReqInfo_PayLoadInfo.png ├── TTSG_ConsoleCenter_AfterApply.png ├── TTSG_ConsoleCenter_Before.png ├── TTSG_ReqInfo.png ├── TTSG_Show.png ├── TTSG_Speaker.png ├── TTS_Blueprint.png ├── TTS_Center.png ├── TTS_Center_E.png ├── TTS_Free.png ├── TTS_ReqInfo.png ├── TTS_Settings.png ├── TTS_VoiceManage.png ├── XGXunFeiLink.png └── XunFeiLinkSettings.png ├── README.md ├── README_CN.md ├── XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用) ├── Resources │ └── Icon128.png ├── Source │ └── XGKeDaXunFeiSound │ │ ├── Private │ │ ├── Actor │ │ │ └── SceneVoice.cpp │ │ ├── Algorithm │ │ │ └── hmacsha256.cpp │ │ ├── Component │ │ │ ├── XGPlayVoiceComponent.cpp │ │ │ ├── XGSampleSynthComponent.cpp │ │ │ └── XGTTSPlayVoiceComponent.cpp │ │ ├── Config │ │ │ └── XGKeDaXunFeiSoundSettings.cpp │ │ ├── Core │ │ │ ├── XGAudioCaptureSubsystem.cpp │ │ │ ├── XGKeDaXunFeiSocketSubsystem.cpp │ │ │ └── XGTTSSubsystem.cpp │ │ ├── Thread │ │ │ └── ConsumeSoundRunnable.cpp │ │ ├── Type │ │ │ ├── XGRealTimeSpeechToTextRequestType.cpp │ │ │ └── XGRealTimeSpeechToTextResponseType.cpp │ │ ├── XGKeDaXunFeiSound.cpp │ │ └── XGKeDaXunFeiSoundBPLibrary.cpp │ │ ├── Public │ │ ├── Actor │ │ │ └── SceneVoice.h │ │ ├── Algorithm │ │ │ └── hmacsha256.h │ │ ├── Component │ │ │ ├── XGPlayVoiceComponent.h │ │ │ ├── XGSampleSynthComponent.h │ │ │ └── XGTTSPlayVoiceComponent.h │ │ ├── Config │ │ │ └── XGKeDaXunFeiSoundSettings.h │ │ ├── Core │ │ │ ├── XGAudioCaptureSubsystem.h │ │ │ ├── XGKeDaXunFeiSocketSubsystem.h │ │ │ └── XGTTSSubsystem.h │ │ ├── Thread │ │ │ └── ConsumeSoundRunnable.h │ │ ├── Type │ │ │ ├── XGRealTimeSpeechToTextRequestType.h │ │ │ └── XGRealTimeSpeechToTextResponseType.h │ │ ├── XGKeDaXunFeiSound.h │ │ └── XGKeDaXunFeiSoundBPLibrary.h │ │ └── XGKeDaXunFeiSound.Build.cs └── XGKeDaXunFeiSound.uplugin ├── XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包) ├── Config │ └── FilterPlugin.ini ├── Resources │ └── Icon128.png ├── Source │ ├── ThirdParty │ │ └── XGXunFeiBase │ │ │ ├── Private │ │ │ ├── XGXunFeiBase.cpp │ │ │ └── XGXunFeiBaseLibrary.cpp │ │ │ ├── Public │ │ │ ├── XGXunFeiBase.h │ │ │ └── XGXunFeiBaseLibrary.h │ │ │ └── XGXunFeiBase.Build.cs │ ├── XGXunFeiCore │ │ ├── Private │ │ │ ├── AsyncAction │ │ │ │ └── XGXunFeiCoreAsyncAction.cpp │ │ │ ├── Config │ │ │ │ └── XGXunFeiCoreSettings.cpp │ │ │ ├── Type │ │ │ │ └── XGXunFeiCoreWaveType.cpp │ │ │ ├── XGXunFeiCore.cpp │ │ │ └── XGXunFeiCoreBPLibrary.cpp │ │ ├── Public │ │ │ ├── AsyncAction │ │ │ │ └── XGXunFeiCoreAsyncAction.h │ │ │ ├── Config │ │ │ │ └── XGXunFeiCoreSettings.h │ │ │ ├── Type │ │ │ │ └── XGXunFeiCoreWaveType.h │ │ │ ├── XGXunFeiCore.h │ │ │ └── XGXunFeiCoreBPLibrary.h │ │ └── XGXunFeiCore.Build.cs │ ├── XGXunFeiLink │ │ ├── Private │ │ │ ├── XGXunFeiLink.cpp │ │ │ └── XGXunFeiLinkBPLibrary.cpp │ │ ├── Public │ │ │ ├── XGXunFeiLink.h │ │ │ └── XGXunFeiLinkBPLibrary.h │ │ └── XGXunFeiLink.Build.cs │ ├── XGXunFeiSTT │ │ ├── Private │ │ │ ├── Log │ │ │ │ └── LogXGXunFeiSTT.cpp │ │ │ ├── Subsystem │ │ │ │ ├── XGXunFeiAudioCaptureSubsystem.cpp │ │ │ │ └── XGXunFeiRealTimeSTTSubsystem.cpp │ │ │ ├── Thread │ │ │ │ └── XGXunFeiConsumeVoiceRunnable.cpp │ │ │ ├── Type │ │ │ │ └── STT │ │ │ │ │ ├── XGXunFeiRealTimeSTTReqType.cpp │ │ │ │ │ └── XGXunFeiRealTimeSTTRespType.cpp │ │ │ └── XGXunFeiSTT.cpp │ │ ├── Public │ │ │ ├── Log │ │ │ │ └── LogXGXunFeiSTT.h │ │ │ ├── Subsystem │ │ │ │ ├── XGXunFeiAudioCaptureSubsystem.h │ │ │ │ └── XGXunFeiRealTimeSTTSubsystem.h │ │ │ ├── Thread │ │ │ │ └── XGXunFeiConsumeVoiceRunnable.h │ │ │ ├── Type │ │ │ │ └── STT │ │ │ │ │ ├── XGXunFeiRealTimeSTTReqType.h │ │ │ │ │ ├── XGXunFeiRealTimeSTTRespType.h │ │ │ │ │ └── XGXunFeiRealTimeSTTType.h │ │ │ └── XGXunFeiSTT.h │ │ └── XGXunFeiSTT.Build.cs │ └── XGXunFeiTTS │ │ ├── Private │ │ ├── AsyncNode │ │ │ └── XGXunFeiTTSAsyncAction.cpp │ │ ├── Log │ │ │ └── LogXGXunFeiTTS.cpp │ │ ├── Type │ │ │ ├── XGXunFeiTTSReqType.cpp │ │ │ └── XGXunFeiTTSRespType.cpp │ │ ├── XGXunFeiTTS.cpp │ │ └── XGXunFeiTTSBPLibrary.cpp │ │ ├── Public │ │ ├── AsyncNode │ │ │ └── XGXunFeiTTSAsyncAction.h │ │ ├── Log │ │ │ └── LogXGXunFeiTTS.h │ │ ├── Type │ │ │ ├── XGXunFeiTTSReqType.h │ │ │ └── XGXunFeiTTSRespType.h │ │ ├── XGXunFeiTTS.h │ │ └── XGXunFeiTTSBPLibrary.h │ │ └── XGXunFeiTTS.Build.cs └── XGXunFeiLink.uplugin └── XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程) ├── Config ├── DefaultEditor.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── Content └── XGXunFei │ ├── Enum │ └── E_SparkInformationType.uasset │ ├── GameFrame │ ├── BP_XunFeiGameInstance.uasset │ ├── Common │ │ └── BP_XunFeiGameMode.uasset │ └── Talk │ │ ├── BP_Audio.uasset │ │ ├── BP_TalkGameMode.uasset │ │ ├── BP_TalkHUD.uasset │ │ └── BP_TalkLibrary.uasset │ ├── Maps │ ├── MainMap.umap │ └── TalkMap.umap │ ├── Struct │ ├── S_SparkTalkMessage.uasset │ ├── S_TTSAduio.uasset │ ├── S_TTSTask.uasset │ └── S_VDSNText.uasset │ └── UI │ ├── Main │ └── WBP_Main_Layout.uasset │ └── Talk │ ├── WBP_InformationItem.uasset │ ├── WBP_InputText.uasset │ ├── WBP_TalkBox.uasset │ ├── WBP_TalkSpark_Layout.uasset │ └── WBP_VCN.uasset └── XunFeiLinkDemo.uproject /.gitignore: -------------------------------------------------------------------------------- 1 | # UE5 2 | Binaries/ 3 | Intermediate/ 4 | Saved/ 5 | DerivedDataCache/ 6 | Build/ 7 | # Prerequisites 8 | *.d 9 | 10 | # Compiled Object files 11 | *.slo 12 | *.lo 13 | *.o 14 | *.obj 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Compiled Dynamic libraries 21 | *.so 22 | *.dylib 23 | *.dll 24 | 25 | # Fortran module files 26 | *.mod 27 | *.smod 28 | 29 | # Compiled Static libraries 30 | *.lai 31 | *.la 32 | *.a 33 | *.lib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | -------------------------------------------------------------------------------- /DocumentPictures/ASRG_Begin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/ASRG_Begin.png -------------------------------------------------------------------------------- /DocumentPictures/ASRG_Console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/ASRG_Console.png -------------------------------------------------------------------------------- /DocumentPictures/ASRG_ReqInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/ASRG_ReqInfo.png -------------------------------------------------------------------------------- /DocumentPictures/ASRG_Show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/ASRG_Show.png -------------------------------------------------------------------------------- /DocumentPictures/All_Frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/All_Frame.png -------------------------------------------------------------------------------- /DocumentPictures/D_ProjectSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/D_ProjectSettings.png -------------------------------------------------------------------------------- /DocumentPictures/DocImg/B_ShowCode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/DocImg/B_ShowCode.png -------------------------------------------------------------------------------- /DocumentPictures/DocImg/D_GameInstance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/DocImg/D_GameInstance.png -------------------------------------------------------------------------------- /DocumentPictures/DocImg/D_MainUI_Designer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/DocImg/D_MainUI_Designer.png -------------------------------------------------------------------------------- /DocumentPictures/DocImg/D_MainUI_Graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/DocImg/D_MainUI_Graph.png -------------------------------------------------------------------------------- /DocumentPictures/DocImg/D_ProjectSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/DocImg/D_ProjectSettings.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_ASRG_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_ASRG_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_AllMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_AllMethod.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_CategoryList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_CategoryList.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_FaceCompare_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_FaceCompare_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_FunctionList_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_FunctionList_1.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_FunctionList_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_FunctionList_2.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_ImgUnderstand_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_ImgUnderstand_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_ObjectRecognition_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_ObjectRecognition_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_PlaceRecognition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_PlaceRecognition.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_SFR_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_SFR_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_STT_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_STT_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_SceneRecognition_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_SceneRecognition_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_SparkHelper_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_SparkHelper_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_SparkHint_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_SparkHint_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_SparkV3FunctionCall_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_SparkV3FunctionCall_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_Spark_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_Spark_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_TCO_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_TCO_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_TTSG_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_TTSG_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_TTS_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_TTS_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_UCR_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_UCR_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_UCRintsig_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_UCRintsig_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/G_VD_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/G_VD_Code.png -------------------------------------------------------------------------------- /DocumentPictures/Product/T_Main_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Product/T_Main_3.png -------------------------------------------------------------------------------- /DocumentPictures/STTBegin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTBegin.png -------------------------------------------------------------------------------- /DocumentPictures/STTCenterWeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTCenterWeb.png -------------------------------------------------------------------------------- /DocumentPictures/STTCenterWeb_E.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTCenterWeb_E.png -------------------------------------------------------------------------------- /DocumentPictures/STTFreeEntry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTFreeEntry.png -------------------------------------------------------------------------------- /DocumentPictures/STTReqInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTReqInfo.png -------------------------------------------------------------------------------- /DocumentPictures/STTResult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTResult.png -------------------------------------------------------------------------------- /DocumentPictures/STTSettins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STTSettins.png -------------------------------------------------------------------------------- /DocumentPictures/STT_Audio_48000_2_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/STT_Audio_48000_2_16.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_Begin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_Begin.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_Center_E.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_Center_E.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_Delegate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_Delegate.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_ReqInfo_Header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_ReqInfo_Header.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_ReqInfo_Main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_ReqInfo_Main.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_ReqInfo_ParameterInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_ReqInfo_ParameterInfo.png -------------------------------------------------------------------------------- /DocumentPictures/Spark_ReqInfo_PayLoadInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/Spark_ReqInfo_PayLoadInfo.png -------------------------------------------------------------------------------- /DocumentPictures/TTSG_ConsoleCenter_AfterApply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTSG_ConsoleCenter_AfterApply.png -------------------------------------------------------------------------------- /DocumentPictures/TTSG_ConsoleCenter_Before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTSG_ConsoleCenter_Before.png -------------------------------------------------------------------------------- /DocumentPictures/TTSG_ReqInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTSG_ReqInfo.png -------------------------------------------------------------------------------- /DocumentPictures/TTSG_Show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTSG_Show.png -------------------------------------------------------------------------------- /DocumentPictures/TTSG_Speaker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTSG_Speaker.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_Blueprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_Blueprint.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_Center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_Center.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_Center_E.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_Center_E.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_Free.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_Free.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_ReqInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_ReqInfo.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_Settings.png -------------------------------------------------------------------------------- /DocumentPictures/TTS_VoiceManage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/TTS_VoiceManage.png -------------------------------------------------------------------------------- /DocumentPictures/XGXunFeiLink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/XGXunFeiLink.png -------------------------------------------------------------------------------- /DocumentPictures/XunFeiLinkSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/DocumentPictures/XunFeiLinkSettings.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XGXunFeiLink 2 | Plugin Version:4.1 3 | ## Brief 4 | 5 | This is XGXunFeiLink project,which it helps to connect iFlyTek with UnrealEngine 5. 6 | At pressent,It contains a lot of functions : 7 | Spark Big Model 8 | Automatic Speech Recognition 9 | Speech Synthesis 10 | Face Recognition 11 | Character Recognition 12 | Image Recognition 13 | 14 | 15 | It contains Four parts: 16 | 17 | "DocumentPictures":There are some pictures used by this document. 18 | 19 | "XGKeDaXunFeiSound-v1.0-Test":It is just study and test code.lease do not use it in a formal situation. 20 | 21 | "XGXunFeiLink-v2.4-FreeTrial":The part of code is only for learning.You can try it for free, but it's not commercially available.If you have some commercial use,you can purchase it through Unreal Engine Marketplace. 22 | 23 | "XunFeiLinDemo-v3.6-UE5.3":The project shows you how to quickly use this plugin.Before you start it,you should purchase the plugin and install it to UnealEngine 5.Then,you should prepare some necessary resources(text,auido,img...).You must register your App info from iFlyTek Web by yourself. 24 | 25 | Demo Video URL: 26 | 27 | [PluginShowVideo-2.4](https://youtu.be/6NQ4PO2RpOU) 28 | 29 | UE Marketplace URL: 30 | 31 | [XGXunFeiLink](https://www.unrealengine.com/marketplace/en-US/product/xgxunfeilink) 32 | 33 | Chinese Instruction URL: 34 | [中文说明书](./README_CN.md) 35 | 36 | iFlyTek Global Web URL: 37 | 38 | [IFlyTekWebUrl-en](https://global.xfyun.cn/) 39 | 40 | iFlyTek Chinese Web URL: 41 | 42 | [IFlyTekWebUrl-cn](https://www.xfyun.cn/) 43 | 44 | ## Important Things 45 | 46 | CategoryList: 47 | 48 | ![image](DocumentPictures/Product/G_CategoryList.png) 49 | 50 | FunctionList: 51 | 52 | ![image](DocumentPictures/Product/G_FunctionList_1.png) 53 | 54 | ![image](DocumentPictures/Product/G_FunctionList_2.png) 55 | 56 | All Method List: 57 | 58 | ![image](DocumentPictures/Product/G_AllMethod.png) 59 | 60 | iFlyTek provides a lot of Web API both in China or in the global region. 61 | 62 | This plugin supports these WebAPI in different region. 63 | 64 | Most of WebAPI seem to be similar. 65 | 66 | However,they are really different. 67 | You need different accounts,AppID,APIKey,APISecret,especially when you are in China and out of China. 68 | Keep in mind that right App information correspond with right Web API. 69 | 70 | ## Get App Information 71 | 72 | If you don't create the iFlyTek App,you should create it. 73 | 74 | iFlyTek Web(Chinese site,No Global): 75 | 76 | [IFlyTekWebUrl-cn](https://www.xfyun.cn/) 77 | 78 | iFlyTek Web(English site,Global): 79 | 80 | [IFlyTekWebUrl-en](https://global.xfyun.cn/) 81 | 82 | Although the code is similar,Only when iFlyTek supports Web API in these regions,this plugin can work . 83 | 84 | You have to register your account and manage your App information through different sites. 85 | 86 | It is not very difficult to do . You can translate this web page directly through the browser tool. 87 | 88 | I have translated some important interface parameters in my codes and documents. 89 | 90 | After you create the App, you should enable corresponding function in your iFlyTek control panel,such as STT ,TTS,Spark. 91 | 92 | Be careful that some functions are not free.Howover,You can try it for free in a short time. 93 | 94 | ## Browse The Plugin From UE 95 | 96 | You can quickly learn which method and documentation each API corresponds to. 97 | 98 | ![image](DocumentPictures/DocImg/D_ProjectSettings.png) 99 | 100 | ## Functional detail 101 | 102 | ### Spark Big Model 103 | 104 | 105 | #### Spark(V1.5,V2.0,V3.0) 106 | 107 | URL:https://www.xfyun.cn/doc/spark/Web.html 108 | 109 | 110 | ![image](DocumentPictures/Product/G_Spark_Code.png) 111 | 112 | #### SparkV3.0FuncionCall 113 | 114 | URL:https://www.xfyun.cn/doc/spark/Web.html 115 | 116 | ![image](DocumentPictures/Product/G_SparkV3FunctionCall_Code.png) 117 | 118 | #### SparkHelper 119 | 120 | URL: 121 | https://www.xfyun.cn/doc/spark/SparkAssistantAPI.html 122 | 123 | 124 | ![image](DocumentPictures/Product/G_SparkHelper_Code.png) 125 | 126 | #### SparkHint 127 | 128 | URL: 129 | https://www.xfyun.cn/doc/spark/%E6%98%9F%E7%81%AB%E5%BE%AE%E8%B0%83%E6%9C%8D%E5%8A%A1Web%E6%96%87%E6%A1%A3.html 130 | 131 | 132 | ![image](DocumentPictures/Product/G_SparkHint_Code.png) 133 | 134 | #### ImgUnderstand 135 | 136 | URL: 137 | https://www.xfyun.cn/doc/spark/ImageUnderstanding.html 138 | 139 | 140 | 141 | ![image](DocumentPictures/Product/G_ImgUnderstand_Code.png) 142 | 143 | ### Automatic Speech Recognition 144 | 145 | You can call XunFeiBeginRealTimeSpeechToText to begin STT. 146 | 147 | You can call XunFeiStopRealTimeSpeechToText to end STT. 148 | 149 | It captures audio data from audio input device,and then send it to iFLyTek Web API. 150 | 151 | It will call you to recive results. 152 | 153 | It calls you to recive results ,src text,dst text. 154 | 155 | Defualt audio input device must in 156 | 157 | [48000 kHz,16 bits, 2 channle], 158 | 159 | [48000 kHz,16 bits, 1 channle], 160 | 161 | [16000 kHz,16 bits, 1 channle]. 162 | 163 | If your audio input device is not right,you wil not get src text or dst text. 164 | 165 | #### ASR(Global) 166 | 167 | URL: 168 | https://global.xfyun.cn/doc/rtasr/rtasr/API.html 169 | 170 | 171 | 172 | ![image](DocumentPictures/Product/G_ASRG_Code.png) 173 | 174 | #### STT 175 | 176 | URL: 177 | https://www.xfyun.cn/doc/asr/rtasr/API.html 178 | 179 | 180 | ![image](DocumentPictures/Product/G_STT_Code.png) 181 | 182 | #### VoiceDictation 183 | 184 | URL: 185 | https://www.xfyun.cn/doc/asr/voicedictation/API.html 186 | 187 | 188 | ![image](DocumentPictures/Product/G_VD_Code.png) 189 | 190 | 191 | ### Speech Synthesis 192 | 193 | You can call XunFeiTextToSpeech to begin TTS. 194 | 195 | It is a async blueprint node. 196 | 197 | It converts text to USoundWave and wav file. 198 | 199 | You have to input the text to convert it. 200 | 201 | If you enable bSaveToLocal,you must input the right and absolute file path. 202 | 203 | The directory must exist. 204 | 205 | The file name must end with ".wav" 206 | 207 | You can keep it default for test at first. 208 | Different languages choose different pronunciations to have the best pronunciation. 209 | Advanced speakers cost extra. 210 | The Picture Shows where to add a new speeker. 211 | The Picture after it was translated by the browsing tools is as follow: 212 | ![image](DocumentPictures/TTS_VoiceManage.png) 213 | 214 | The Picture Shows where to add a new speeker. 215 | ![image](DocumentPictures/TTSG_Speaker.png) 216 | 217 | #### TTS(Global) 218 | 219 | URL: 220 | https://global.xfyun.cn/doc/tts/online_tts/API.html 221 | 222 | 223 | ![image](DocumentPictures/Product/G_TTSG_Code.png) 224 | 225 | #### TTS 226 | 227 | URL: 228 | https://www.xfyun.cn/doc/tts/online_tts/API.html 229 | 230 | ![image](DocumentPictures/Product/G_TTS_Code.png) 231 | 232 | ### Face Recognition 233 | 234 | #### FaceComparison 235 | 236 | URL: 237 | https://www.xfyun.cn/doc/face/xffaceComparisonRecg/API.html 238 | 239 | 240 | ![image](DocumentPictures/Product/G_FaceCompare_Code.png) 241 | 242 | 243 | ### Character Recognition 244 | 245 | 246 | #### Universal Character Recognition 247 | 248 | URL: 249 | https://www.xfyun.cn/doc/words/universal_character_recognition/API.html 250 | 251 | 252 | 253 | ![image](DocumentPictures/Product/G_UCR_Code.png) 254 | 255 | #### Universal Character Recognition(intsig) 256 | 257 | URL: 258 | https://www.xfyun.cn/doc/words/universal-character-recognition/API.html 259 | 260 | 261 | 262 | ![image](DocumentPictures/Product/G_UCRintsig_Code.png) 263 | 264 | 265 | ### Image Recognition 266 | 267 | 268 | #### Scene Recognition 269 | 270 | URL: 271 | https://www.xfyun.cn/doc/image/scene-recg/API.html 272 | 273 | 274 | ![image](DocumentPictures/Product/G_SceneRecognition_Code.png) 275 | 276 | #### Object Recognition 277 | 278 | URL: 279 | https://www.xfyun.cn/doc/image/object-recg/API.html 280 | 281 | 282 | ![image](DocumentPictures/Product/G_ObjectRecognition_Code.png) 283 | 284 | #### Place Recoginition 285 | 286 | URL: 287 | https://www.xfyun.cn/doc/image/place-recg/API.html 288 | 289 | 290 | ![image](DocumentPictures/Product/G_PlaceRecognition.png) 291 | 292 | 293 | ## XGXunFeiLinkDemo 294 | 295 | 296 | 1.App info shoulud be input "Content/GameFrame/BP_XunFeiGameInstance" 297 | 298 | ![image](DocumentPictures/DocImg/D_GameInstance.png) 299 | 300 | 301 | 2.All BP methods are in "Content/UI/BP_ShowCode" 302 | 303 | ![image](DocumentPictures/DocImg/B_ShowCode.png) 304 | 305 | 306 | 3.All buttons are in "Content/UI/WBP_MainUI" 307 | 308 | ![image](DocumentPictures/DocImg/D_MainUI_Designer.png) 309 | 310 | 311 | ![image](DocumentPictures/DocImg/D_MainUI_Graph.png) 312 | 313 | 314 | 4.Some nodes need to temporarily prepare pictures, audio and other resources in the Saved directory of the project for testing, and specify the file location in the blueprint node. If the test is packaged, you also need to copy the same resource in the packaged path. 315 | 316 | ## Framwork 317 | 318 | XGXunFeiBase 319 | Process open/ssl->HmacSha256 320 | 321 | XGXunFeiCore 322 | Common API Exposed to OtherModule 323 | 324 | XGXunFeiSTT 325 | STT Module 326 | 327 | XGXunFeiTTS 328 | TTS Module 329 | 330 | XGXunFeiSpark 331 | Spark Module 332 | 333 | XGXunFeiASRG 334 | ASRG Module 335 | 336 | XGXunFeiTTSG 337 | TTSG Module 338 | 339 | XGXunFeiTR 340 | TTSG Module 341 | 342 | XGXunFeiFR 343 | TTSG Module 344 | 345 | XGXunFeiIR 346 | TTSG Module 347 | 348 | XGXunFeiOther 349 | ......(to be added) 350 | 351 | XGXunFeiLink 352 | It contains UE C++ API . 353 | 354 | ......\Plugins\XGXunFeiLink\Source\XGXunFeiLink\Public\XGXunFeiLinkBPLibrary.h 355 | 356 | Other API is highly customized. 357 | It may be not good for the general design. 358 | 359 | ![image](DocumentPictures/All_Frame.png) 360 | 361 | Remember it: 362 | 363 | If you use C++ API,you should add the modules to your "*.build.cs". 364 | ``` 365 | public class XGXunFeiDemo : ModuleRules 366 | { 367 | public XGXunFeiDemo(ReadOnlyTargetRules Target) : base(Target) 368 | { 369 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 370 | 371 | PublicDependencyModuleNames.AddRange(new string[] { 372 | "Core", 373 | "CoreUObject", 374 | "Engine", 375 | "InputCore"," 376 | XGXunFeiLink", 377 | "XGXunFeiCore", 378 | "XGXunFeiSTT", 379 | "XGXunFeiTTS", 380 | "XGXunFeiSpark", 381 | "XGXunFeiTTSG", 382 | "XGXunFeiASRG", 383 | "XGXunFeiOther......" 384 | }); 385 | 386 | PrivateDependencyModuleNames.AddRange(new string[] { }); 387 | 388 | 389 | } 390 | } 391 | 392 | ``` 393 | 394 | ## Package 395 | Windows:[5.0-5.3] 396 | Andriod:Only version 5.3 has been tested. 397 | ## Other 398 | This plugin does not contain any iFlyTek's files(\*.h,\*.cpp,\*.lib,......) 399 | 400 | This plugin does not contain AI code or AI Model code. 401 | 402 | This plugin uses "OpenSSL" to encrypt information in the network,but it will not send data to the Creator("OpenSSL"). 403 | 404 | This plugin will not send any data to the plugin author. 405 | 406 | This plugin was not developed by iFlyTek. 407 | 408 | This plugin will only send the interactive data to iFLyTek and recieve the message from iFlyTek . This plugin will not generate any data directly.You must comply with the relevant user and data usage agreements aboutt iFlyTek.These agreements can be found in the iFLyTek website. 409 | 410 | The part of plugin code was uploaded to GitHub just for learning. 411 | 412 | If the plugin is useful for you. Please purchase it in Unreal Engine Marketplace. 413 | 414 | Thanks a lot. 415 | 416 | ## Contact Information 417 | 418 | Please contact me if you have any questions about [XGXunFeiLink](https://www.unrealengine.com/marketplace/en-US/product/xgxunfeilink). 419 | 420 | QQ: 421 | 709777172 422 | 423 | Email: 424 | 709777172@qq.com 425 | 426 | bilibili: 427 | [虚幻小刚](https://space.bilibili.com/8383085) 428 | 429 | 430 | 431 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # XGXunFeiLink 2 | Plugin Version:4.1 3 | ## 简介 4 | 连接虚幻引擎5和科大讯飞的WebAPI的引擎插件
5 | 英文文档:
6 | [English Instruction](./README.md)
7 | 中文文档:
8 | [Chinese Instruction](./README_CN.md)
9 | 开发日志视频(中文):
10 | [虚幻科大讯飞插件开发实战](https://www.bilibili.com/video/BV13W4y1w7MV/)
11 | 油管视频(英文):
12 | [PluginVersion-2.4](https://youtu.be/6NQ4PO2RpOU)
13 | 商城链接:
14 | [XGXunFeiLink购买链接](https://www.unrealengine.com/marketplace/en-US/product/xgxunfeilink)
15 | 注意:
16 | 1.你需要自行去科大讯飞官网进行注册应用信息,获取AppID,APISecret,APIKey等,大部分功能均可免费试用,部分功能可以长期试用.
17 | 科大讯飞官网分为中文站和全球站,两套网站的信息功能不互通.
18 | 只有全球站的功能才支持全球调用.
19 | [IFlyTekWebUrl-en](https://global.xfyun.cn/)
20 | [IFlyTekWebUrl-cn](https://www.xfyun.cn/)
21 | 2.本插件并非由官方人员开发,也不包含任何来自科大讯飞的代码,图片等,也不会存储你的应用信息等,功能仅由虚幻引擎的提供代码进行实现通讯交互. 22 | ## 代码库介绍 23 | ### 文件夹 DocumentPictures: 24 | 25 | 文档中的各类图片 26 | 27 | ### 文件夹 XGKeDaXunFeiSound-v1.0-Test: 28 | 29 | 插件1.0版本开发中的测试代码,请勿使用 30 | 31 | ### 文件夹 XGXunFeiLink-v2.4-FreeTrial: 32 | 33 | 插件2.4版本,仅包含STT和TTS,免费体验试用版,不允许商用 34 | 35 | ### 文件夹 XunFeiLinDemo-v3.6-EngineVersion5.3: 36 | 37 | 在插件3.6版本和引擎5.3版本下的测试Demo,主要为了方便蓝图节点拷贝测试使用. 38 | 需要在商城购置插件,引擎安装后,Demo方可运行. 39 | Demo本身不包含插件. 40 | 41 | 42 | ## 功能简介 43 | 44 | ![image](DocumentPictures/Product/G_CategoryList.png) 45 | 46 | 星火大模型,语音识别,语音合成,人脸识别,文字识别,图像识别...... 47 | 48 | 支持多引擎版本Windos打包(5.0-5.3),UE5.3已测试可安卓打包使用.其余未测试. 49 | 50 | 内置功能跳转链接: 51 | 52 | ![image](DocumentPictures/DocImg/D_ProjectSettings.png) 53 | 54 | 所有API预览: 55 | 56 | ![image](DocumentPictures/Product/G_AllMethod.png) 57 | 58 | ## 功能详解 59 | ![image](DocumentPictures/Product/G_FunctionList_1.png) 60 | ![image](DocumentPictures/Product/G_FunctionList_2.png) 61 | 62 | ### Spark Big Model-星火大模型 63 | 64 | #### Spark(V1.5,V2.0,V3.0) 65 | 66 | 星火大模型 67 | 68 | URL:https://www.xfyun.cn/doc/spark/Web.html 69 | 70 | ![image](DocumentPictures/Product/G_Spark_Code.png) 71 | 72 | #### SparkV3.0FuncionCall 73 | 74 | 星火大模型 75 | 76 | URL: 77 | https://www.xfyun.cn/doc/spark/Web.html 78 | 79 | ![image](DocumentPictures/Product/G_SparkV3FunctionCall_Code.png) 80 | 81 | #### SparkHelper 82 | 83 | 星火助手 84 | 85 | URL: 86 | https://www.xfyun.cn/doc/spark/SparkAssistantAPI.html 87 | 88 | 89 | ![image](DocumentPictures/Product/G_SparkHelper_Code.png) 90 | 91 | #### SparkHint 92 | 93 | 星火微调 94 | 95 | URL: 96 | https://www.xfyun.cn/doc/spark/%E6%98%9F%E7%81%AB%E5%BE%AE%E8%B0%83%E6%9C%8D%E5%8A%A1Web%E6%96%87%E6%A1%A3.html 97 | 98 | 99 | ![image](DocumentPictures/Product/G_SparkHint_Code.png) 100 | 101 | #### ImgUnderstand 102 | 103 | 图片理解 104 | 105 | URL: 106 | https://www.xfyun.cn/doc/spark/ImageUnderstanding.html 107 | 108 | 109 | 110 | ![image](DocumentPictures/Product/G_ImgUnderstand_Code.png) 111 | 112 | ### Automatic Speech Recognition-语音识别 113 | #### ASR(Global) 114 | 115 | 实时语音识别 (全球) 116 | 117 | 118 | URL: 119 | https://global.xfyun.cn/doc/rtasr/rtasr/API.html 120 | 121 | 122 | ![image](DocumentPictures/Product/G_ASRG_Code.png) 123 | #### STT 124 | 125 | 实时语音识别 126 | URL: 127 | https://www.xfyun.cn/doc/asr/rtasr/API.html 128 | 129 | 130 | ![image](DocumentPictures/Product/G_STT_Code.png) 131 | #### VoiceDictation 132 | 133 | 语音听写(1min) 134 | 135 | URL: 136 | https://www.xfyun.cn/doc/asr/voicedictation/API.html 137 | 138 | 139 | ![image](DocumentPictures/Product/G_VD_Code.png) 140 | 141 | ### Speech Synthesis-语音合成 142 | #### TTS(Global) 143 | 144 | 语音合成(全球) 145 | 146 | URL: 147 | https://global.xfyun.cn/doc/tts/online_tts/API.html 148 | 149 | 150 | ![image](DocumentPictures/Product/G_TTSG_Code.png) 151 | #### TTS 152 | 153 | 语音合成 154 | 155 | URL: 156 | https://www.xfyun.cn/doc/tts/online_tts/API.html 157 | 158 | 159 | ![image](DocumentPictures/Product/G_TTS_Code.png) 160 | 161 | ### Face Recognition-人脸识别 162 | #### FaceComparison 163 | 164 | 人脸比较 165 | 166 | URL: 167 | https://www.xfyun.cn/doc/face/xffaceComparisonRecg/API.html 168 | 169 | 170 | ![image](DocumentPictures/Product/G_FaceCompare_Code.png) 171 | 172 | ### Character Recognition-文字识别 173 | #### Universal Character Recognition 174 | 175 | 通用文字识别 176 | 177 | URL: 178 | https://www.xfyun.cn/doc/words/universal_character_recognition/API.html 179 | 180 | 181 | ![image](DocumentPictures/Product/G_UCR_Code.png) 182 | #### Universal Character Recognition(intsig) 183 | 184 | 通用文字识别(多语种) 185 | 186 | URL: 187 | https://www.xfyun.cn/doc/words/universal-character-recognition/API.html 188 | 189 | 190 | ![image](DocumentPictures/Product/G_UCRintsig_Code.png) 191 | 192 | 193 | ### Image Recognition-图像识别 194 | #### Scene Recognition 195 | 196 | 场景识别 197 | 198 | URL: 199 | https://www.xfyun.cn/doc/image/scene-recg/API.html 200 | 201 | 202 | ![image](DocumentPictures/Product/G_SceneRecognition_Code.png) 203 | 204 | #### Object Recognition 205 | 206 | 物体识别 207 | 208 | URL: 209 | https://www.xfyun.cn/doc/image/object-recg/API.html 210 | 211 | 212 | ![image](DocumentPictures/Product/G_ObjectRecognition_Code.png) 213 | 214 | #### Place Recoginition 215 | 216 | 场所识别 217 | 218 | URL: 219 | https://www.xfyun.cn/doc/image/place-recg/API.html 220 | 221 | 222 | ![image](DocumentPictures/Product/G_PlaceRecognition.png) 223 | 224 | 225 | ## XGXunFeiLinkDemo 226 | 1.请在Content/GameFrame/BP_XunFeiGameInstance中对于App信息进行配置 227 | 228 | ![image](DocumentPictures/DocImg/D_GameInstance.png) 229 | 230 | 231 | 2.所有可以使用的蓝图节点在Content/UI/BP_ShowCode中 232 | 233 | ![image](DocumentPictures/DocImg/B_ShowCode.png) 234 | 235 | 236 | 3.所有UI按钮均在Content/UI/WBP_MainUI中 237 | 238 | ![image](DocumentPictures/DocImg/D_MainUI_Designer.png) 239 | 240 | 241 | ![image](DocumentPictures/DocImg/D_MainUI_Graph.png) 242 | 243 | 244 | 4.部分节点需要临时自行准备图片,音频等资源放在项目的Saved目录下进行测试,并在蓝图节点中指定文件位置.如果是测试打包后,也需要拷贝同样的资源在打包后的路径. 245 | 246 | ## 联系方式 247 | 如果有任何[XGXunFeiLink](https://www.unrealengine.com/marketplace/en-US/product/xgxunfeilink)插件产品问题,请联系我. 248 | 249 | QQ: 250 | 709777172 251 | 252 | Email: 253 | 709777172@qq.com 254 | 255 | bilibili: 256 | [虚幻小刚](https://space.bilibili.com/8383085) 257 | 258 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Resources/Icon128.png -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Actor/SceneVoice.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "SceneVoice.h" 3 | #include 4 | #include 5 | #include 6 | ASceneVoice::ASceneVoice() 7 | { 8 | 9 | RootComponent = CreateDefaultSubobject(TEXT("Root")); 10 | 11 | } 12 | 13 | void ASceneVoice::OnNewSubmixBuffer(const USoundSubmix* OwningSubmix, float* AudioData, int32 NumSamples, int32 NumChannels, const int32 SampleRate, double AudioClock) 14 | { 15 | UE_LOG(LogTemp, Warning, TEXT("[%s]-NumSamples :{%d}-NumChannels-{%d} SampleRate -{%d} AudioClock -{%f}"), *FString(__FUNCTION__), NumSamples, NumChannels, SampleRate, AudioClock); 16 | 17 | } 18 | 19 | void ASceneVoice::BeginPlay() 20 | { 21 | Super::BeginPlay(); 22 | AudioDevice = GetWorld()->GetAudioDevice(); 23 | 24 | 25 | if (AudioDevice) 26 | { 27 | AudioDevice->RegisterSubmixBufferListener(this); 28 | } 29 | 30 | 31 | 32 | } 33 | 34 | void ASceneVoice::EndPlay(const EEndPlayReason::Type EndPlayReason) 35 | { 36 | if (AudioDevice) 37 | { 38 | AudioDevice->UnregisterSubmixBufferListener(this); 39 | } 40 | 41 | 42 | 43 | 44 | Super::EndPlay(EndPlayReason); 45 | } 46 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Algorithm/hmacsha256.cpp: -------------------------------------------------------------------------------- 1 | #include "Algorithm/hmacsha256.h" 2 | #include 3 | 4 | //#define ROR(n,k) ((n >> k) | (n << (32 - k))) 5 | 6 | static uint32_t ror(uint32_t n, uint32_t k) 7 | { 8 | return (n >> k) | (n << (32 - k)); 9 | } 10 | 11 | #define ROR(n,k) ror(n,k) 12 | 13 | #define CH(x,y,z) (z ^ (x & (y ^ z))) 14 | #define MAJ(x,y,z) ((x & y) | (z & (x | y))) 15 | #define S0(x) (ROR(x, 2) ^ ROR(x,13) ^ ROR(x,22)) 16 | #define S1(x) (ROR(x, 6) ^ ROR(x,11) ^ ROR(x,25)) 17 | #define R0(x) (ROR(x, 7) ^ ROR(x,18) ^ (x>>3)) 18 | #define R1(x) (ROR(x,17) ^ ROR(x,19) ^ (x>>10)) 19 | 20 | static const uint32_t K[64] = 21 | { 22 | 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 23 | 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 24 | 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 25 | 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 26 | 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 27 | 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 28 | 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 29 | 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 30 | }; 31 | 32 | static void sha256_transform(SHA256_CTX* s, const uint8_t* buf) 33 | { 34 | uint32_t t1, t2, a, b, c, d, e, f, g, h, m[64]; 35 | uint32_t i, j; 36 | 37 | for (i = 0, j = 0; i < 16; i++, j += 4) 38 | { 39 | m[i] = (uint32_t)buf[j] << 24 | (uint32_t)buf[j + 1] << 16 | 40 | (uint32_t)buf[j + 2] << 8 | (uint32_t)buf[j + 3]; 41 | } 42 | for (; i < 64; i++) 43 | { 44 | m[i] = R1(m[i - 2]) + m[i - 7] + R0(m[i - 15]) + m[i - 16]; 45 | } 46 | a = s->h[0]; 47 | b = s->h[1]; 48 | c = s->h[2]; 49 | d = s->h[3]; 50 | e = s->h[4]; 51 | f = s->h[5]; 52 | g = s->h[6]; 53 | h = s->h[7]; 54 | for (i = 0; i < 64; i++) 55 | { 56 | t1 = h + S1(e) + CH(e, f, g) + K[i] + m[i]; 57 | t2 = S0(a) + MAJ(a, b, c); 58 | h = g; 59 | g = f; 60 | f = e; 61 | e = d + t1; 62 | d = c; 63 | c = b; 64 | b = a; 65 | a = t1 + t2; 66 | } 67 | s->h[0] += a; 68 | s->h[1] += b; 69 | s->h[2] += c; 70 | s->h[3] += d; 71 | s->h[4] += e; 72 | s->h[5] += f; 73 | s->h[6] += g; 74 | s->h[7] += h; 75 | } 76 | 77 | void sha256_init(SHA256_CTX* s) 78 | { 79 | s->len = 0; 80 | 81 | s->h[0] = 0x6a09e667; 82 | s->h[1] = 0xbb67ae85; 83 | s->h[2] = 0x3c6ef372; 84 | s->h[3] = 0xa54ff53a; 85 | s->h[4] = 0x510e527f; 86 | s->h[5] = 0x9b05688c; 87 | s->h[6] = 0x1f83d9ab; 88 | s->h[7] = 0x5be0cd19; 89 | } 90 | 91 | void sha256_final(SHA256_CTX* s, uint8_t* md) 92 | { 93 | uint32_t r = s->len % SHA256_BLOCKLEN; 94 | int i; 95 | 96 | //pad 97 | s->buf[r++] = 0x80; 98 | if (r > 56) 99 | { 100 | memset(s->buf + r, 0, SHA256_BLOCKLEN - r); 101 | r = 0; 102 | sha256_transform(s, s->buf); 103 | } 104 | memset(s->buf + r, 0, 56 - r); 105 | s->len *= 8; 106 | s->buf[56] = s->len >> 56; 107 | s->buf[57] = s->len >> 48; 108 | s->buf[58] = s->len >> 40; 109 | s->buf[59] = s->len >> 32; 110 | s->buf[60] = s->len >> 24; 111 | s->buf[61] = s->len >> 16; 112 | s->buf[62] = s->len >> 8; 113 | s->buf[63] = s->len; 114 | sha256_transform(s, s->buf); 115 | 116 | for (i = 0; i < SHA256_DIGESTINT; i++) 117 | { 118 | md[4 * i] = s->h[i] >> 24; 119 | md[4 * i + 1] = s->h[i] >> 16; 120 | md[4 * i + 2] = s->h[i] >> 8; 121 | md[4 * i + 3] = s->h[i]; 122 | } 123 | sha256_init(s); 124 | } 125 | 126 | void sha256_update(SHA256_CTX* s, const uint8_t* m, uint32_t len) 127 | { 128 | const uint8_t* p = m; 129 | uint32_t r = s->len % SHA256_BLOCKLEN; 130 | 131 | s->len += len; 132 | if (r) 133 | { 134 | if (len + r < SHA256_BLOCKLEN) 135 | { 136 | memcpy(s->buf + r, p, len); 137 | return; 138 | } 139 | memcpy(s->buf + r, p, SHA256_BLOCKLEN - r); 140 | len -= SHA256_BLOCKLEN - r; 141 | p += SHA256_BLOCKLEN - r; 142 | sha256_transform(s, s->buf); 143 | } 144 | for (; len >= SHA256_BLOCKLEN; len -= SHA256_BLOCKLEN, p += SHA256_BLOCKLEN) 145 | { 146 | sha256_transform(s, p); 147 | } 148 | memcpy(s->buf, p, len); 149 | } 150 | 151 | #define INNER_PAD '\x36' 152 | #define OUTER_PAD '\x5c' 153 | 154 | void hmac_sha256_init(HMAC_SHA256_CTX* hmac, const uint8_t* key, uint32_t keylen) 155 | { 156 | SHA256_CTX* sha = &hmac->sha; 157 | uint32_t i; 158 | 159 | if (keylen <= SHA256_BLOCKLEN) 160 | { 161 | memcpy(hmac->buf, key, keylen); 162 | memset(hmac->buf + keylen, '\0', SHA256_BLOCKLEN - keylen); 163 | } 164 | else 165 | { 166 | sha256_init(sha); 167 | sha256_update(sha, key, keylen); 168 | sha256_final(sha, hmac->buf); 169 | memset(hmac->buf + SHA256_DIGESTLEN, '\0', SHA256_BLOCKLEN - SHA256_DIGESTLEN); 170 | } 171 | 172 | for (i = 0; i < SHA256_BLOCKLEN; i++) 173 | { 174 | hmac->buf[i] = hmac->buf[i] ^ OUTER_PAD; 175 | } 176 | 177 | sha256_init(sha); 178 | sha256_update(sha, hmac->buf, SHA256_BLOCKLEN); 179 | // copy outer state 180 | memcpy(hmac->h_outer, sha->h, SHA256_DIGESTLEN); 181 | 182 | for (i = 0; i < SHA256_BLOCKLEN; i++) 183 | { 184 | hmac->buf[i] = (hmac->buf[i] ^ OUTER_PAD) ^ INNER_PAD; 185 | } 186 | 187 | sha256_init(sha); 188 | sha256_update(sha, hmac->buf, SHA256_BLOCKLEN); 189 | // copy inner state 190 | memcpy(hmac->h_inner, sha->h, SHA256_DIGESTLEN); 191 | } 192 | 193 | void hmac_sha256_update(HMAC_SHA256_CTX* hmac, const uint8_t* m, uint32_t mlen) 194 | { 195 | sha256_update(&hmac->sha, m, mlen); 196 | } 197 | 198 | void hmac_sha256_final(HMAC_SHA256_CTX* hmac, uint8_t* md) 199 | { 200 | SHA256_CTX* sha = &hmac->sha; 201 | sha256_final(sha, md); 202 | 203 | // reset sha to outer state 204 | memcpy(sha->h, hmac->h_outer, SHA256_DIGESTLEN); 205 | sha->len = SHA256_BLOCKLEN; 206 | 207 | sha256_update(sha, md, SHA256_DIGESTLEN); 208 | sha256_final(sha, md); // md = D(outer || D(inner || msg)) 209 | 210 | // reset sha to inner state -> reset hmac 211 | memcpy(sha->h, hmac->h_inner, SHA256_DIGESTLEN); 212 | sha->len = SHA256_BLOCKLEN; 213 | } 214 | 215 | void pbkdf2_sha256(HMAC_SHA256_CTX* hmac, 216 | const uint8_t* key, uint32_t keylen, const uint8_t* salt, uint32_t saltlen, uint32_t rounds, 217 | uint8_t* dk, uint32_t dklen) 218 | { 219 | uint8_t* U; 220 | uint8_t* T; 221 | uint8_t count[4]; 222 | uint32_t i, j, k; 223 | uint32_t len; 224 | 225 | uint32_t hlen = SHA256_DIGESTLEN; 226 | uint32_t l = dklen / hlen + ((dklen % hlen) ? 1 : 0); 227 | uint32_t r = dklen - (l - 1) * hlen; 228 | 229 | hmac_sha256_init(hmac, key, keylen); 230 | 231 | U = hmac->buf; 232 | T = dk; 233 | 234 | len = hlen; 235 | for (i = 1; i <= l; i++) 236 | { 237 | if (i == l) { len = r; } 238 | count[0] = (i >> 24) & 0xFF; 239 | count[1] = (i >> 16) & 0xFF; 240 | count[2] = (i >> 8) & 0xFF; 241 | count[3] = (i) & 0xFF; 242 | hmac_sha256_update(hmac, salt, saltlen); 243 | hmac_sha256_update(hmac, count, 4); 244 | hmac_sha256_final(hmac, U); 245 | memcpy(T, U, len); 246 | for (j = 1; j < rounds; j++) 247 | { 248 | hmac_sha256_update(hmac, U, hlen); 249 | hmac_sha256_final(hmac, U); 250 | for (k = 0; k < len; k++) 251 | { 252 | T[k] ^= U[k]; 253 | } 254 | } 255 | T += len; 256 | } 257 | 258 | } 259 | 260 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Component/XGPlayVoiceComponent.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "XGPlayVoiceComponent.h" 3 | #include "XGAudioCaptureSubsystem.h" 4 | 5 | int32 UXGPlayVoiceComponent::OnGenerateAudio(float* OutAudio, int32 NumSamples) 6 | { 7 | int i = 0; 8 | int j = 0; 9 | for (; i < 1024;) 10 | { //1024 <= 2048 11 | //LLLLLLLL <=LRLRLRLRLRLR 12 | OutAudio[i] = UXGAudioCaptureSubsystem::InAudios[SoundIndex][j]; 13 | 14 | 15 | 16 | i++; 17 | j = j + 2; 18 | } 19 | 20 | SoundIndex++; 21 | 22 | return 1024; 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Component/XGSampleSynthComponent.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | 4 | #include "XGSampleSynthComponent.h" 5 | 6 | bool UXGSampleSynthComponent::Init(int32& SampleRate) 7 | { 8 | NumChannels = 1; 9 | 10 | #if SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 11 | // Initialize the DSP objects 12 | Osc.Init(SampleRate); 13 | Osc.SetFrequency(440.0f); 14 | Osc.Start(); 15 | #endif // SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 16 | 17 | return true; 18 | } 19 | 20 | int32 UXGSampleSynthComponent::OnGenerateAudio(float* OutAudio, int32 NumSamples) 21 | { 22 | #if SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 23 | // Perform DSP operations here 24 | for (int32 Sample = 0; Sample < NumSamples; ++Sample) 25 | { 26 | OutAudio[Sample] = Osc.Generate(); 27 | } 28 | #endif // SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 29 | 30 | return NumSamples; 31 | } 32 | 33 | void UXGSampleSynthComponent::SetFrequency(const float InFrequencyHz) 34 | { 35 | #if SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 36 | // Use this protected base class method to push a lambda function which will safely execute in the audio render thread. 37 | SynthCommand([this, InFrequencyHz]() 38 | { 39 | Osc.SetFrequency(InFrequencyHz); 40 | Osc.Update(); 41 | }); 42 | #endif // SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 43 | } -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Component/XGTTSPlayVoiceComponent.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Component/XGTTSPlayVoiceComponent.cpp -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Config/XGKeDaXunFeiSoundSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "XGKeDaXunFeiSoundSettings.h" -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Core/XGAudioCaptureSubsystem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Core/XGAudioCaptureSubsystem.cpp -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Core/XGKeDaXunFeiSocketSubsystem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Core/XGKeDaXunFeiSocketSubsystem.cpp -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Thread/ConsumeSoundRunnable.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "ConsumeSoundRunnable.h" 3 | #include "XGKeDaXunFeiSocketSubsystem.h" 4 | #include "XGAudioCaptureSubsystem.h" 5 | 6 | 7 | 8 | FCriticalSection FConsumeSoundRunnable::CriticalSection; 9 | bool FConsumeSoundRunnable::Init() 10 | { 11 | return true; 12 | } 13 | 14 | uint32 FConsumeSoundRunnable::Run() 15 | { 16 | while (true) 17 | { 18 | 19 | FScopeLock Lock(&CriticalSection); 20 | if (!bRunning) 21 | { 22 | break;; 23 | } 24 | Lock.Unlock(); 25 | FPlatformProcess::Sleep(0.04); 26 | 27 | 28 | 29 | FScopeLock DataLock(&UXGAudioCaptureSubsystem::XGAudioCriticalSection); 30 | if (UXGAudioCaptureSubsystem::AudioData.Num()>1024) 31 | { 32 | 33 | TArray SendData; 34 | SendData.Append(UXGAudioCaptureSubsystem::AudioData.GetData(), 1024); 35 | UXGAudioCaptureSubsystem::AudioData.RemoveAt(0, 1024); 36 | 37 | UXGKeDaXunFeiSocketSubsystem::SendVoiceData(SendData.GetData(), 1024); 38 | } 39 | 40 | } 41 | 42 | 43 | 44 | 45 | return 0; 46 | } 47 | 48 | void FConsumeSoundRunnable::Exit() 49 | { 50 | 51 | } 52 | 53 | void FConsumeSoundRunnable::Stop() 54 | { 55 | UE_LOG(LogTemp, Display, TEXT("FConsumeSoundRunnable[%s] begin to stop"), *MyThreadName); 56 | FScopeLock Lock(&CriticalSection); 57 | bRunning = false; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Type/XGRealTimeSpeechToTextRequestType.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGRealTimeSpeechToTextRequestType.h" 4 | #include "XGKeDaXunFeiSoundSettings.h" 5 | 6 | FString FXGRealTimeSpeechToTextRequestType::GenerateRequireParams() 7 | { 8 | FString RetStr=TEXT(""); 9 | 10 | FString AppID = UXGKeDaXunFeiSoundSettings::GetDataBaseSettings()->AppID; 11 | FString APIKey = UXGKeDaXunFeiSoundSettings::GetDataBaseSettings()->APIKeySTT; 12 | FString TS = FString::FromInt(FDateTime::Now().UtcNow().ToUnixTimestamp()); 13 | 14 | appid = AppID; 15 | 16 | ts = TS; 17 | 18 | signa = GenerateSigna(AppID, TS, APIKey); 19 | 20 | RetStr += TEXT("appid=") + appid; 21 | RetStr += TEXT("&ts=") + ts; 22 | RetStr += TEXT("&signa=") + signa; 23 | 24 | if (!lang.IsEmpty()) 25 | { 26 | RetStr += TEXT("&lang=") + lang; 27 | } 28 | 29 | if (bEnableTranslate) 30 | { 31 | RetStr += TEXT("&transType=") + transType; 32 | RetStr += TEXT("&transStrategy=") + FString::FromInt(transStrategy); 33 | RetStr += TEXT("&targetLang=") + targetLang; 34 | } 35 | 36 | if (!punc.IsEmpty()&&!punc.Equals(TEXT("None"))) 37 | { 38 | RetStr+= TEXT("&punc=") + punc; 39 | } 40 | 41 | 42 | if (!pd.IsEmpty()&& !pd.Equals(TEXT("None"))) 43 | { 44 | RetStr += TEXT("&pd=") + pd; 45 | } 46 | 47 | if (vadMdn!=-1) 48 | { 49 | RetStr += TEXT("&vadMdn=") + FString::FromInt(vadMdn); 50 | } 51 | 52 | 53 | if (roleType != -1) 54 | { 55 | RetStr += TEXT("&roleType=") + FString::FromInt(roleType); 56 | } 57 | 58 | 59 | 60 | if (engLangType != -1) 61 | { 62 | RetStr += TEXT("&engLangType=") + FString::FromInt(engLangType); 63 | } 64 | 65 | 66 | 67 | 68 | 69 | return RetStr; 70 | } 71 | 72 | FString FXGRealTimeSpeechToTextRequestType::GenerateSigna(const FString& InAppid, const FString& InTS, const FString& InAPIKey) 73 | { 74 | FString BaseString = InAppid+ InTS; 75 | FString MD5BaseString = FMD5::HashAnsiString(*BaseString); 76 | 77 | FSHAHash Hash; 78 | FSHA1 SHA1; 79 | SHA1.HMACBuffer(TCHAR_TO_ANSI(*InAPIKey), InAPIKey.Len(), TCHAR_TO_ANSI(*MD5BaseString), MD5BaseString.Len(), Hash.Hash); 80 | 81 | FString Signa = FBase64::Encode(Hash.Hash, 20); 82 | Signa.ReplaceInline(TEXT("="), TEXT("%3D")); 83 | 84 | return Signa; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/Type/XGRealTimeSpeechToTextResponseType.cpp: -------------------------------------------------------------------------------- 1 | #include "XGRealTimeSpeechToTextResponseType.h" -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/XGKeDaXunFeiSound.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGKeDaXunFeiSound.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FXGKeDaXunFeiSoundModule" 6 | 7 | void FXGKeDaXunFeiSoundModule::StartupModule() 8 | { 9 | 10 | 11 | } 12 | 13 | void FXGKeDaXunFeiSoundModule::ShutdownModule() 14 | { 15 | 16 | 17 | } 18 | 19 | #undef LOCTEXT_NAMESPACE 20 | 21 | IMPLEMENT_MODULE(FXGKeDaXunFeiSoundModule, XGKeDaXunFeiSound) -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Private/XGKeDaXunFeiSoundBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGKeDaXunFeiSoundBPLibrary.h" 4 | #include "XGKeDaXunFeiSound.h" 5 | #include "XGKeDaXunFeiSocketSubsystem.h" 6 | #include "Kismet/GameplayStatics.h" 7 | 8 | UXGKeDaXunFeiSoundBPLibrary::UXGKeDaXunFeiSoundBPLibrary(const FObjectInitializer& ObjectInitializer) 9 | : Super(ObjectInitializer) 10 | { 11 | 12 | } 13 | 14 | void UXGKeDaXunFeiSoundBPLibrary::XGBeginSpeachToText(const UObject* WorldContextObject, FXGBeginSpeachToTextDelegate XGBeginSpeachToTextDelegate, FXGSpeachToTextDelegate XGSpeachToTextDelegat) 15 | { 16 | if (!WorldContextObject) 17 | { 18 | return; 19 | } 20 | UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); 21 | UXGKeDaXunFeiSocketSubsystem* SocketSystem = GameInstance->GetSubsystem(); 22 | 23 | SocketSystem->XGBeginSpeachToText(XGBeginSpeachToTextDelegate, XGSpeachToTextDelegat); 24 | 25 | } 26 | 27 | void UXGKeDaXunFeiSoundBPLibrary::XGStopSpeachToText(const UObject* WorldContextObject) 28 | { 29 | 30 | FString ChineseTest1 = TEXT("你好"); 31 | 32 | if (!WorldContextObject) 33 | { 34 | return; 35 | } 36 | UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); 37 | UXGKeDaXunFeiSocketSubsystem* SocketSystem = GameInstance->GetSubsystem(); 38 | SocketSystem->XGStopSpeachToText(); 39 | 40 | } 41 | 42 | void UXGKeDaXunFeiSoundBPLibrary::XGBeginSpeachToTextFullConfig(const UObject* WorldContextObject, 43 | const FXGRealTimeSpeechToTextRequestType& InXGRealTimeSpeechToTextType, 44 | FXGBeginSpeachToTextDelegate XGBeginSpeachToTextDelegate, 45 | FXGSpeachToTextDelegate XGSpeachToTextDelegat, 46 | FXGSpeachToTextWithoutTranslateDelegate XGSpeachToTextWithoutTranslateDelegate 47 | ) 48 | { 49 | 50 | if (!WorldContextObject) 51 | { 52 | return; 53 | } 54 | UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); 55 | UXGKeDaXunFeiSocketSubsystem* SocketSystem = GameInstance->GetSubsystem(); 56 | 57 | SocketSystem->XGBeginSpeachToTextConfig(InXGRealTimeSpeechToTextType, 58 | XGBeginSpeachToTextDelegate, 59 | XGSpeachToTextDelegat, 60 | XGSpeachToTextWithoutTranslateDelegate 61 | ); 62 | 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Actor/SceneVoice.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include 6 | #include "SceneVoice.generated.h" 7 | 8 | 9 | 10 | UCLASS() 11 | class ASceneVoice :public AActor, public ISubmixBufferListener 12 | { 13 | GENERATED_BODY() 14 | 15 | public : 16 | ASceneVoice(); 17 | 18 | 19 | public: 20 | 21 | virtual void OnNewSubmixBuffer(const USoundSubmix* OwningSubmix, float* AudioData, int32 NumSamples, int32 NumChannels, const int32 SampleRate, double AudioClock) override; 22 | 23 | 24 | 25 | 26 | protected: 27 | void BeginPlay() override; 28 | 29 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 30 | 31 | 32 | 33 | protected: 34 | FAudioDeviceHandle AudioDevice; 35 | 36 | 37 | }; -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Algorithm/hmacsha256.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _HMAC_SHA_256_H_ 4 | #define _HMAC_SHA_256_H_ 5 | 6 | #define SHA256_BLOCKLEN 64ul //size of message block buffer 7 | #define SHA256_DIGESTLEN 32ul //size of digest in uint8_t 8 | #define SHA256_DIGESTINT 8ul //size of digest in uint32_t 9 | 10 | // #ifndef PBKDF2_SHA256_STATIC 11 | // #define PBKDF2_SHA256_DEF extern 12 | // #else 13 | // #define PBKDF2_SHA256_DEF static 14 | // #endif 15 | 16 | #include 17 | 18 | 19 | typedef struct sha256_ctx_t 20 | { 21 | uint64_t len; // processed message length 22 | uint32_t h[SHA256_DIGESTINT]; // hash state 23 | uint8_t buf[SHA256_BLOCKLEN]; // message block buffer 24 | } SHA256_CTX; 25 | 26 | void sha256_init(SHA256_CTX* ctx); 27 | void sha256_update(SHA256_CTX* ctx, const uint8_t* m, uint32_t mlen); 28 | // resets state: calls sha256_init 29 | void sha256_final(SHA256_CTX* ctx, uint8_t* md); 30 | 31 | typedef struct hmac_sha256_ctx_t 32 | { 33 | uint8_t buf[SHA256_BLOCKLEN]; // key block buffer, not needed after init 34 | uint32_t h_inner[SHA256_DIGESTINT]; 35 | uint32_t h_outer[SHA256_DIGESTINT]; 36 | SHA256_CTX sha; 37 | } HMAC_SHA256_CTX; 38 | 39 | void hmac_sha256_init(HMAC_SHA256_CTX* hmac, const uint8_t* key, uint32_t keylen); 40 | void hmac_sha256_update(HMAC_SHA256_CTX* hmac, const uint8_t* m, uint32_t mlen); 41 | void hmac_sha256_final(HMAC_SHA256_CTX* hmac, uint8_t* md); 42 | 43 | void pbkdf2_sha256(HMAC_SHA256_CTX* ctx, const uint8_t* key, uint32_t keylen, const uint8_t* salt, uint32_t saltlen, uint32_t rounds, uint8_t* dk, uint32_t dklen); 44 | 45 | #endif // _HMAC_SHA_256_H_ 46 | 47 | 48 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Component/XGPlayVoiceComponent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "Components/SynthComponent.h" 6 | #include "XGPlayVoiceComponent.generated.h" 7 | 8 | 9 | UCLASS(ClassGroup = Synth, meta = (BlueprintSpawnableComponent)) 10 | class XGKEDAXUNFEISOUND_API UXGPlayVoiceComponent : public USynthComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | 15 | 16 | // Called to generate more audio 17 | virtual int32 OnGenerateAudio(float* OutAudio, int32 NumSamples) override; 18 | 19 | int32 SoundIndex = 0; 20 | 21 | }; -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Component/XGSampleSynthComponent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Components/SynthComponent.h" 7 | #include "DSP/Osc.h" 8 | #include "XGSampleSynthComponent.generated.h" 9 | 10 | // ======================================================================== 11 | // UXGSampleSynthComponent 12 | // Synth component class which implements USynthComponent 13 | // This is a simple hello-world type example which generates a sine-wave 14 | // tone using a DSP oscillator class and implements a single function to set 15 | // the frequency. To enable example: 16 | // 1. Ensure "SignalProcessing" is added to project's .Build.cs in PrivateDependencyModuleNames 17 | // 2. Enable macro below that includes code utilizing SignalProcessing Oscilator 18 | // ======================================================================== 19 | 20 | #define SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 1 21 | 22 | UCLASS(ClassGroup = Synth, meta = (BlueprintSpawnableComponent)) 23 | class XGKEDAXUNFEISOUND_API UXGSampleSynthComponent : public USynthComponent 24 | { 25 | GENERATED_BODY() 26 | 27 | // Called when synth is created 28 | virtual bool Init(int32& SampleRate) override; 29 | 30 | // Called to generate more audio 31 | virtual int32 OnGenerateAudio(float* OutAudio, int32 NumSamples) override; 32 | 33 | // Sets the oscillator's frequency 34 | UFUNCTION(BlueprintCallable, Category = "Synth|Components|Audio") 35 | void SetFrequency(const float FrequencyHz = 440.0f); 36 | 37 | protected: 38 | #if SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 39 | // A simple oscillator class. Can also generate Saw/Square/Tri/Noise. 40 | Audio::FOsc Osc; 41 | #endif // SYNTHCOMPONENT_EX_OSCILATOR_ENABLED 42 | }; -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Component/XGTTSPlayVoiceComponent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "Components/SynthComponent.h" 6 | #include "XGTTSPlayVoiceComponent.generated.h" 7 | 8 | 9 | UCLASS(ClassGroup = Synth, meta = (BlueprintSpawnableComponent)) 10 | class XGKEDAXUNFEISOUND_API UXGTTSPlayVoiceComponent : public USynthComponent 11 | { 12 | GENERATED_BODY() 13 | 14 | // Called when synth is created 15 | virtual bool Init(int32& SampleRate) override; 16 | 17 | 18 | 19 | // Called to generate more audio 20 | virtual int32 OnGenerateAudio(float* OutAudio, int32 NumSamples) override; 21 | 22 | 23 | public: 24 | 25 | 26 | 27 | protected: 28 | int32 PlayIndex=0; 29 | 30 | }; -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Config/XGKeDaXunFeiSoundSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "XGKeDaXunFeiSoundSettings.generated.h" 6 | 7 | 8 | UCLASS(Config = XGKeDaXunFeiSound, defaultconfig) 9 | class UXGKeDaXunFeiSoundSettings : public UDeveloperSettings 10 | { 11 | GENERATED_BODY() 12 | 13 | public: 14 | 15 | /** Gets the settings container name for the settings, either Project or Editor */ 16 | virtual FName GetContainerName() const override { return TEXT("Project"); } 17 | /** Gets the category for the settings, some high level grouping like, Editor, Engine, Game...etc. */ 18 | virtual FName GetCategoryName() const override { return TEXT("XGPlugins"); } 19 | /** The unique name for your section of settings, uses the class's FName. */ 20 | virtual FName GetSectionName() const override { return TEXT("UXGKeDaXunFeiSoundSettings"); } 21 | 22 | 23 | public: 24 | UPROPERTY(Config, EditAnywhere, BlueprintReadWrite,Category="General") 25 | FString AppID; 26 | 27 | UPROPERTY(Config, EditAnywhere, BlueprintReadWrite,Category="Real Time Speech To Text") 28 | FString APIKeySTT; 29 | 30 | UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "Text To Speech Stream") 31 | FString APIKeyTTSStream; 32 | 33 | UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "Text To Speech Stream") 34 | FString APISecretTTSStream; 35 | 36 | public: 37 | 38 | UFUNCTION(BlueprintCallable) 39 | static UXGKeDaXunFeiSoundSettings* GetDataBaseSettings() 40 | { 41 | UXGKeDaXunFeiSoundSettings* Settings = GetMutableDefault(); 42 | return Settings; 43 | 44 | } 45 | 46 | 47 | }; -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Core/XGAudioCaptureSubsystem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Core/XGAudioCaptureSubsystem.h -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Core/XGKeDaXunFeiSocketSubsystem.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Subsystems/GameInstanceSubsystem.h" 7 | #include 8 | #include "Thread/ConsumeSoundRunnable.h" 9 | #include "XGKeDaXunFeiSoundBPLibrary.h" 10 | #include "XGRealTimeSpeechToTextRequestType.h" 11 | #include "XGKeDaXunFeiSocketSubsystem.generated.h" 12 | 13 | class UXGAudioCaptureSubsystem; 14 | /** 15 | * 16 | */ 17 | UCLASS() 18 | class XGKEDAXUNFEISOUND_API UXGKeDaXunFeiSocketSubsystem : public UGameInstanceSubsystem, public FTickableGameObject 19 | { 20 | 21 | GENERATED_BODY() 22 | public: 23 | 24 | virtual bool ShouldCreateSubsystem(UObject* Outer) const override; 25 | virtual void Initialize(FSubsystemCollectionBase& Collection)override; 26 | virtual void Deinitialize()override; 27 | 28 | public: 29 | virtual void Tick(float DeltaTime) override; 30 | virtual bool IsTickable() const override; 31 | virtual TStatId GetStatId() const override; 32 | 33 | 34 | public: 35 | void XGBeginSpeachToText(FXGBeginSpeachToTextDelegate InXGBeginSpeachToTextDelegate, FXGSpeachToTextDelegate InXGSpeachToTextDelegat); 36 | void XGBeginSpeachToTextConfig(FXGRealTimeSpeechToTextRequestType InXGRealTimeSpeechToTextType, 37 | FXGBeginSpeachToTextDelegate InXGBeginSpeachToTextDelegate, 38 | FXGSpeachToTextDelegate InXGSpeachToTextDelegat, 39 | FXGSpeachToTextWithoutTranslateDelegate InXGSpeachToTextWithoutTranslateDelegate = FXGSpeachToTextWithoutTranslateDelegate() 40 | ); 41 | 42 | void XGStopSpeachToText(); 43 | 44 | 45 | public: 46 | UFUNCTION(BlueprintCallable) 47 | void CreateSocket(); 48 | UFUNCTION(BlueprintCallable) 49 | void CloseSocket(); 50 | 51 | 52 | public: 53 | 54 | static void SendVoiceData(const float* InAudio, int32 NumSamples); 55 | static void EndSendVoiceData(); 56 | 57 | UFUNCTION(BlueprintCallable) 58 | void StopSenVoiceData(); 59 | 60 | protected: 61 | 62 | void OnConnected(); 63 | void OnConnectionError(const FString& Error); 64 | void OnClosed(int32 StatusCode, const FString& Reason, bool bWasClean); 65 | void OnMessage(const FString& Message); 66 | void OnMessageSent(const FString& MessageString); 67 | 68 | void OnMessageFullConfig(const FString& Message); 69 | 70 | 71 | protected: 72 | static TSharedPtr Socket ; 73 | FString ServerURL = TEXT(""); 74 | FString ServerProtocol = TEXT(""); 75 | 76 | FString Appid; 77 | FString APIKey; 78 | 79 | static bool bSending ; 80 | 81 | 82 | bool bSpeechToText = false; 83 | FXGBeginSpeachToTextDelegate XGBeginSpeachToTextDelegate; 84 | FXGSpeachToTextDelegate XGSpeachToTextDelegate; 85 | FXGSpeachToTextWithoutTranslateDelegate XGSpeachToTextWithoutTranslateDelegate; 86 | 87 | TSharedPtr< FConsumeSoundRunnable> VoiceRunnable; 88 | public: 89 | static UXGAudioCaptureSubsystem* XGAudioCaptureSubsystem; 90 | }; 91 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Core/XGTTSSubsystem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Core/XGTTSSubsystem.h -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Thread/ConsumeSoundRunnable.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "HAL/Runnable.h" 6 | 7 | class FConsumeSoundRunnable :public FRunnable 8 | { 9 | public: 10 | FConsumeSoundRunnable(FString ThreadName) :MyThreadName(ThreadName) 11 | { 12 | 13 | } 14 | 15 | virtual bool Init() override; 16 | virtual uint32 Run() override; 17 | virtual void Exit() override; 18 | virtual void Stop() override; 19 | 20 | FString MyThreadName; 21 | 22 | 23 | 24 | 25 | static FCriticalSection CriticalSection; 26 | protected: 27 | bool bRunning = true; 28 | 29 | }; -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Type/XGRealTimeSpeechToTextRequestType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | 5 | #include "XGRealTimeSpeechToTextRequestType.generated.h" 6 | 7 | 8 | /** 9 | * 科大讯飞实时语音转写官方文档 10 | * https://www.xfyun.cn/doc/asr/rtasr/API.html#%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8%E6%B5%81%E7%A8%8B 11 | * 12 | * 13 | * 14 | */ 15 | USTRUCT(BlueprintType) 16 | struct FXGRealTimeSpeechToTextRequestType 17 | { 18 | GENERATED_BODY() 19 | 20 | //UPROPERTY(EditAnywhere, Category = "Plant Settings", meta = (EditCondition = "bEnableFloorInterpolation", DisplayAfter = "bEnableFloorInterpolation")) 21 | 22 | protected: 23 | 24 | /** 25 | * 参数:appid 26 | * 类型:string 27 | * 必须:是 28 | * 说明:讯飞开放平台应用ID 29 | * 示例:5f9c6d6a 30 | */ 31 | UPROPERTY() 32 | FString appid; 33 | 34 | /** 35 | * 参数:ts 36 | * 类型:string 37 | * 必须:是 38 | * 说明:当前时间戳,从1970年1月1日0点0分0秒开始到现在的秒数 39 | * 示例:1512041814 40 | */ 41 | UPROPERTY() 42 | FString ts; 43 | 44 | /** 45 | * 参数:signa 46 | * 类型:string 47 | * 必须:是 48 | * 说明:加密数字签名(基于HMACSHA1算法) 49 | * 示例:IrrzsJeOFk1NGfJHW6SkHUoN9CU= 50 | */ 51 | UPROPERTY() 52 | FString signa; 53 | 54 | public: 55 | 56 | /** 57 | * 参数:lang 58 | * 类型:string 59 | * 必须:否 60 | * 说明:实时语音转写语种,不传默认为中文 61 | * 示例: 62 | * 语种类型:中文、中英混合识别:cn; 63 | * 英文:en; 64 | * 小语种及方言可到控制台-实时语音转写-方言/语种处添加,添加后会显示该方言/语种参数值。传参示例如:"lang=en" 65 | * 若未授权无法使用会报错10110 66 | */ 67 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 68 | FString lang=TEXT("cn"); 69 | 70 | 71 | 72 | /** 73 | * 自定义字段 是否开启翻译功能 74 | * 需要在科大讯飞控制台开通翻译功能 75 | */ 76 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 77 | bool bEnableTranslate=false; 78 | 79 | 80 | /** 81 | * 参数:transType 82 | * 类型:string 83 | * 必须:否 84 | * 说明:normal表示普通翻译,默认值normal; 85 | * 示例: 例如:transType="normal" 86 | * 注意:需控制台开通翻译功能 87 | */ 88 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 89 | FString transType=TEXT("normal"); 90 | 91 | /** 92 | * 参数:transType 93 | * 类型:int 94 | * 必须:否 95 | * 说明: 策略1,转写的vad结果直接送去翻译; 96 | * 策略2,返回中间过程中的结果; 97 | * 策略3,按照结束性标点拆分转写结果请求翻译; 98 | * 建议使用策略2 99 | * 示例: 例如:transStrategy=2 100 | * 注意:需控制台开通翻译功能 101 | */ 102 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 103 | int32 transStrategy=2; 104 | 105 | 106 | /** 107 | * 参数:targetLang 108 | * 类型:string 109 | * 必须:否 110 | * 说明: 111 | * 目标翻译语种:控制把源语言转换成什么类型的语言; 112 | * 请注意类似英文转成法语必须以中文为过渡语言,即英-中-法,暂不支持不含中文语种之间的直接转换; 113 | * 中文:cn 114 | * 英文:en 115 | * 日语:ja 116 | * 韩语:ko 117 | * 俄语:ru 118 | * 法语:fr 119 | * 西班牙语:es 120 | * 越南语:vi 121 | * 广东话:cn_cantonese 122 | * 示例: 123 | * 例如:targetLang="en" 124 | * 如果使用中文实时翻译为英文传参示例如下: 125 | * "&lang=cn&transType=normal&transStrategy=2&targetLang=en" 126 | * 注意:需控制台开通翻译功能 127 | */ 128 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 129 | FString targetLang=TEXT("en"); 130 | 131 | /** 132 | * 参数:punc 133 | * 类型:string 134 | * 必须:否 135 | * 说明: 标点过滤控制,默认返回标点,punc=0会过滤结果中的标点 136 | * 示例: 0 137 | */ 138 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 139 | FString punc=TEXT("None"); 140 | 141 | /** 142 | * 参数:pd 143 | * 类型:string 144 | * 必须:否 145 | * 说明: 146 | * 垂直领域个性化参数: 147 | * 法院: court 148 | * 教育: edu 149 | * 金融: finance 150 | * 医疗: medical 151 | * 科技: tech 152 | * 运营商: isp 153 | * 政府: gov 154 | * 电商: ecom 155 | * 军事: mil 156 | * 企业: com 157 | * 生活: life 158 | * 汽车: car 159 | * 示例: 160 | * 设置示例:pd="edu" 161 | * 参数pd为非必须设置,不设置参数默认为通用 162 | */ 163 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 164 | FString pd=TEXT("None"); 165 | 166 | 167 | /** 168 | * 参数:vadMdn 169 | * 类型:int 170 | * 必须:否 171 | * 说明: 远近场切换,不传此参数或传1代表远场,传2代表近场 172 | * 示例: 设置示例:vadMdn=2 173 | */ 174 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 175 | int32 vadMdn=-1; 176 | 177 | /** 178 | * 参数:roleType 179 | * 类型:int 180 | * 必须:否 181 | * 说明: 是否开角色分离,默认不开启,传2开启(效果持续优化中) 182 | * 示例: 设置示例:roleType=2 183 | */ 184 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 185 | int32 roleType=-1; 186 | 187 | /** 188 | * 参数:engLangType 189 | * 类型:int 190 | * 必须:否 191 | * 说明: 192 | * 语言识别模式选,默认为模式1中英文模式: 193 | * 1:自动中英文模式 194 | * 2:中文模式,可能包含少量英文 195 | * 4:纯中文模式,不包含英文 196 | * 示例: 设置示例:engLangType=4 197 | */ 198 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG RealTime STT") 199 | int32 engLangType=-1; 200 | 201 | public: 202 | 203 | FString GenerateRequireParams(); 204 | 205 | protected: 206 | 207 | FString GenerateSigna(const FString& InAppid, const FString& InTS, const FString& InAPIKey); 208 | 209 | }; 210 | 211 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Type/XGRealTimeSpeechToTextResponseType.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/Type/XGRealTimeSpeechToTextResponseType.h -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/XGKeDaXunFeiSound.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | 7 | class FXGKeDaXunFeiSoundModule : public IModuleInterface 8 | { 9 | public: 10 | 11 | 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/Public/XGKeDaXunFeiSoundBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) XiaoGang.2023.All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Kismet/BlueprintFunctionLibrary.h" 6 | #include "XGRealTimeSpeechToTextRequestType.h" 7 | #include "XGKeDaXunFeiSoundBPLibrary.generated.h" 8 | 9 | 10 | DECLARE_DYNAMIC_DELEGATE_OneParam(FXGBeginSpeachToTextDelegate,bool,bBeginSpeachToText); 11 | 12 | DECLARE_DYNAMIC_DELEGATE_OneParam(FXGSpeachToTextWithoutTranslateDelegate, FString, OutSrcText); 13 | 14 | DECLARE_DYNAMIC_DELEGATE_TwoParams(FXGSpeachToTextDelegate, FString, OutSrcText,FString, OutDstText); 15 | 16 | 17 | UCLASS() 18 | class UXGKeDaXunFeiSoundBPLibrary : public UBlueprintFunctionLibrary 19 | { 20 | GENERATED_UCLASS_BODY() 21 | 22 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "BeginSpeachToText", Keywords = "KeDaXunFei ", WorldContext = "WorldContextObject"), Category = "XGKeDaXunFeiSoundTesting") 23 | static void XGBeginSpeachToText(const UObject* WorldContextObject, FXGBeginSpeachToTextDelegate XGBeginSpeachToTextDelegate, FXGSpeachToTextDelegate XGSpeachToTextDelegat); 24 | 25 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "StopSpeachToText", Keywords = "KeDaXunFei ", WorldContext = "WorldContextObject"), Category = "XGKeDaXunFeiSoundTesting") 26 | static void XGStopSpeachToText(const UObject* WorldContextObject); 27 | 28 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "BeginSpeachToTextFullConfig", Keywords = "KeDaXunFei ", WorldContext = "WorldContextObject"), Category = "XGKeDaXunFeiSoundTesting") 29 | static void XGBeginSpeachToTextFullConfig(const UObject* WorldContextObject, 30 | const FXGRealTimeSpeechToTextRequestType& InXGRealTimeSpeechToTextType, 31 | FXGBeginSpeachToTextDelegate XGBeginSpeachToTextDelegate, 32 | FXGSpeachToTextDelegate XGSpeachToTextDelegat, 33 | FXGSpeachToTextWithoutTranslateDelegate XGSpeachToTextWithoutTranslateDelegate 34 | ); 35 | 36 | 37 | 38 | 39 | }; 40 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/Source/XGKeDaXunFeiSound/XGKeDaXunFeiSound.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class XGKeDaXunFeiSound : ModuleRules 6 | { 7 | public XGKeDaXunFeiSound(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicIncludePaths.AddRange( 12 | new string[] { 13 | "$(ModuleDir)/Public/Type" 14 | 15 | 16 | 17 | } 18 | ); 19 | 20 | 21 | PrivateIncludePaths.AddRange( 22 | new string[] { 23 | 24 | "XGKeDaXunFeiSound/Public/Actor", 25 | "XGKeDaXunFeiSound/Public/Algorithm", 26 | "XGKeDaXunFeiSound/Public/Algorithm", 27 | "XGKeDaXunFeiSound/Public/Component", 28 | "XGKeDaXunFeiSound/Public/Config", 29 | "XGKeDaXunFeiSound/Public/Core", 30 | "XGKeDaXunFeiSound/Public/Thread", 31 | "XGKeDaXunFeiSound/Public/Type", 32 | 33 | 34 | } 35 | ); 36 | 37 | 38 | PublicDependencyModuleNames.AddRange( 39 | new string[] 40 | { 41 | "Core", 42 | 43 | } 44 | ); 45 | 46 | 47 | PrivateDependencyModuleNames.AddRange( 48 | new string[] 49 | { 50 | "CoreUObject", 51 | "Engine", 52 | "Slate", 53 | "SlateCore", 54 | "WebSockets", 55 | "AudioMixer", 56 | "SignalProcessing", 57 | "AudioCapture", 58 | "Json", 59 | "DeveloperSettings", 60 | "JsonUtilities", 61 | "AudioCapture", 62 | "AudioCaptureEditor", 63 | "AudioCaptureRtAudio" 64 | 65 | 66 | } 67 | ); 68 | 69 | 70 | DynamicallyLoadedModuleNames.AddRange( 71 | new string[] 72 | { 73 | 74 | } 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/XGKeDaXunFeiSound.uplugin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGKeDaXunFeiSound-v1.0-Test(测试代码,千万别用)/XGKeDaXunFeiSound.uplugin -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Config/FilterPlugin.ini: -------------------------------------------------------------------------------- 1 | [FilterPlugin] 2 | ; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and 3 | ; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. 4 | ; 5 | ; Examples: 6 | ; /README.txt 7 | ; /Extras/... 8 | ; /Binaries/ThirdParty/*.dll 9 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Resources/Icon128.png -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/ThirdParty/XGXunFeiBase/Private/XGXunFeiBase.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiBase.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FXGXunFeiBaseModule" 6 | 7 | void FXGXunFeiBaseModule::StartupModule() 8 | { 9 | 10 | 11 | } 12 | 13 | void FXGXunFeiBaseModule::ShutdownModule() 14 | { 15 | 16 | 17 | } 18 | 19 | #undef LOCTEXT_NAMESPACE 20 | 21 | IMPLEMENT_MODULE(FXGXunFeiBaseModule, XGXunFeiBase) -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/ThirdParty/XGXunFeiBase/Private/XGXunFeiBaseLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiBaseLibrary.h" 4 | 5 | #if WITH_SSL 6 | #include 7 | #include 8 | #include 9 | #endif 10 | 11 | FXGXunFeiBaseSHA256 FXGXunFeiBaseLibrary::HmacSha256(const uint8* Input, size_t InputLen, const uint8* Key, size_t KeyLen) 12 | { 13 | FXGXunFeiBaseSHA256 Output; 14 | unsigned int OutputLen = 0; 15 | HMAC(EVP_sha256(), Key, KeyLen, (const unsigned char*)Input, InputLen, Output.Digest, &OutputLen); 16 | return Output; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/ThirdParty/XGXunFeiBase/Public/XGXunFeiBase.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | /** 7 | * XGXunFeiBaseModule 8 | */ 9 | class FXGXunFeiBaseModule : public IModuleInterface 10 | { 11 | public: 12 | 13 | virtual void StartupModule() override; 14 | 15 | virtual void ShutdownModule() override; 16 | 17 | }; 18 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/ThirdParty/XGXunFeiBase/Public/XGXunFeiBaseLibrary.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | #include "CoreMinimal.h" 5 | 6 | /** 7 | * XGXunFeiBaseSHA256 8 | * Save the result after HmacSha256 encryption 9 | */ 10 | struct XGXUNFEIBASE_API FXGXunFeiBaseSHA256 11 | { 12 | uint8 Digest[32]; 13 | 14 | }; 15 | /** 16 | * FXGXunFeiBaseLibrary 17 | * Exposed to XGXunFeiCore to use encryption method 18 | */ 19 | class XGXUNFEIBASE_API FXGXunFeiBaseLibrary 20 | { 21 | public: 22 | 23 | /** 24 | * HmacSha256 25 | * 26 | * @param Input Input What you want to encrypt data ptr. 27 | * @param InputLen The lenth of data. 28 | * @param Key The Key ptr which you want to encrypt data with. 29 | * @param KeyLen The lenth of the key. 30 | * @return FXGXunFeiBaseSHA256 Encryption Resulte 31 | */ 32 | static FXGXunFeiBaseSHA256 HmacSha256(const uint8* Input, size_t InputLen, const uint8* Key, size_t KeyLen); 33 | 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/ThirdParty/XGXunFeiBase/XGXunFeiBase.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class XGXunFeiBase : ModuleRules 6 | { 7 | protected virtual bool bPlatformSupportsSSL 8 | { 9 | get 10 | { 11 | return 12 | Target.Platform == UnrealTargetPlatform.Mac || 13 | Target.Platform == UnrealTargetPlatform.Win64 || 14 | Target.IsInPlatformGroup(UnrealPlatformGroup.Unix) || 15 | Target.Platform == UnrealTargetPlatform.IOS || 16 | Target.Platform == UnrealTargetPlatform.Android; 17 | } 18 | } 19 | 20 | protected virtual bool bUseDefaultSSLCert 21 | { 22 | get 23 | { 24 | return 25 | Target.Platform == UnrealTargetPlatform.Mac || 26 | Target.Platform == UnrealTargetPlatform.IOS; 27 | } 28 | } 29 | 30 | 31 | 32 | public XGXunFeiBase(ReadOnlyTargetRules Target) : base(Target) 33 | { 34 | PublicDefinitions.Add("SSL_PACKAGE=1"); 35 | 36 | PrivateDependencyModuleNames.AddRange( 37 | new string[] { 38 | "Core", 39 | } 40 | ); 41 | 42 | if (bPlatformSupportsSSL) 43 | { 44 | PublicDefinitions.Add("WITH_SSL=1"); 45 | PrivateDefinitions.Add("USE_DEFAULT_SSLCERT=" + (bUseDefaultSSLCert ? "1" : "0")); 46 | 47 | AddEngineThirdPartyPrivateStaticDependencies(Target, "OpenSSL"); 48 | 49 | } 50 | else 51 | { 52 | PublicDefinitions.Add("WITH_SSL=0"); 53 | } 54 | 55 | UnsafeTypeCastWarningLevel = WarningLevel.Error; 56 | 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Private/AsyncAction/XGXunFeiCoreAsyncAction.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiCoreAsyncAction.h" 4 | #include "Async/Async.h" 5 | #include "Async/TaskGraphInterfaces.h" 6 | UXGXunFeiCoreAsyncAction::UXGXunFeiCoreAsyncAction(const FObjectInitializer& ObjectInitializer) 7 | :Super(ObjectInitializer), 8 | AsyncID(FGuid::NewGuid()) 9 | { 10 | 11 | 12 | } 13 | 14 | void UXGXunFeiCoreAsyncAction::Activate() 15 | { 16 | Super::Activate(); 17 | 18 | AsyncTask(ENamedThreads::GameThread, [this]() { 19 | 20 | this->Activate_Internal(); 21 | 22 | }); 23 | 24 | } 25 | 26 | void UXGXunFeiCoreAsyncAction::Activate_Internal() 27 | { 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Private/Config/XGXunFeiCoreSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiCoreSettings.h" 4 | #include "Interfaces/IPluginManager.h" 5 | #include "PluginDescriptor.h" 6 | 7 | 8 | UXGXunFeiCoreSettings::UXGXunFeiCoreSettings(const FObjectInitializer& ObjectInitializer) 9 | :Super(ObjectInitializer) 10 | { 11 | 12 | IPluginManager& PluginManager = IPluginManager::Get(); 13 | 14 | TSharedPtr PluginPtr = PluginManager.FindPlugin(TEXT("XGXunFeiLink")); 15 | 16 | if (PluginPtr.IsValid()) 17 | { 18 | FPluginDescriptor PluginDescriptor = PluginPtr->GetDescriptor(); 19 | PluginVersion = PluginDescriptor.VersionName; 20 | } 21 | 22 | 23 | 24 | ASRG.FunctionName = TEXT("ASRG"); 25 | ASRG.MethodName = TEXT("XunFeiBeginRealTimeASRGlobal and XGXunFeiStopAutomatedSpeechRecognitionGlobal"); 26 | ASRG.Description = TEXT("Real-time ASR based on the deep fully convolutional neural network framework (DFCNN), converting audio stream data (within 5 hours) into text stream data results in real-time. It provides a basis for information processing and data mining, which is more suitable for daily dialogue."); 27 | ASRG.WebURL = TEXT("https://global.xfyun.cn/doc/rtasr/rtasr/API.html"); 28 | ASRG.bGlobal = true; 29 | 30 | TTSG.FunctionName = TEXT("TTSG"); 31 | TTSG.MethodName = TEXT("XGXunFeiTextToSpeechGlobal"); 32 | TTSG.Description = TEXT("The stream interface for Online TTS converts text information into acoustic information, and provides a number of distinctive speakers (acoustic library) for you to choose from. Click here to experience the speech effect online. This function is a common interface provided to developers through Websocket API. Websocket API can achieve streaming, applicable to AI service scenarios that require streaming data transmission. Compared to SDK, API is featured as lightweight and cross-language; compared to the HTTP API, the Websocket API protocol has the advantage of natively supporting cross-domain."); 33 | TTSG.WebURL = TEXT("https://global.xfyun.cn/doc/tts/online_tts/API.html"); 34 | TTSG.bGlobal = true; 35 | 36 | STT.FunctionName = TEXT("STT"); 37 | STT.MethodName = TEXT("XunFeiBeginRealTimeSpeechToText and XunFeiStopRealTimeSpeechToText"); 38 | STT.Description = TEXT(""); 39 | STT.WebURL = TEXT("https://www.xfyun.cn/doc/asr/rtasr/API.html"); 40 | 41 | TTS.FunctionName = TEXT("TTS"); 42 | TTS.MethodName = TEXT("XunFeiTextToSpeech"); 43 | TTS.Description = TEXT(""); 44 | TTS.WebURL = TEXT("https://www.xfyun.cn/doc/tts/online_tts/API.html"); 45 | 46 | Spark.FunctionName = TEXT("Spark"); 47 | Spark.MethodName = TEXT("XunFeiSpark"); 48 | Spark.Description = TEXT(""); 49 | Spark.WebURL = TEXT("https://www.xfyun.cn/doc/spark/Web.html"); 50 | 51 | SparkHelper.FunctionName = TEXT("SparkHelper"); 52 | SparkHelper.MethodName = TEXT("XunFeiSparkHelper"); 53 | SparkHelper.Description = TEXT(""); 54 | SparkHelper.WebURL = TEXT("https://www.xfyun.cn/doc/spark/SparkAssistantAPI.html"); 55 | 56 | SparkHint.FunctionName = TEXT("SparkHint"); 57 | SparkHint.MethodName = TEXT("XunFeiSparkHint"); 58 | SparkHint.Description = TEXT(""); 59 | SparkHint.WebURL = TEXT("https://www.xfyun.cn/doc/spark/%E6%98%9F%E7%81%AB%E5%BE%AE%E8%B0%83%E6%9C%8D%E5%8A%A1Web%E6%96%87%E6%A1%A3.html"); 60 | 61 | SparkV3FunctionCall.FunctionName = TEXT("SparkV3FunctionCall"); 62 | SparkV3FunctionCall.MethodName = TEXT("XGXunFeiSparkV3FunctionCall"); 63 | SparkV3FunctionCall.Description = TEXT(""); 64 | SparkV3FunctionCall.WebURL = TEXT("https://www.xfyun.cn/doc/spark/Web.html"); 65 | 66 | ImgUnderstand.FunctionName = TEXT("ImgUnderstand"); 67 | ImgUnderstand.MethodName = TEXT("XunFeiSparkImgUnderstand,XunFeiLoadPitcureFileToBinaryData"); 68 | ImgUnderstand.Description = TEXT(""); 69 | ImgUnderstand.WebURL = TEXT("https://www.xfyun.cn/doc/spark/ImageUnderstanding.html"); 70 | 71 | 72 | 73 | } 74 | 75 | UXGXunFeiCoreSettings::~UXGXunFeiCoreSettings() 76 | { 77 | } 78 | 79 | FName UXGXunFeiCoreSettings::GetContainerName() const 80 | { 81 | return TEXT("Project"); 82 | } 83 | 84 | FName UXGXunFeiCoreSettings::GetCategoryName() const 85 | { 86 | return TEXT("XGPlugins"); 87 | } 88 | FName UXGXunFeiCoreSettings::GetSectionName() const 89 | { 90 | return TEXT("XunFeiCoreSettings"); 91 | } 92 | 93 | 94 | UXGXunFeiCoreSettings* UXGXunFeiCoreSettings::GetXGXunFeiCoreSettings() 95 | { 96 | UXGXunFeiCoreSettings* Settings = GetMutableDefault(); 97 | 98 | return Settings; 99 | 100 | } 101 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Private/Type/XGXunFeiCoreWaveType.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "XGXunFeiCoreWaveType.h" -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Private/XGXunFeiCore.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiCore.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FXGXunFeiCoreModule" 6 | 7 | void FXGXunFeiCoreModule::StartupModule() 8 | { 9 | 10 | 11 | } 12 | 13 | void FXGXunFeiCoreModule::ShutdownModule() 14 | { 15 | 16 | 17 | } 18 | 19 | #undef LOCTEXT_NAMESPACE 20 | 21 | IMPLEMENT_MODULE(FXGXunFeiCoreModule, XGXunFeiCore) -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Private/XGXunFeiCoreBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiCoreBPLibrary.h" 4 | 5 | #include "Sound/SoundWaveProcedural.h" 6 | #include "Misc/Base64.h" 7 | #include "Misc/Paths.h" 8 | #include "Misc/FileHelper.h" 9 | #include "Runtime/Launch/Resources/Version.h" 10 | #include "UObject/Package.h" 11 | #include "UObject/ObjectMacros.h" 12 | #include "Memory/SharedBuffer.h" 13 | 14 | 15 | 16 | 17 | #include "XGXunFeiBaseLibrary.h" 18 | #include "XGXunFeiCoreWaveType.h" 19 | 20 | FString UXGXunFeiCoreBPLibrary::XunFeiTTSHMACSHA256(const FString& InAPPSecreet, const FString& InData) 21 | { 22 | 23 | //uint8_t* secret = (uint8_t*)TCHAR_TO_UTF8(*InAPPSecreet); 24 | //uint8_t* indata = (uint8_t*)TCHAR_TO_UTF8(*InData); 25 | 26 | int len1 = strlen((char*)TCHAR_TO_UTF8(*InAPPSecreet)); 27 | int len2 = strlen((char*)TCHAR_TO_UTF8(*InData)); 28 | 29 | FXGXunFeiBaseSHA256 XunFeiBaseSHA256 = FXGXunFeiBaseLibrary::HmacSha256((uint8_t*)TCHAR_TO_UTF8(*InData), len2, (uint8_t*)TCHAR_TO_UTF8(*InAPPSecreet), len1); 30 | 31 | FString RetStr = TEXT(""); 32 | 33 | RetStr = FBase64::Encode(XunFeiBaseSHA256.Digest, 32); 34 | 35 | return RetStr; 36 | 37 | } 38 | 39 | void UXGXunFeiCoreBPLibrary::ConvertPCMToWave(const TArray& InPCMData, TArray& OutWaveData) 40 | { 41 | OutWaveData.Empty(); 42 | FXGXunFeiWaveHeard WaveHeard; 43 | FXGXunFeiWaveFmt WaveFmt; 44 | FXGXunFeiWaveData WaveData; 45 | 46 | FMemory::Memcpy(WaveHeard.ChunkID, "RIFF", strlen("RIFF")); 47 | FMemory::Memcpy(WaveHeard.Format, "WAVE", strlen("WAVE")); 48 | WaveHeard.ChunkSize = 36 + InPCMData.Num() * sizeof(uint8); 49 | 50 | FMemory::Memcpy(WaveFmt.SubChunkID, "fmt ", strlen("fmt ")); 51 | WaveFmt.SubChunkSize = 16; 52 | WaveFmt.AudioFormat = 1; 53 | WaveFmt.NumChannel = 1; 54 | WaveFmt.SampleRate = 16000; 55 | WaveFmt.BitsForSample = 16; 56 | WaveFmt.ByteRate = 16000 * 1 * 16 / 8; 57 | WaveFmt.BlockAlign = 1 * 16 / 8; 58 | 59 | FMemory::Memcpy(WaveData.DataChunkID, "data", strlen("data")); 60 | WaveData.DataChunkSize = InPCMData.Num() * sizeof(uint8); 61 | 62 | 63 | OutWaveData.AddUninitialized(sizeof(FXGXunFeiWaveHeard)); 64 | FMemory::Memcpy(OutWaveData.GetData(), &WaveHeard, sizeof(FXGXunFeiWaveHeard)); 65 | 66 | 67 | int32 Index = OutWaveData.AddUninitialized(sizeof(FXGXunFeiWaveFmt)); 68 | FMemory::Memcpy(&OutWaveData[Index], &WaveFmt, sizeof(FXGXunFeiWaveFmt)); 69 | 70 | 71 | Index = OutWaveData.AddUninitialized(sizeof(FXGXunFeiWaveData)); 72 | FMemory::Memcpy(&OutWaveData[Index], &WaveData, sizeof(FXGXunFeiWaveData)); 73 | 74 | 75 | OutWaveData.Append(InPCMData); 76 | 77 | 78 | 79 | } 80 | 81 | USoundWave* UXGXunFeiCoreBPLibrary::ImportPCMToSoundWave(const TArray& InPCMData) 82 | { 83 | const int32 ChannelCount = 1; 84 | 85 | const int32 SizeOfSample = 16 / 8; 86 | const int32 NumSamples = InPCMData.Num() / SizeOfSample; 87 | 88 | const int32 NumFrames = NumSamples / ChannelCount; 89 | 90 | const int32 SampleDataSize = InPCMData.Num(); 91 | 92 | FString SoundWaveName = TEXT("XGSoundWave:") + FGuid::NewGuid().ToString(); 93 | 94 | USoundWave* SoundWave = NewObject < USoundWave>(GetTransientPackage(), *SoundWaveName, RF_Public | RF_Standalone); 95 | 96 | 97 | 98 | #if WITH_EDITOR&& ENGINE_MINOR_VERSION > 0 99 | 100 | TArray WavData; 101 | ConvertPCMToWave(InPCMData, WavData); 102 | 103 | SoundWave->RawData.UpdatePayload(FSharedBuffer::Clone(WavData.GetData(), WavData.Num())); 104 | #endif 105 | 106 | 107 | SoundWave->RawPCMData = (uint8*)FMemory::Malloc(SampleDataSize); 108 | 109 | FMemory::Memcpy(SoundWave->RawPCMData, InPCMData.GetData(), SampleDataSize); 110 | 111 | SoundWave->RawPCMDataSize = SampleDataSize; 112 | 113 | // Set Sound Wave Info 114 | SoundWave->Duration = (float)NumFrames / 16000.f; 115 | SoundWave->SetSampleRate(16000.f); 116 | SoundWave->NumChannels = ChannelCount; 117 | SoundWave->TotalSamples = NumFrames; 118 | 119 | 120 | 121 | 122 | return SoundWave; 123 | } 124 | 125 | bool UXGXunFeiCoreBPLibrary::LoadPitcureFileToBinaryData(const FString& InAbsoluteFilePath, TArray& OutImgBinaryData) 126 | { 127 | if (FPaths::FileExists(InAbsoluteFilePath)) 128 | { 129 | OutImgBinaryData.Empty(); 130 | return FFileHelper::LoadFileToArray(OutImgBinaryData, *InAbsoluteFilePath); 131 | } 132 | 133 | 134 | 135 | return false; 136 | } 137 | 138 | void UXGXunFeiCoreBPLibrary::AssembleAuthUrl(FString IniFlyTekURL, FString InAPISecret, FString InAPIKey, FString& OutAuthURL, FString& OutProtocol, bool bGet) 139 | { 140 | 141 | TArray URLParts; 142 | 143 | IniFlyTekURL.ParseIntoArray(URLParts, TEXT("/"), true); 144 | 145 | FString URLDomain = URLParts[1]; 146 | 147 | FString URLPath = TEXT(""); 148 | 149 | for (int32 Index = 0; Index < URLParts.Num(); Index++) 150 | { 151 | if (Index > 1) 152 | { 153 | URLPath += TEXT("/"); 154 | URLPath += URLParts[Index]; 155 | 156 | } 157 | 158 | } 159 | 160 | 161 | FString host = TEXT("host: ") + URLDomain + TEXT("\n"); 162 | 163 | FString HttpDate = FDateTime::Now().UtcNow().ToHttpDate(); 164 | 165 | FString date = TEXT("date: ") + HttpDate + TEXT("\n"); 166 | 167 | FString requireLine = TEXT(""); 168 | if (bGet) 169 | { 170 | requireLine = TEXT("GET ") + URLPath + TEXT(" HTTP/1.1"); 171 | } 172 | else 173 | { 174 | requireLine = TEXT("POST ") + URLPath + TEXT(" HTTP/1.1"); 175 | } 176 | 177 | FString signature_origin = host + date + requireLine; 178 | 179 | FString signature = XunFeiTTSHMACSHA256(InAPISecret, signature_origin); 180 | 181 | FString authorization_origin = 182 | FString::Printf(TEXT("api_key=\"%s\", algorithm=\"hmac-sha256\", headers=\"host date request-line\", signature=\"%s\""), *InAPIKey, *signature); 183 | 184 | FString authorization = FBase64::Encode(authorization_origin); 185 | 186 | OutProtocol = URLParts[0].Replace(TEXT(":"), TEXT("")); 187 | 188 | OutAuthURL = IniFlyTekURL + FString::Printf(TEXT("?authorization=%s&date=%s&host=%s"), *authorization, *URLEncode(HttpDate), *URLDomain); 189 | 190 | 191 | 192 | } 193 | 194 | void UXGXunFeiCoreBPLibrary::AssembleAuthUrl(FString IniFlyTekURL, FString InAPISecret, FString InAPIKey, FString& OutAuthURL, FString& OutProtocol, TMap& OutUpgradeHeaders) 195 | { 196 | OutUpgradeHeaders.Empty(); 197 | 198 | TArray URLParts; 199 | 200 | IniFlyTekURL.ParseIntoArray(URLParts, TEXT("/"), true); 201 | 202 | FString URLDomain = URLParts[1]; 203 | 204 | FString URLPath = TEXT(""); 205 | 206 | for (int32 Index = 0; Index < URLParts.Num(); Index++) 207 | { 208 | if (Index > 1) 209 | { 210 | URLPath += TEXT("/"); 211 | URLPath += URLParts[Index]; 212 | 213 | } 214 | 215 | } 216 | 217 | 218 | FString host = TEXT("host: ") + URLDomain + TEXT("\n"); 219 | 220 | FString HttpDate = FDateTime::Now().UtcNow().ToHttpDate(); 221 | 222 | FString date = TEXT("date: ") + HttpDate + TEXT("\n"); 223 | 224 | FString requireLine = TEXT("GET ") + URLPath + TEXT(" HTTP/1.1"); 225 | 226 | FString signature_origin = host + date + requireLine; 227 | 228 | FString signature = XunFeiTTSHMACSHA256(InAPISecret, signature_origin); 229 | 230 | FString authorization_origin = 231 | FString::Printf(TEXT("api_key=\"%s\", algorithm=\"hmac-sha256\", headers=\"host date request-line\", signature=\"%s\""), *InAPIKey, *signature); 232 | 233 | FString authorization = FBase64::Encode(authorization_origin); 234 | 235 | OutProtocol = URLParts[0].Replace(TEXT(":"), TEXT("")); 236 | 237 | OutAuthURL = IniFlyTekURL + FString::Printf(TEXT("?authorization=%s&date=%s&host=%s"), *authorization, *URLEncode(HttpDate), *URLDomain); 238 | 239 | 240 | OutUpgradeHeaders.Add(TEXT("authorization"), authorization); 241 | OutUpgradeHeaders.Add(TEXT("date"), URLEncode(HttpDate)); 242 | OutUpgradeHeaders.Add(TEXT("host"), URLDomain); 243 | } 244 | FString UXGXunFeiCoreBPLibrary::URLEncode(FString InURL) 245 | { 246 | InURL.ReplaceInline(TEXT("%"), TEXT("%25")); 247 | InURL.ReplaceInline(TEXT("+"), TEXT("%2B")); 248 | InURL.ReplaceInline(TEXT(" "), TEXT("%20")); 249 | InURL.ReplaceInline(TEXT("/"), TEXT("%2F")); 250 | InURL.ReplaceInline(TEXT("?"), TEXT("%3F")); 251 | InURL.ReplaceInline(TEXT("#"), TEXT("%23")); 252 | InURL.ReplaceInline(TEXT("&"), TEXT("%26")); 253 | InURL.ReplaceInline(TEXT("="), TEXT("%3D")); 254 | InURL.ReplaceInline(TEXT(":"), TEXT("%3A")); 255 | InURL.ReplaceInline(TEXT(","), TEXT("%2C")); 256 | 257 | return InURL; 258 | } 259 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Public/AsyncAction/XGXunFeiCoreAsyncAction.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Kismet/BlueprintAsyncActionBase.h" 6 | #include "XGXunFeiCoreAsyncAction.generated.h" 7 | 8 | 9 | UCLASS() 10 | class XGXUNFEICORE_API UXGXunFeiCoreAsyncAction : public UBlueprintAsyncActionBase 11 | { 12 | GENERATED_BODY() 13 | 14 | 15 | public: 16 | 17 | UXGXunFeiCoreAsyncAction(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); 18 | 19 | virtual void Activate() override ; 20 | 21 | 22 | virtual void Activate_Internal() ; 23 | 24 | public: 25 | 26 | FGuid AsyncID; 27 | }; -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Public/Config/XGXunFeiCoreSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Engine/DeveloperSettings.h" 7 | #include "XGXunFeiCoreSettings.generated.h" 8 | 9 | 10 | USTRUCT(BlueprintType) 11 | struct FXunFeiFunctionDescriber 12 | { 13 | GENERATED_USTRUCT_BODY() 14 | 15 | public: 16 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Base") 17 | FString FunctionName = TEXT("None"); 18 | 19 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Base") 20 | FString MethodName = TEXT("None"); 21 | 22 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Base") 23 | FString Description = TEXT("None"); 24 | 25 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "URL") 26 | FString WebURL = TEXT("None"); 27 | 28 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Region") 29 | bool bGlobal = false; 30 | 31 | 32 | }; 33 | 34 | 35 | 36 | 37 | /** 38 | * UXGXunFeiCoreSettings 39 | * Input iFlyTek App Information 40 | */ 41 | UCLASS(Config = XGXunFeiCoreSettings, defaultconfig) 42 | class XGXUNFEICORE_API UXGXunFeiCoreSettings : public UDeveloperSettings 43 | { 44 | GENERATED_BODY() 45 | 46 | public: 47 | 48 | UXGXunFeiCoreSettings(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); 49 | 50 | virtual ~UXGXunFeiCoreSettings(); 51 | 52 | virtual FName GetContainerName() const override; 53 | 54 | virtual FName GetCategoryName() const override; 55 | 56 | virtual FName GetSectionName() const override; 57 | 58 | public: 59 | 60 | static UXGXunFeiCoreSettings* GetXGXunFeiCoreSettings(); 61 | 62 | public: 63 | 64 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 65 | FString PluginVersion = TEXT(""); 66 | 67 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 68 | bool bSupportASRG = false; 69 | 70 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 71 | bool bSupportTTSG = false; 72 | 73 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 74 | bool bSupportSTT = true; 75 | 76 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 77 | bool bSupportTTS = true; 78 | 79 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 80 | bool bSupportSpark = false; 81 | 82 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 83 | bool bSupportSparkHelper = false; 84 | 85 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 86 | bool bSupportSparkHint = false; 87 | 88 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 89 | bool bSupportSparkV3FunctionCall = false; 90 | 91 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkInfo") 92 | bool bSupportImgUnderstand = false; 93 | 94 | 95 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction") 96 | FXunFeiFunctionDescriber ASRG; 97 | 98 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction") 99 | FXunFeiFunctionDescriber TTSG; 100 | 101 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction") 102 | FXunFeiFunctionDescriber STT; 103 | 104 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction") 105 | FXunFeiFunctionDescriber TTS; 106 | 107 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction|Spark") 108 | FXunFeiFunctionDescriber Spark; 109 | 110 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction|Spark") 111 | FXunFeiFunctionDescriber SparkHelper; 112 | 113 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction|Spark") 114 | FXunFeiFunctionDescriber SparkHint; 115 | 116 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction|Spark") 117 | FXunFeiFunctionDescriber SparkV3FunctionCall; 118 | 119 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "XunFeiLinkFunction|Spark") 120 | FXunFeiFunctionDescriber ImgUnderstand; 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | }; -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Public/Type/XGXunFeiCoreWaveType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | 8 | /** 9 | * FXGXunFeiWaveHeard 10 | * 11 | */ 12 | struct FXGXunFeiWaveHeard 13 | { 14 | 15 | int8 ChunkID[4]; 16 | 17 | uint32 ChunkSize; 18 | 19 | int8 Format[4]; 20 | }; 21 | 22 | /** 23 | * FXGXunFeiWaveFmt 24 | * 25 | */ 26 | struct FXGXunFeiWaveFmt 27 | { 28 | 29 | int8 SubChunkID[4]; 30 | 31 | uint32 SubChunkSize; 32 | 33 | uint16 AudioFormat; 34 | 35 | uint16 NumChannel; 36 | 37 | uint32 SampleRate; 38 | 39 | uint32 ByteRate; 40 | 41 | uint16 BlockAlign; 42 | 43 | uint16 BitsForSample; 44 | 45 | 46 | 47 | }; 48 | 49 | /** 50 | * FXGXunFeiWaveData 51 | * 52 | */ 53 | struct FXGXunFeiWaveData 54 | { 55 | 56 | int8 DataChunkID[4]; 57 | 58 | uint32 DataChunkSize; 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Public/XGXunFeiCore.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | /** 7 | * FXGXunFeiCoreModule 8 | */ 9 | class FXGXunFeiCoreModule : public IModuleInterface 10 | { 11 | public: 12 | 13 | 14 | virtual void StartupModule() override; 15 | 16 | virtual void ShutdownModule() override; 17 | 18 | }; 19 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/Public/XGXunFeiCoreBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | #include "XGXunFeiCoreBPLibrary.generated.h" 8 | 9 | 10 | class USoundWave; 11 | /** 12 | * UXGXunFeiCoreBPLibrary. 13 | * Exposed for OtherModule to use. 14 | * Highly customizable,Do not use it. 15 | */ 16 | UCLASS() 17 | class XGXUNFEICORE_API UXGXunFeiCoreBPLibrary : public UBlueprintFunctionLibrary 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | 23 | static FString XunFeiTTSHMACSHA256(const FString& InAPPSecreet, const FString& InData); 24 | 25 | static void ConvertPCMToWave(const TArray& InPCMData, TArray& OutWaveData); 26 | 27 | static USoundWave* ImportPCMToSoundWave(const TArray& InPCMData); 28 | 29 | static bool LoadPitcureFileToBinaryData(const FString& InAbsoluteFilePath,TArray& OutImgBinaryData); 30 | 31 | static void AssembleAuthUrl(FString IniFlyTekURL, FString InAPISecret, FString InAPIKey, FString& OutAuthURL, FString& OutProtocol, bool bGet = true); 32 | 33 | static void AssembleAuthUrl(FString IniFlyTekURL, FString InAPISecret, FString InAPIKey, FString& OutAuthURL, FString& OutProtocol, TMap& OutUpgradeHeaders); 34 | 35 | static FString URLEncode(FString InURL); 36 | }; 37 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiCore/XGXunFeiCore.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class XGXunFeiCore : ModuleRules 7 | { 8 | public XGXunFeiCore(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 11 | 12 | PublicIncludePaths.AddRange( 13 | new string[] { 14 | "$(ModuleDir)/Public/AsyncAction", 15 | "$(ModuleDir)/Public/Config", 16 | } 17 | ); 18 | 19 | 20 | PrivateIncludePaths.AddRange( 21 | new string[] { 22 | "XGXunFeiCore/Public/AsyncAction", 23 | "XGXunFeiCore/Public/Config", 24 | "XGXunFeiCore/Public/Type" 25 | } 26 | ); 27 | 28 | 29 | PublicDependencyModuleNames.AddRange( 30 | new string[] 31 | { 32 | "Core", 33 | 34 | } 35 | ); 36 | 37 | 38 | PrivateDependencyModuleNames.AddRange( 39 | new string[] 40 | { 41 | "CoreUObject", 42 | "Engine", 43 | "DeveloperSettings", 44 | "XGXunFeiBase", 45 | "Projects" 46 | } 47 | ); 48 | 49 | if (Target.Platform == UnrealTargetPlatform.Android) 50 | { 51 | PrivateDependencyModuleNames.AddRange( 52 | new string[] 53 | { 54 | "Launch", 55 | } 56 | ); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiLink/Private/XGXunFeiLink.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiLink.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FXGXunFeiLinkModule" 6 | 7 | void FXGXunFeiLinkModule::StartupModule() 8 | { 9 | 10 | 11 | } 12 | 13 | void FXGXunFeiLinkModule::ShutdownModule() 14 | { 15 | 16 | 17 | } 18 | 19 | #undef LOCTEXT_NAMESPACE 20 | 21 | IMPLEMENT_MODULE(FXGXunFeiLinkModule, XGXunFeiLink) -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiLink/Private/XGXunFeiLinkBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiLinkBPLibrary.h" 4 | 5 | #include "XGXunFeiRealTimeSTTSubsystem.h" 6 | 7 | #include "Kismet/GameplayStatics.h" 8 | #include "Engine/GameInstance.h" 9 | #include "Async/Async.h" 10 | #include "XGXunFeiCoreBPLibrary.h" 11 | 12 | 13 | void UXGXunFeiLinkBPLibrary::XGXunFeiBeginRealTimeSpeechToText(const UObject* WorldContextObject, 14 | FString InSTTAppID, 15 | FString InSTTAPIKey, 16 | FXGXunFeiRealTimeSTTReqInfo InRealTimeSTTReqInfo, 17 | FXGXunFeiInitRealTimeSTTDelegate InRealTimeSTTInitDelegate, 18 | FXGXunFeiRealTimeSTTRespDelegate InRealTimeSTTRespDelegate, 19 | FXGXunFeiRealTimeSTTCloseDelegate InRealTimeSTTCloseDelegate, 20 | FGuid& OutSTTAsyncID) 21 | { 22 | if (WorldContextObject && WorldContextObject->GetWorld()) 23 | { 24 | UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); 25 | UXGXunFeiRealTimeSTTSubsystem* RealTimeSTTSubsystem = GameInstance->GetSubsystem(); 26 | 27 | OutSTTAsyncID = RealTimeSTTSubsystem->XGBeginRealTimeSpeechToText( 28 | InSTTAppID, 29 | InSTTAPIKey, 30 | InRealTimeSTTReqInfo, 31 | InRealTimeSTTInitDelegate, 32 | InRealTimeSTTRespDelegate, 33 | InRealTimeSTTCloseDelegate); 34 | 35 | } 36 | else 37 | { 38 | OutSTTAsyncID = FGuid::NewGuid(); 39 | 40 | AsyncTask(ENamedThreads::GameThread, [InRealTimeSTTInitDelegate, OutSTTAsyncID]() { 41 | 42 | InRealTimeSTTInitDelegate.ExecuteIfBound(OutSTTAsyncID, false, TEXT("WorldContextObject is null"), FXGXunFeiRealTimeSTTInitInformation()); 43 | 44 | }); 45 | 46 | 47 | 48 | } 49 | 50 | 51 | } 52 | 53 | void UXGXunFeiLinkBPLibrary::XGXunFeiStopRealTimeSpeechToText(const UObject* WorldContextObject) 54 | { 55 | if (WorldContextObject && WorldContextObject->GetWorld()) 56 | { 57 | UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); 58 | UXGXunFeiRealTimeSTTSubsystem* RealTimeSTTSubsystem = GameInstance->GetSubsystem(); 59 | RealTimeSTTSubsystem->XGStopRealTimeSpeechToText(); 60 | 61 | } 62 | else 63 | { 64 | 65 | } 66 | 67 | } 68 | 69 | FGuid UXGXunFeiLinkBPLibrary::XGXunFeiTextToSpeech( 70 | UObject* WorldContextObject, 71 | FString InTTSAppID, 72 | FString InTTSAPISecret, 73 | FString InTTSAPIKey, 74 | const FString& InText, 75 | bool bInSaveToLocal, 76 | const FString& InSaveFileFullPath, 77 | FXGXunFeiTTSReqInfo InXunFeiTTSReqInfo, 78 | FXGXunFeiTTSDelegate OnXunFeiTTSSoundWaveSuccess, 79 | FXGXunFeiTTSDelegate OnXunFeiTTSSoundWaveFail, 80 | FXGXunFeiTTSDelegate OnXunFeiTTSWavFileSuccess, 81 | FXGXunFeiTTSDelegate OnXunFeiTTSWavFileFail) 82 | { 83 | if (!WorldContextObject || !WorldContextObject->GetWorld()) 84 | { 85 | OnXunFeiTTSSoundWaveFail.Broadcast(FGuid(), false, TEXT("WorldContextObject is null"), nullptr); 86 | return FGuid(); 87 | } 88 | 89 | UXGXunFeiTTSAsyncAction* XGXunFeiTTSAsyncAction = UXGXunFeiTTSAsyncAction::XGXunFeiTextToSpeech(WorldContextObject, 90 | InTTSAppID, InTTSAPISecret, InTTSAPIKey, InText, bInSaveToLocal, InSaveFileFullPath, InXunFeiTTSReqInfo); 91 | 92 | XGXunFeiTTSAsyncAction->OnSoundWaveSuccess = OnXunFeiTTSSoundWaveSuccess; 93 | XGXunFeiTTSAsyncAction->OnSoundWaveFail = OnXunFeiTTSSoundWaveFail; 94 | XGXunFeiTTSAsyncAction->OnWavFileSuccess = OnXunFeiTTSWavFileSuccess; 95 | XGXunFeiTTSAsyncAction->OnWavFileFail = OnXunFeiTTSWavFileFail; 96 | 97 | 98 | XGXunFeiTTSAsyncAction->Activate(); 99 | 100 | return XGXunFeiTTSAsyncAction->AsyncID; 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiLink/Public/XGXunFeiLink.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | /** 7 | * FXGXunFeiLinkModule 8 | */ 9 | class FXGXunFeiLinkModule : public IModuleInterface 10 | { 11 | public: 12 | 13 | 14 | virtual void StartupModule() override; 15 | virtual void ShutdownModule() override; 16 | }; 17 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiLink/Public/XGXunFeiLinkBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Kismet/BlueprintFunctionLibrary.h" 6 | 7 | 8 | 9 | 10 | 11 | #include "XGXunFeiRealTimeSTTReqType.h" 12 | #include "XGXunFeiRealTimeSTTType.h" 13 | 14 | #include "XGXunFeiTTSAsyncAction.h" 15 | #include "XGXunFeiTTSReqType.h" 16 | 17 | 18 | #include "XGXunFeiLinkBPLibrary.generated.h" 19 | 20 | 21 | 22 | 23 | 24 | class USoundWave; 25 | /** 26 | * UXGXunFeiLinkBPLibrary 27 | * Exposed to users. 28 | * You can use these methods. 29 | */ 30 | UCLASS() 31 | class XGXUNFEILINK_API UXGXunFeiLinkBPLibrary : public UBlueprintFunctionLibrary 32 | { 33 | GENERATED_BODY() 34 | 35 | public: 36 | 37 | 38 | 39 | 40 | /** 41 | * XunFeiBeginRealTimeSpeechToText 42 | * If your app ID supports to translage and you open it in this plugin.More to look XunFeiDoc. 43 | * @param WorldContextObject WorldContext 44 | 45 | * @param InSTTAppID iFlyTek AppID 46 | * @param InSTTAPIKey iFlyTek APIKey 47 | * 48 | * @param InRealTimeSTTReqInfo RealTimeSpeechToTextSettings,you can do nothing to keep default. 49 | * Default lanaguge is Chinese,you can change to Chinese to Enginsh,such as "cn"->"en". Default No Translate,just Src.if you need to translate,you need to open it function in XunFei web. 50 | * 51 | * @param InInitRealTimeSTTDelegate Tell you whether to success to create socket to XunFei and begin to audio capture. 52 | * if your app key and id are not right,you will fail.if your audio input device is not good,you will fail. 53 | * Suggest audio input [48000 kHz,16 bits, 2 channle][48000 kHz,16 bits, 1 channle][16000 kHz,16 bits, 1 channle],thest can work well. 54 | * 55 | * @param InRealTimeSTTRespDelegate Give you the response info 56 | * @param InRealTimeSTTCloseDelegate If it stops normally,It will call you.If you force to stop,there will be no callback. 57 | * 58 | * @param OutSTTAsyncID The STTAsyncID 59 | * 60 | * 61 | */ 62 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "XunFeiBeginRealTimeSpeechToText", WorldContext = "WorldContextObject", 63 | Keywords = "XG XunFei STT Soeech To Text RealTime Begin"), Category = "XGXunFeiLink|STT|RealTimeSTT") 64 | static void XGXunFeiBeginRealTimeSpeechToText(const UObject* WorldContextObject, 65 | FString InSTTAppID, 66 | FString InSTTAPIKey, 67 | FXGXunFeiRealTimeSTTReqInfo InRealTimeSTTReqInfo, 68 | FXGXunFeiInitRealTimeSTTDelegate InRealTimeSTTInitDelegate, 69 | FXGXunFeiRealTimeSTTRespDelegate InRealTimeSTTRespDelegate, 70 | FXGXunFeiRealTimeSTTCloseDelegate InRealTimeSTTCloseDelegate, 71 | FGuid& OutSTTAsyncID); 72 | 73 | 74 | /** 75 | * 76 | * XunFeiStopRealTimeSpeechToText 77 | * 78 | * @param WorldContextObject WorldContext 79 | */ 80 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "XunFeiStopRealTimeSpeechToText", WorldContext = "WorldContextObject", 81 | Keywords = "XG XunFei STT SPeech To Text "), Category = "XGXunFeiLink|STT") 82 | static void XGXunFeiStopRealTimeSpeechToText(const UObject* WorldContextObject); 83 | 84 | 85 | /** 86 | * XGXunFeiTextToSpeech 87 | * 88 | * @param WorldContextObject WorldContext 89 | * 90 | * @param InTTSAppID iFlyTek AppID 91 | * @param InTTSAPISecret iFlyTek APISecret 92 | * @param InTTSAPIKey iFlyTek APIKey 93 | * 94 | * @param InText The Str you want to Convert to Audio 95 | * @param bInSaveToLocal Whether to Save to local disk 96 | * @param InSaveFileFullPath The FilePath which the wmv file will save to . 97 | * This directory must exist,and the file name must end with ".wav" 98 | * This path is absoult path! 99 | * @param InXunFeiTTSReqInfo About TTS Settins,more to look iflytesk document.you can choos which voice to say,and so on. 100 | * 101 | * @param OnXunFeiTTSSoundWaveSuccess If it succeeds ,you will get USoundWave. 102 | * @param OnXunFeiTTSSoundWaveFail If it fails,you will get reasons. 103 | * @param OnXunFeiTTSWavFileSuccess If it succeeds ,you will get sound file. 104 | * @param OnXunFeiTTSWavFileFail If it fails,you will get reasons. 105 | * 106 | * 107 | * @return FGuid The AsyncID. 108 | */ 109 | static FGuid XGXunFeiTextToSpeech(UObject* WorldContextObject, 110 | FString InTTSAppID, 111 | FString InTTSAPISecret, 112 | FString InTTSAPIKey, 113 | const FString& InText, 114 | bool bInSaveToLocal, 115 | const FString& InSaveFileFullPath, 116 | FXGXunFeiTTSReqInfo InXunFeiTTSReqInfo, 117 | FXGXunFeiTTSDelegate OnXunFeiTTSSoundWaveSuccess, 118 | FXGXunFeiTTSDelegate OnXunFeiTTSSoundWaveFail, 119 | FXGXunFeiTTSDelegate OnXunFeiTTSWavFileSuccess, 120 | FXGXunFeiTTSDelegate OnXunFeiTTSWavFileFail); 121 | 122 | 123 | 124 | 125 | }; 126 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiLink/XGXunFeiLink.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class XGXunFeiLink : ModuleRules 6 | { 7 | public XGXunFeiLink(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicIncludePaths.AddRange( 12 | new string[] { 13 | 14 | } 15 | ); 16 | 17 | 18 | PrivateIncludePaths.AddRange( 19 | new string[] { 20 | 21 | } 22 | ); 23 | 24 | 25 | PublicDependencyModuleNames.AddRange( 26 | new string[] 27 | { 28 | "Core", 29 | "XGXunFeiCore", 30 | "XGXunFeiSTT", 31 | "XGXunFeiTTS" 32 | } 33 | ); 34 | 35 | 36 | PrivateDependencyModuleNames.AddRange( 37 | new string[] 38 | { 39 | "CoreUObject", 40 | "Engine" 41 | } 42 | ); 43 | 44 | if (Target.Platform == UnrealTargetPlatform.Android) 45 | { 46 | PrivateDependencyModuleNames.AddRange( 47 | new string[] 48 | { 49 | "Launch", 50 | } 51 | ); 52 | } 53 | 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Private/Log/LogXGXunFeiSTT.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "LogXGXunFeiSTT.h" 3 | 4 | DEFINE_LOG_CATEGORY(LogXGXunFeiSTT); 5 | 6 | DEFINE_LOG_CATEGORY(LogXGXunFeiRealTimeSTT); 7 | 8 | DEFINE_LOG_CATEGORY(LogXGXunFeiVoiceDictation); 9 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Private/Subsystem/XGXunFeiAudioCaptureSubsystem.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiAudioCaptureSubsystem.h" 4 | 5 | #include "Generators/AudioGenerator.h" 6 | #include "Async/Async.h" 7 | #include "Async/TaskGraphInterfaces.h" 8 | #include "Kismet/KismetSystemLibrary.h" 9 | #include "Engine/GameInstance.h" 10 | #include "LogXGXunFeiSTT.h" 11 | 12 | #include "XGXunFeiRealTimeSTTSubsystem.h" 13 | 14 | 15 | UXGXunFeiAudioCaptureSubsystem* UXGXunFeiAudioCaptureSubsystem::XunFeiAudioCaptureSubsystemPtr = nullptr; 16 | 17 | int32 UXGXunFeiAudioCaptureSubsystem::AudioCaptureSampleRate = 16000; 18 | int32 UXGXunFeiAudioCaptureSubsystem::OnceSendFloatDataNum = 640; 19 | 20 | TArray UXGXunFeiAudioCaptureSubsystem::NewAllVoiceData = {}; 21 | 22 | 23 | 24 | FAudioCaptureDeviceInfo UXGXunFeiAudioCaptureSubsystem::AudioCaptureDeviceInfo; 25 | 26 | FCriticalSection UXGXunFeiAudioCaptureSubsystem::VoiceDataSection; 27 | 28 | bool UXGXunFeiAudioCaptureSubsystem::ShouldCreateSubsystem(UObject* Outer) const 29 | { 30 | return true; 31 | } 32 | 33 | void UXGXunFeiAudioCaptureSubsystem::Initialize(FSubsystemCollectionBase& Collection) 34 | { 35 | Super::Initialize(Collection); 36 | 37 | XunFeiAudioCaptureSubsystemPtr = this; 38 | 39 | 40 | } 41 | 42 | void UXGXunFeiAudioCaptureSubsystem::Deinitialize() 43 | { 44 | 45 | StopCapturingAudio(); 46 | XunFeiAudioCaptureSubsystemPtr = nullptr; 47 | Super::Deinitialize(); 48 | 49 | 50 | } 51 | 52 | UXGXunFeiAudioCaptureSubsystem* UXGXunFeiAudioCaptureSubsystem::Get() 53 | { 54 | return XunFeiAudioCaptureSubsystemPtr; 55 | } 56 | 57 | void UXGXunFeiAudioCaptureSubsystem::StartCapturingAudio(EXGXunFeiAudioCaptureType InAuidoCaptureType) 58 | { 59 | if (!XGAudioCapture) 60 | { 61 | StopCapturingAudio(); 62 | } 63 | 64 | XGAudioCapture = UAudioCaptureFunctionLibrary::CreateAudioCapture(); 65 | 66 | if (XGAudioCapture) 67 | { 68 | ClearVoiceData(); 69 | 70 | GetAudioCaptureDeviceInfo(AudioCaptureDeviceInfo); 71 | 72 | AudioGeneratorHandle = XGAudioCapture->AddGeneratorDelegate(&UXGXunFeiAudioCaptureSubsystem::OnAudioGenerate); 73 | 74 | switch (InAuidoCaptureType) 75 | { 76 | case EXGXunFeiAudioCaptureType::None: 77 | 78 | AudioCaptureSampleRate = 16000; 79 | 80 | break; 81 | case EXGXunFeiAudioCaptureType::RealtimeSTT: 82 | 83 | AudioCaptureSampleRate = 16000; 84 | 85 | break; 86 | 87 | case EXGXunFeiAudioCaptureType::VoiceDictation_8k: 88 | 89 | AudioCaptureSampleRate = 8000; 90 | 91 | OnceSendFloatDataNum = 320; 92 | 93 | break; 94 | 95 | case EXGXunFeiAudioCaptureType::VoiceDictation_16k: 96 | 97 | AudioCaptureSampleRate = 16000; 98 | 99 | 100 | break; 101 | default: 102 | break; 103 | } 104 | 105 | 106 | XGAudioCapture->StartCapturingAudio(); 107 | } 108 | else 109 | { 110 | 111 | //UKismetSystemLibrary::PrintString(this, TEXT("Failed AudioCapture,please check it")); 112 | 113 | UE_LOG(LogXGXunFeiSTT, Warning, TEXT("[%s]:No Audio Device Captured ,Please Check it!"), *FString(__FUNCTION__)); 114 | 115 | } 116 | } 117 | 118 | void UXGXunFeiAudioCaptureSubsystem::StopCapturingAudio() 119 | { 120 | if (XGAudioCapture) 121 | { 122 | XGAudioCapture->StopCapturingAudio(); 123 | XGAudioCapture->RemoveGeneratorDelegate(AudioGeneratorHandle); 124 | XGAudioCapture = nullptr; 125 | 126 | } 127 | 128 | ClearVoiceData(); 129 | 130 | } 131 | 132 | bool UXGXunFeiAudioCaptureSubsystem::IsCapturingAudio() 133 | { 134 | if (XGAudioCapture) 135 | { 136 | return XGAudioCapture->IsCapturingAudio(); 137 | } 138 | 139 | return false; 140 | 141 | 142 | } 143 | 144 | bool UXGXunFeiAudioCaptureSubsystem::GetAudioCaptureDeviceInfo(FAudioCaptureDeviceInfo& OutInfo) 145 | { 146 | if (XGAudioCapture) 147 | { 148 | return XGAudioCapture->GetAudioCaptureDeviceInfo(OutInfo); 149 | } 150 | 151 | return false; 152 | } 153 | 154 | float UXGXunFeiAudioCaptureSubsystem::GetVolumeSize() 155 | { 156 | return VolumeSize; 157 | } 158 | 159 | void UXGXunFeiAudioCaptureSubsystem::SetVolumeSize(float InVolumeSize) 160 | { 161 | VolumeSize = InVolumeSize; 162 | } 163 | 164 | void UXGXunFeiAudioCaptureSubsystem::AppendVoiceData(const float* InAudio, int32 NumSamples) 165 | { 166 | FScopeLock Lock(&VoiceDataSection); 167 | 168 | NewAllVoiceData.Append(InAudio, NumSamples); 169 | 170 | } 171 | 172 | bool UXGXunFeiAudioCaptureSubsystem::GetVoiceData(TArray& OutVoiceData) 173 | { 174 | FScopeLock Lock(&VoiceDataSection); 175 | 176 | OutVoiceData.Empty(); 177 | 178 | if (AudioCaptureDeviceInfo.SampleRate == 48000 && (AudioCaptureDeviceInfo.NumInputChannels == 2 || AudioCaptureDeviceInfo.NumInputChannels == 1) 179 | || AudioCaptureDeviceInfo.SampleRate == 16000 && (AudioCaptureDeviceInfo.NumInputChannels == 2 || AudioCaptureDeviceInfo.NumInputChannels == 1)) 180 | { 181 | 182 | 183 | 184 | int32 AudioFix = AudioCaptureDeviceInfo.NumInputChannels * AudioCaptureDeviceInfo.SampleRate / AudioCaptureSampleRate; 185 | 186 | int32 HanldeAudioFloatNum = OnceSendFloatDataNum * AudioFix; 187 | 188 | 189 | if (NewAllVoiceData.Num() > HanldeAudioFloatNum) 190 | { 191 | 192 | for (int32 Index = 0; Index < OnceSendFloatDataNum; Index++) 193 | { 194 | OutVoiceData.Add(NewAllVoiceData[Index * AudioFix]); 195 | } 196 | 197 | NewAllVoiceData.RemoveAt(0, HanldeAudioFloatNum); 198 | 199 | //int32 VoiceTotalNum = NewAllVoiceData.Num(); 200 | 201 | //AsyncTask(ENamedThreads::GameThread, [VoiceTotalNum]() { 202 | 203 | // UE_LOG(LogXGXunFeiVoiceDictation, Warning, TEXT("--Num:[%d]-]"), VoiceTotalNum); 204 | 205 | // }); 206 | 207 | 208 | 209 | return true; 210 | } 211 | 212 | } 213 | else if (AudioCaptureDeviceInfo.SampleRate == 44100 && AudioCaptureDeviceInfo.NumInputChannels == 2 214 | || AudioCaptureDeviceInfo.SampleRate == 44100 && AudioCaptureDeviceInfo.NumInputChannels == 1) 215 | { 216 | int32 HanldeAudioFloatNum = AudioCaptureDeviceInfo.SampleRate / 25 * AudioCaptureDeviceInfo.NumInputChannels; 217 | 218 | if (NewAllVoiceData.Num() > HanldeAudioFloatNum) 219 | { 220 | TArray OriginData; 221 | 222 | int32 StepSize = AudioCaptureDeviceInfo.NumInputChannels; 223 | 224 | for (int32 Index = 0; Index < HanldeAudioFloatNum;) 225 | { 226 | Index += StepSize; 227 | OriginData.Add(NewAllVoiceData[Index]); 228 | 229 | } 230 | 231 | OutVoiceData = LinearResample(OriginData, OnceSendFloatDataNum); 232 | 233 | NewAllVoiceData.RemoveAt(0, HanldeAudioFloatNum); 234 | 235 | return true; 236 | } 237 | } 238 | else 239 | { 240 | check(false); 241 | } 242 | 243 | return false; 244 | } 245 | 246 | void UXGXunFeiAudioCaptureSubsystem::ClearVoiceData() 247 | { 248 | 249 | FScopeLock Lock(&VoiceDataSection); 250 | 251 | NewAllVoiceData.Empty(); 252 | 253 | if (UXGXunFeiAudioCaptureSubsystem::XunFeiAudioCaptureSubsystemPtr) 254 | { 255 | UXGXunFeiAudioCaptureSubsystem::XunFeiAudioCaptureSubsystemPtr->SetVolumeSize(0.f); 256 | } 257 | 258 | } 259 | 260 | void UXGXunFeiAudioCaptureSubsystem::OnAudioGenerate(const float* InAudio, int32 NumSamples) 261 | { 262 | 263 | //FAudioCaptureDeviceInfo OutAudioCaptureDeviceInfo = AudioCaptureDeviceInfo; 264 | 265 | //AsyncTask(ENamedThreads::GameThread, [OutAudioCaptureDeviceInfo, NumSamples]() { 266 | 267 | // UE_LOG(LogXGXunFeiVoiceDictation, Warning, TEXT("--NumCaputure:%d--AudioName:[%s]--AudioChannel:[%d]--AudioRate:[%d]"), NumSamples 268 | // , *OutAudioCaptureDeviceInfo.DeviceName.ToString(), OutAudioCaptureDeviceInfo.NumInputChannels, OutAudioCaptureDeviceInfo.SampleRate); 269 | // }); 270 | 271 | if (NumSamples <= 0) 272 | { 273 | return; 274 | } 275 | 276 | float Volume = 0.0; 277 | 278 | //Volume calculation 279 | for (int32 VolumeCalculationIndex = 0; VolumeCalculationIndex < NumSamples; VolumeCalculationIndex++) 280 | { 281 | 282 | Volume += InAudio[VolumeCalculationIndex] * InAudio[VolumeCalculationIndex]; 283 | } 284 | 285 | Volume = FMath::Sqrt(Volume / NumSamples); 286 | 287 | AsyncTask(ENamedThreads::GameThread, [Volume]() { 288 | 289 | if (UXGXunFeiAudioCaptureSubsystem::XunFeiAudioCaptureSubsystemPtr) 290 | { 291 | UXGXunFeiAudioCaptureSubsystem::XunFeiAudioCaptureSubsystemPtr->SetVolumeSize(Volume); 292 | } 293 | 294 | }); 295 | 296 | UXGXunFeiAudioCaptureSubsystem::AppendVoiceData(InAudio, NumSamples); 297 | 298 | } 299 | 300 | TArray UXGXunFeiAudioCaptureSubsystem::LinearResample(TArray& InData, int32 OutDataSize) 301 | { 302 | TArray OutData; 303 | 304 | double ResampleRatio = (float)(InData.Num() - 1) / (float)(OutDataSize - 1); 305 | 306 | for (int32 i = 0; i < OutDataSize; ++i) { 307 | float Index = i * ResampleRatio; 308 | 309 | int32 LowerIndex = (int32)Index; 310 | int32 UpperIndex = FMath::Min((int32)Index + 1, InData.Num() - 1); 311 | float alpha = Index - LowerIndex; 312 | 313 | float interpolatedValue = (1.0 - alpha) * InData[LowerIndex] + alpha * InData[UpperIndex]; 314 | OutData.Add(interpolatedValue); 315 | } 316 | 317 | return OutData; 318 | } 319 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Private/Thread/XGXunFeiConsumeVoiceRunnable.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiConsumeVoiceRunnable.h" 4 | #include "XGXunFeiAudioCaptureSubsystem.h" 5 | #include "XGXunFeiRealTimeSTTSubsystem.h" 6 | 7 | 8 | 9 | FXGXunFeiConsumeVoiceRunnable::FXGXunFeiConsumeVoiceRunnable(FString InThreadName, 10 | EXGXunFeiConsumeVoiceType InConsumeVoiceType) 11 | :ThreadName(InThreadName) 12 | , ConsumeVoiceType(InConsumeVoiceType) 13 | { 14 | 15 | 16 | } 17 | 18 | 19 | FXGXunFeiConsumeVoiceRunnable::~FXGXunFeiConsumeVoiceRunnable() 20 | { 21 | 22 | } 23 | 24 | bool FXGXunFeiConsumeVoiceRunnable::Init() 25 | { 26 | return true; 27 | } 28 | 29 | uint32 FXGXunFeiConsumeVoiceRunnable::Run() 30 | { 31 | bIsRunning = true; 32 | 33 | while (bIsRunning) 34 | { 35 | FPlatformProcess::Sleep(0.01); 36 | 37 | TArray VoiceData; 38 | 39 | bool bRightVoice = UXGXunFeiAudioCaptureSubsystem::GetVoiceData(VoiceData); 40 | 41 | if (bRightVoice) 42 | { 43 | switch (ConsumeVoiceType) 44 | { 45 | case EXGXunFeiConsumeVoiceType::None: 46 | 47 | break; 48 | case EXGXunFeiConsumeVoiceType::RealtimeSTT: 49 | 50 | if (UXGXunFeiRealTimeSTTSubsystem::RealTimeSTTSubsystemPtr) 51 | { 52 | UXGXunFeiRealTimeSTTSubsystem::RealTimeSTTSubsystemPtr->SendVoiceData(VoiceData); 53 | } 54 | 55 | break; 56 | 57 | 58 | default: 59 | 60 | break; 61 | 62 | } 63 | 64 | } 65 | } 66 | return 0; 67 | } 68 | 69 | void FXGXunFeiConsumeVoiceRunnable::Stop() 70 | { 71 | bIsRunning = false; 72 | 73 | } 74 | 75 | void FXGXunFeiConsumeVoiceRunnable::Exit() 76 | { 77 | UXGXunFeiAudioCaptureSubsystem::ClearVoiceData(); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Private/Type/STT/XGXunFeiRealTimeSTTReqType.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiRealTimeSTTReqType.h" 4 | 5 | #include "Misc/Base64.h" 6 | 7 | #include "XGXunFeiCoreSettings.h" 8 | 9 | 10 | 11 | FString FXGXunFeiRealTimeSTTReqInfo::GenerateRequireParams(FString InAppID, FString InAPIKey) 12 | { 13 | FString RetStr=TEXT(""); 14 | 15 | FString AppID = InAppID; 16 | FString APIKey = InAPIKey; 17 | FString TS = FString::FromInt(FDateTime::Now().UtcNow().ToUnixTimestamp()); 18 | 19 | appid = AppID; 20 | 21 | ts = TS; 22 | 23 | signa = GenerateSigna(AppID, TS, APIKey); 24 | 25 | RetStr += TEXT("appid=") + appid; 26 | RetStr += TEXT("&ts=") + ts; 27 | RetStr += TEXT("&signa=") + signa; 28 | 29 | if (!lang.IsEmpty()) 30 | { 31 | RetStr += TEXT("&lang=") + lang; 32 | } 33 | 34 | if (bEnableTranslate) 35 | { 36 | RetStr += TEXT("&transType=") + transType; 37 | RetStr += TEXT("&transStrategy=") + FString::FromInt(transStrategy); 38 | RetStr += TEXT("&targetLang=") + targetLang; 39 | } 40 | 41 | if (!punc.IsEmpty()&&!punc.Equals(TEXT("None"))) 42 | { 43 | RetStr+= TEXT("&punc=") + punc; 44 | } 45 | 46 | 47 | if (!pd.IsEmpty()&& !pd.Equals(TEXT("None"))) 48 | { 49 | RetStr += TEXT("&pd=") + pd; 50 | } 51 | 52 | if (vadMdn!=-1) 53 | { 54 | RetStr += TEXT("&vadMdn=") + FString::FromInt(vadMdn); 55 | } 56 | 57 | 58 | if (roleType != -1) 59 | { 60 | RetStr += TEXT("&roleType=") + FString::FromInt(roleType); 61 | } 62 | 63 | 64 | 65 | if (engLangType != -1) 66 | { 67 | RetStr += TEXT("&engLangType=") + FString::FromInt(engLangType); 68 | } 69 | 70 | return RetStr; 71 | } 72 | 73 | FString FXGXunFeiRealTimeSTTReqInfo::GenerateSigna(const FString& InAppid, const FString& InTS, const FString& InAPIKey) 74 | { 75 | FString BaseString = InAppid+ InTS; 76 | FString MD5BaseString = FMD5::HashAnsiString(*BaseString); 77 | 78 | FSHAHash Hash; 79 | FSHA1 SHA1; 80 | SHA1.HMACBuffer(TCHAR_TO_ANSI(*InAPIKey), InAPIKey.Len(), TCHAR_TO_ANSI(*MD5BaseString), MD5BaseString.Len(), Hash.Hash); 81 | 82 | FString Signa = FBase64::Encode(Hash.Hash, 20); 83 | 84 | Signa.ReplaceInline(TEXT("%"), TEXT("%25")); 85 | Signa.ReplaceInline(TEXT("+"), TEXT("%2B")); 86 | Signa.ReplaceInline(TEXT(" "), TEXT("%20")); 87 | Signa.ReplaceInline(TEXT("/"), TEXT("%2F")); 88 | Signa.ReplaceInline(TEXT("?"), TEXT("%3F")); 89 | Signa.ReplaceInline(TEXT("#"), TEXT("%23")); 90 | Signa.ReplaceInline(TEXT("&"), TEXT("%26")); 91 | Signa.ReplaceInline(TEXT("="), TEXT("%3D")); 92 | 93 | return Signa; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Private/Type/STT/XGXunFeiRealTimeSTTRespType.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "XGXunFeiRealTimeSTTRespType.h" -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Private/XGXunFeiSTT.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiSTT.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FXGXunFeiSTTModule" 6 | 7 | void FXGXunFeiSTTModule::StartupModule() 8 | { 9 | 10 | 11 | } 12 | 13 | void FXGXunFeiSTTModule::ShutdownModule() 14 | { 15 | 16 | 17 | } 18 | 19 | #undef LOCTEXT_NAMESPACE 20 | 21 | IMPLEMENT_MODULE(FXGXunFeiSTTModule, XGXunFeiSTT) -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Log/LogXGXunFeiSTT.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | 6 | DECLARE_LOG_CATEGORY_EXTERN(LogXGXunFeiSTT, Log, All); 7 | 8 | DECLARE_LOG_CATEGORY_EXTERN(LogXGXunFeiRealTimeSTT, Log, All); 9 | 10 | DECLARE_LOG_CATEGORY_EXTERN(LogXGXunFeiVoiceDictation, Log, All); 11 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Subsystem/XGXunFeiAudioCaptureSubsystem.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | #include "CoreMinimal.h" 5 | #include "Subsystems/GameInstanceSubsystem.h" 6 | #include "AudioCapture.h" 7 | #include "XGXunFeiAudioCaptureSubsystem.generated.h" 8 | 9 | 10 | enum class EXGXunFeiAudioCaptureType 11 | { 12 | None, 13 | RealtimeSTT, 14 | VoiceDictation_8k, 15 | VoiceDictation_16k, 16 | }; 17 | 18 | /** 19 | * UXGXunFeiAudioCaptureSubsystem 20 | * Audio capture from deivce. 21 | * if you have no audio input device,It will not work. 22 | */ 23 | struct FAudioGeneratorHandle; 24 | UCLASS() 25 | class XGXUNFEISTT_API UXGXunFeiAudioCaptureSubsystem : public UGameInstanceSubsystem 26 | { 27 | GENERATED_BODY() 28 | 29 | friend class FXGXunFeiConsumeVoiceRunnable; 30 | friend class UXGXunFeiRealTimeSTTSubsystem; 31 | friend class UXGXunFeiVoiceDictationSubsystem; 32 | friend class UXGXunFeiLinkBPLibrary; 33 | 34 | public: 35 | 36 | virtual bool ShouldCreateSubsystem(UObject* Outer) const override; 37 | 38 | virtual void Initialize(FSubsystemCollectionBase& Collection) override; 39 | 40 | virtual void Deinitialize() override; 41 | 42 | protected: 43 | 44 | static UXGXunFeiAudioCaptureSubsystem* Get(); 45 | 46 | void StartCapturingAudio(EXGXunFeiAudioCaptureType InAuidoCaptureType= EXGXunFeiAudioCaptureType::RealtimeSTT); 47 | 48 | void StopCapturingAudio(); 49 | 50 | bool IsCapturingAudio(); 51 | 52 | bool GetAudioCaptureDeviceInfo(FAudioCaptureDeviceInfo& OutInfo); 53 | 54 | float GetVolumeSize(); 55 | 56 | void SetVolumeSize(float InVolumeSize); 57 | 58 | static void AppendVoiceData(const float* InAudio, int32 NumSamples); 59 | 60 | static bool GetVoiceData(TArray& OutVoiceData); 61 | 62 | static void ClearVoiceData(); 63 | 64 | static void OnAudioGenerate(const float* InAudio, int32 NumSamples); 65 | 66 | static TArray LinearResample(TArray& InData,int32 OutDataSize); 67 | 68 | protected: 69 | 70 | static FAudioCaptureDeviceInfo AudioCaptureDeviceInfo; 71 | 72 | static UXGXunFeiAudioCaptureSubsystem* XunFeiAudioCaptureSubsystemPtr; 73 | 74 | static int32 AudioCaptureSampleRate; 75 | 76 | static int32 OnceSendFloatDataNum; 77 | 78 | static int32 AudioCaptureCoefficient; 79 | 80 | float VolumeSize =0.f; 81 | 82 | UPROPERTY() 83 | UAudioCapture* XGAudioCapture; 84 | 85 | FAudioGeneratorHandle AudioGeneratorHandle; 86 | 87 | static FCriticalSection VoiceDataSection; 88 | 89 | static TArray NewAllVoiceData; 90 | 91 | 92 | }; -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Subsystem/XGXunFeiRealTimeSTTSubsystem.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "Subsystems/GameInstanceSubsystem.h" 5 | 6 | 7 | #include "XGXunFeiRealTimeSTTType.h" 8 | #include "XGXunFeiRealTimeSTTReqType.h" 9 | 10 | #include "XGXunFeiRealTimeSTTSubsystem.generated.h" 11 | 12 | 13 | class IWebSocket; 14 | class FXGXunFeiConsumeVoiceRunnable; 15 | class UXGXunFeiLinkBPLibrary; 16 | class UXGXunFeiAudioCaptureSubsystem; 17 | class UXGXunFeiVoiceDictationSubsystem; 18 | 19 | /** 20 | * UXGXunFeiRealTimeSTTSubsystem 21 | * Connect iFlyTek RealTime SST WebAPI through WebSocket. 22 | */ 23 | UCLASS() 24 | class XGXUNFEISTT_API UXGXunFeiRealTimeSTTSubsystem : public UGameInstanceSubsystem 25 | { 26 | GENERATED_BODY() 27 | 28 | friend class FXGXunFeiConsumeVoiceRunnable; 29 | friend class UXGXunFeiLinkBPLibrary; 30 | friend class UXGXunFeiAudioCaptureSubsystem; 31 | friend class UXGXunFeiVoiceDictationSubsystem; 32 | 33 | public: 34 | 35 | virtual bool ShouldCreateSubsystem(UObject* Outer) const override; 36 | virtual void Initialize(FSubsystemCollectionBase& Collection)override; 37 | virtual void Deinitialize()override; 38 | 39 | 40 | protected: 41 | 42 | bool IsRealTimeSTTReady(); 43 | 44 | FGuid XGBeginRealTimeSpeechToText( 45 | FString InSTTAppID, 46 | FString InSTTAPIKey, 47 | FXGXunFeiRealTimeSTTReqInfo& InRealTimeSTTReqInfo, 48 | FXGXunFeiInitRealTimeSTTDelegate InRealTimeSTTInitDelegate, 49 | FXGXunFeiRealTimeSTTRespDelegate InRealTimeSTTRespDelegate, 50 | FXGXunFeiRealTimeSTTCloseDelegate InRealTimeSTTCloseDelegate); 51 | 52 | void XGStopRealTimeSpeechToText(); 53 | 54 | void XGForceToStopRealTimeSPeechToText(bool IsDeinitialize=false); 55 | 56 | void CallInitRealTimeSTTDelegate(FGuid InSTTAsyncID, bool bInInitResult, FString InInitRespMessage, FXGXunFeiRealTimeSTTInitInformation InRealTimeSTTInitInformation); 57 | 58 | void CallRealTimeSTTRespDelegate( FXGXunFeiRealTimeSTTInformation InRealTimeSTTInformation); 59 | 60 | void CallRealTimeSTTCloseDelegate(FGuid InSTTAsyncID, int32 InStatusCode, FString InReason,bool bInWasClean); 61 | 62 | void SendVoiceData(const TArray& InVoiceData); 63 | 64 | void RealseaseVoiceGenerateRunnale(); 65 | 66 | void RealeaseVoiceConsumeRunnable(); 67 | 68 | void RealeaseWebSocket(); 69 | 70 | void RealeaseSTTInfo(); 71 | 72 | void EndSendVoiceData(); 73 | 74 | 75 | 76 | 77 | 78 | protected: 79 | 80 | void OnConnected(); 81 | 82 | void OnConnectionError(const FString& ErrorMessage); 83 | 84 | void OnClosed(int32 StatusCode, const FString& Reason, bool bWasClean); 85 | 86 | void OnMessage(const FString& Message); 87 | 88 | void OnMessageSent(const FString& MessageString); 89 | 90 | 91 | protected: 92 | 93 | static UXGXunFeiRealTimeSTTSubsystem* RealTimeSTTSubsystemPtr; 94 | 95 | EXGXunFeiRealTimeSTTStatus RealTimeSTTStatus = EXGXunFeiRealTimeSTTStatus::Ready; 96 | 97 | FGuid STTAsyncID = FGuid(); 98 | 99 | FString STTAppID=TEXT(""); 100 | 101 | FString STTAPIKey=TEXT(""); 102 | 103 | FXGXunFeiInitRealTimeSTTDelegate RealTimeSTTInitDelegate; 104 | 105 | FXGXunFeiRealTimeSTTRespDelegate RealTimeSTTRespDelegate; 106 | 107 | FXGXunFeiRealTimeSTTCloseDelegate RealTimeSTTCloseDelegate; 108 | 109 | TSharedPtr Socket; 110 | 111 | TSharedPtr ConsumeVoiceRunnable; 112 | 113 | FRunnableThread* RunnableThread; 114 | 115 | 116 | }; -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Thread/XGXunFeiConsumeVoiceRunnable.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "HAL/Runnable.h" 6 | #include "HAL/ThreadSafeBool.h" 7 | class UXGXunFeiAudioCaptureSubsystem; 8 | class UXGXunFeiRealTimeSTTSubsystem; 9 | class UXGXunFeiVoiceDictationSubsystem; 10 | 11 | 12 | enum class EXGXunFeiConsumeVoiceType 13 | { 14 | None, 15 | RealtimeSTT, 16 | VoiceDictation 17 | }; 18 | 19 | /** 20 | * FXGXunFeiConsumeVoiceRunnable 21 | * AudioConsume Thread. Process the data from AudioCaptureSystem,and then send it to iFlyTesk web service. 22 | */ 23 | class FXGXunFeiConsumeVoiceRunnable :public FRunnable 24 | { 25 | public: 26 | 27 | FXGXunFeiConsumeVoiceRunnable(FString InThreadName, 28 | EXGXunFeiConsumeVoiceType InConsumeVoiceType); 29 | 30 | virtual ~FXGXunFeiConsumeVoiceRunnable(); 31 | 32 | virtual bool Init() override; 33 | virtual uint32 Run() override; 34 | virtual void Stop() override; 35 | virtual void Exit() override; 36 | 37 | FString ThreadName; 38 | 39 | protected: 40 | 41 | EXGXunFeiConsumeVoiceType ConsumeVoiceType = EXGXunFeiConsumeVoiceType::None; 42 | 43 | FThreadSafeBool bIsRunning = true; 44 | 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Type/STT/XGXunFeiRealTimeSTTReqType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | /** 4 | * Be careful: 5 | * This STT Module only support China region. 6 | * If you want to use it in other regiion,you can use ASRG Module. 7 | * 8 | * iFlyTek Real Time Speech To Text Document: 9 | * Chinese: 10 | * https://www.xfyun.cn/doc/asr/rtasr/API.html 11 | * 12 | * 13 | */ 14 | #pragma once 15 | #include "CoreMinimal.h" 16 | 17 | #include "XGXunFeiRealTimeSTTReqType.generated.h" 18 | 19 | 20 | /** 21 | * FXGXunFeiRealTimeSTTReqInfo 22 | * Some RequsetJsonStruct About Real Time SST. 23 | * 24 | * 25 | */ 26 | USTRUCT(BlueprintType) 27 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTReqInfo 28 | { 29 | GENERATED_BODY() 30 | 31 | protected: 32 | 33 | /** 34 | * Parameter:appid 35 | * Type:string 36 | * Required:Yes 37 | * Description:Appid message applied from the platform 38 | * Example:5f9c6d6a 39 | */ 40 | UPROPERTY() 41 | FString appid = TEXT(""); 42 | 43 | /** 44 | * Parameter:ts 45 | * Type:string 46 | * Required:Yes 47 | * Description:Current timestamp, in RFC1123 format 48 | * Example:1512041814 49 | */ 50 | UPROPERTY() 51 | FString ts = TEXT(""); 52 | 53 | /** 54 | * Parameter:signa 55 | * Type:string 56 | * Required:Yes 57 | * Description:Encrypted digital signature (based on HMACSHA1 algorithm) 58 | * Example:IrrzsJeOFk1NGfJHW6SkHUoN9CU= 59 | */ 60 | UPROPERTY() 61 | FString signa = TEXT(""); 62 | 63 | public: 64 | 65 | /** 66 | * Parameter:lang 67 | * Type:string 68 | * Required:No 69 | * Description:Real-time speech transfer language.The default is Chinese. 70 | * Example: 71 | * Language type: 72 | * Chinese、ChineseAndEnglish:cn; 73 | * Engilis:en; 74 | * Minor languages and dialects can be added from the iFlyTek control panel console.you can get corresponding parameters. 75 | * ParameterExample:"lang=en" 76 | * Error 10110 is reported, if unauthorised . 77 | */ 78 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 79 | FString lang = TEXT("cn"); 80 | 81 | /** 82 | * Custom fields Whether to enable the translation function 83 | * Note: Translation function needs to be enabled on the iFlyTek control panel console. 84 | */ 85 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 86 | bool bEnableTranslate = false; 87 | 88 | 89 | /** 90 | * Parameter:transType 91 | * Type:string 92 | * Required:No 93 | * Description: 94 | * "normal" explains general translation. The default is "normal"; 95 | * Example: transType="normal" 96 | * Note: Translation function needs to be enabled on the iFlyTek control panel console. 97 | */ 98 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 99 | FString transType = TEXT("normal"); 100 | 101 | /** 102 | * Parameter:transType 103 | * Type:int 104 | * Required:No 105 | * Description: 106 | * Strategy 1: Transcribe the VAD results directly to be translated; 107 | * Strategy 2: which returns the results of the intermediate process; 108 | * Strategy 3: Request a translation based on the final punctuation split transcription result; 109 | * Policy 2 is recommended. 110 | * Example: 111 | * transStrategy=2 112 | * Note: Translation function needs to be enabled on the iFlyTek control panel console. 113 | */ 114 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 115 | int32 transStrategy = 2; 116 | 117 | 118 | /** 119 | * Parameter:targetLang 120 | * Type:string 121 | * Required:No 122 | * Description: 123 | * Target Languages: Control what type of language the source language is converted to; 124 | * Please note that similar to converting from English to French, Chinese must be used as the transition language, that is, English-Chinese-French, and direct conversion between languages excluding Chinese is not supported. 125 | * Chinese: cn 126 | * English: en 127 | * Japanese: ja 128 | * Korean: ko 129 | * Russian: ru 130 | * French:fr 131 | * Spanish: es 132 | * Vietnamese: vi 133 | * Cantonese: cn_cantonese 134 | * Example: 135 | * Such as:targetLang="en" 136 | * If you use Chinese real-time translation to English parameter passing Example is as follows: 137 | * "&lang=cn&transType=normal&transStrategy=2&targetLang=en" 138 | * Note: Translation function needs to be enabled on the iFlyTek control panel console. 139 | */ 140 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 141 | FString targetLang = TEXT("en"); 142 | 143 | /** 144 | * Parameter:punc 145 | * Type:string 146 | * Required:No 147 | * Description: Punctuation filter control, punc is returned by default, punc=0 will filter punctuation in the results 148 | * Example: 0 149 | */ 150 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 151 | FString punc = TEXT("None"); 152 | 153 | /** 154 | * Parameter:pd 155 | * Type:string 156 | * Required:No 157 | * Description: 158 | * Vertical Personalization Parameters: 159 | * Court: court 160 | * Education: edu 161 | * Finance: finance 162 | * Medical: medical 163 | * Technology: tech 164 | * Operator: isp 165 | * Government: gov 166 | * E-Commerce: ecom 167 | * Military: mil 168 | * Enterprise: com 169 | * Life: life 170 | * Car: car 171 | * Example: 172 | * Such as :pd="edu" 173 | * Parameter pd is optional. If no parameter is set, it is common by default 174 | */ 175 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 176 | FString pd = TEXT("None"); 177 | 178 | 179 | /** 180 | * Parameter:vadMdn 181 | * Type:int 182 | * Required:No 183 | * Description: 184 | * Switch between far and near field, do not pass this parameter or pass 1 for the far field and pass 2 for the near field 185 | * Example: Such as :vadMdn=2 186 | */ 187 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 188 | int32 vadMdn = -1; 189 | 190 | /** 191 | * Parameter:roleType 192 | * Type:int 193 | * Required:No 194 | * Description: 195 | * Whether to enable character separation, it is not enabled by default, and transmission 2 is enabled 196 | * (the effect is continuously optimized) 197 | * Example: Such as :roleType=2 198 | */ 199 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 200 | int32 roleType = -1; 201 | 202 | /** 203 | * Parameter:engLangType 204 | * Type:int 205 | * Required:No 206 | * Description: 207 | * Language recognition mode selection, default is mode 1 Chinese and English mode: 208 | * 1: Automatic Chinese and English mode 209 | * 2: Chinese mode, may include a small amount of English 210 | * 4: Pure Chinese mode, does not include English 211 | * Example: Such as :engLangType=4 212 | */ 213 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 214 | int32 engLangType = -1; 215 | 216 | public: 217 | 218 | FString GenerateRequireParams(FString InAppID,FString InAPIKey); 219 | 220 | protected: 221 | 222 | FString GenerateSigna(const FString& InAppid, const FString& InTS, const FString& InAPIKey); 223 | 224 | }; 225 | 226 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Type/STT/XGXunFeiRealTimeSTTRespType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | 5 | #include "XGXunFeiRealTimeSTTRespType.generated.h" 6 | 7 | /** 8 | * FXGXunFeiRealTImeSTTRespInfo 9 | */ 10 | USTRUCT(BlueprintType) 11 | struct XGXUNFEISTT_API FXGXunFeiRealTImeSTTRespInfo 12 | { 13 | GENERATED_BODY() 14 | 15 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 16 | FString action = TEXT(""); 17 | 18 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 19 | FString code = TEXT(""); 20 | 21 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 22 | FString data = TEXT(""); 23 | 24 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 25 | FString desc = TEXT(""); 26 | 27 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 28 | FString sid = TEXT(""); 29 | }; 30 | 31 | /** 32 | * FXGXunFeiRealTimeSTTTranslateData 33 | */ 34 | USTRUCT(BlueprintType) 35 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTTranslateData 36 | { 37 | GENERATED_BODY() 38 | 39 | /** 40 | * Service identification field. The value is trans after the translation function is enabled 41 | * Translation function identification 42 | * 43 | */ 44 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 45 | FString biz = TEXT(""); 46 | 47 | /** 48 | * Translated text results for the target language 49 | * Corresponds to the original text src 50 | */ 51 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 52 | FString dst = TEXT(""); 53 | /** 54 | * End of translation mark 55 | * If true, the translation result has been pushed 56 | */ 57 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 58 | bool isEnd =false; 59 | 60 | /** 61 | * Transliteration result sequence number 62 | * Start at 0 63 | */ 64 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 65 | int32 segId = -1; 66 | 67 | /** 68 | * Send translated original text 69 | * The audio corresponds to the identifying text 70 | */ 71 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 72 | FString src = TEXT(""); 73 | 74 | /** 75 | * Result Type identification 76 | * 0- Final result; 1- Intermediate result 77 | */ 78 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 79 | int32 type = -1; 80 | 81 | 82 | /** 83 | * The beginning time of a sentence in the whole speech, in milliseconds (ms) 84 | * The bg of the intermediate result is the exact value 85 | */ 86 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 87 | int32 bg=-1; 88 | 89 | 90 | /** 91 | * The end time of the sentence in the whole speech, in milliseconds (ms) 92 | * The ed of the intermediate result is 0 93 | */ 94 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 95 | int32 ed=-1; 96 | 97 | }; 98 | 99 | /** 100 | * FXGXunFeiRealTimeSTTNoTranslateCWData 101 | */ 102 | USTRUCT(BlueprintType) 103 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTNoTranslateCWData 104 | { 105 | GENERATED_BODY() 106 | 107 | /** 108 | * Unknown Parameter 109 | */ 110 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 111 | float sc = 0.0f; 112 | 113 | 114 | /** 115 | * Word recognition result 116 | */ 117 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 118 | FString w = TEXT(""); 119 | 120 | /** 121 | * Word recognition result 122 | * n- common words; S-smooth word (modal word); p-punctuation 123 | */ 124 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 125 | FString wp = TEXT(""); 126 | 127 | 128 | /** 129 | * 1. The separated role number can be returned only after the role separation function is enabled. 130 | * 2. The role number starts from 1. 131 | * 3. This field appears only when the role separation function is enabled. 132 | * This value changes only when roles are switched. 133 | * The rest of the value is 0. For example, when role A starts to speak rl=1, then when role A speaks rl is always 0. When Role B starts to speak, rl=2, and Role B continues to speak rl changes back to 0. 134 | */ 135 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 136 | FString rl = TEXT(""); 137 | 138 | /** 139 | * The start time of the word in this sentence, in frames, 1 frame =10ms 140 | * The start time of the word in the whole speech is (bg+wb*10)ms 141 | * The wb of the intermediate result is 0 142 | */ 143 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 144 | int32 wb = -1; 145 | 146 | /** 147 | * Unknown Parameter 148 | */ 149 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 150 | float wc = 0.0f; 151 | 152 | /** 153 | * The end time of the word in this sentence, in frames, 1 frame =10ms 154 | * The end time of the word in the whole speech is (bg+we*10)ms 155 | * The we of the intermediate result is 0 156 | */ 157 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 158 | int32 we = -1; 159 | 160 | 161 | }; 162 | 163 | /** 164 | * FXGXunFeiRealTimeSTTNoTranslateWSData 165 | */ 166 | USTRUCT(BlueprintType) 167 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTNoTranslateWSData 168 | { 169 | GENERATED_BODY() 170 | 171 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 172 | TArray cw; 173 | /** 174 | * The start time of the word in this sentence, in frames, 1 frame =10ms 175 | * The start time of the word in the whole speech is (bg+wb*10)ms 176 | * The wb of the intermediate result is 0 177 | */ 178 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 179 | int32 wb=-1; 180 | 181 | /** 182 | * The end time of the word in this sentence, in frames, 1 frame =10ms 183 | * The end time of the word in the whole speech is (bg+we*10)ms 184 | * The we of the intermediate result is 0 185 | */ 186 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 187 | int32 we=-1; 188 | }; 189 | 190 | 191 | /** 192 | * FXGXunFeiRealTimeSTTNoTranslateRTData 193 | */ 194 | USTRUCT(BlueprintType) 195 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTNoTranslateRTData 196 | { 197 | GENERATED_BODY() 198 | 199 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 200 | TArray ws; 201 | }; 202 | 203 | 204 | 205 | 206 | /** 207 | * FXGXunFeiRealTimeSTTNoTranslateSTData 208 | */ 209 | USTRUCT(BlueprintType) 210 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTNoTranslateSTData 211 | { 212 | GENERATED_BODY() 213 | 214 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 215 | FString bg = TEXT(""); 216 | 217 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 218 | FString ed = TEXT(""); 219 | 220 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 221 | TArray rt; 222 | 223 | 224 | /** 225 | * Result Type identifier 226 | * 0- Final result; 1- Intermediate result 227 | */ 228 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 229 | FString type = TEXT(""); 230 | }; 231 | 232 | 233 | /** 234 | * FXGXunFeiRealTimeSTTNoTranslateCNData 235 | */ 236 | USTRUCT(BlueprintType) 237 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTNoTranslateCNData 238 | { 239 | GENERATED_BODY() 240 | 241 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 242 | FXGXunFeiRealTimeSTTNoTranslateSTData st; 243 | }; 244 | 245 | /** 246 | * FXGXunFeiRealTimeSTTNoTranslateData 247 | */ 248 | USTRUCT(BlueprintType) 249 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTNoTranslateData 250 | { 251 | GENERATED_BODY() 252 | 253 | /** 254 | * Presumed to be a regional code 255 | */ 256 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 257 | FXGXunFeiRealTimeSTTNoTranslateCNData cn; 258 | 259 | 260 | /** 261 | * Transcribe the result sequence number 262 | * Start at 0 263 | */ 264 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 265 | int32 seg_id=-1; 266 | 267 | /** 268 | * Unknown Parameter 269 | */ 270 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 271 | bool ls =false; 272 | }; 273 | 274 | 275 | 276 | 277 | USTRUCT(BlueprintType) 278 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTInitInformation 279 | { 280 | GENERATED_BODY() 281 | 282 | public: 283 | 284 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 285 | FXGXunFeiRealTImeSTTRespInfo RealTImeSTTInitInfo; 286 | 287 | }; 288 | 289 | 290 | 291 | 292 | 293 | USTRUCT(BlueprintType) 294 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTRawInformation 295 | { 296 | GENERATED_BODY() 297 | 298 | public: 299 | 300 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 301 | FXGXunFeiRealTImeSTTRespInfo RealTImeSTTRespInfo; 302 | 303 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 304 | FXGXunFeiRealTimeSTTNoTranslateData RealTimeSTTNoTranslateData; 305 | 306 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 307 | FXGXunFeiRealTimeSTTTranslateData RealTimeSTTTranslateData; 308 | 309 | 310 | }; 311 | 312 | 313 | UENUM(BlueprintType) 314 | enum class EXGXunFeiRealTimeSTTRespType : uint8 315 | { 316 | MiddleTextOnlySrc UMETA(DisplayName = "MiddleTextOnlySrc"), 317 | FinalTextOnlySrc UMETA(DisplayName = "FinalTextOnlySrc"), 318 | FinalTextWithSrcAndDst UMETA(DisplayName = "FinalTextWithSrcAndDst"), 319 | }; 320 | 321 | 322 | 323 | USTRUCT(BlueprintType) 324 | struct XGXUNFEISTT_API FXGXunFeiRealTimeSTTInformation 325 | { 326 | GENERATED_BODY() 327 | 328 | public: 329 | 330 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 331 | FGuid AsyncSTTID = FGuid(); 332 | 333 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 334 | bool bSuccess = false; 335 | 336 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 337 | EXGXunFeiRealTimeSTTRespType RespType = EXGXunFeiRealTimeSTTRespType::MiddleTextOnlySrc; 338 | 339 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 340 | FString SrcText = TEXT(""); 341 | 342 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 343 | FString DstText = TEXT(""); 344 | 345 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 346 | FString RoleType =TEXT("0"); 347 | 348 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG XunFei RealTime STT") 349 | FXGXunFeiRealTimeSTTRawInformation RawInformation; 350 | 351 | }; -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/Type/STT/XGXunFeiRealTimeSTTType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | 5 | #include "XGXunFeiRealTimeSTTRespType.h" 6 | 7 | #include "XGXunFeiRealTimeSTTType.generated.h" 8 | 9 | 10 | 11 | DECLARE_DYNAMIC_DELEGATE_FourParams(FXGXunFeiInitRealTimeSTTDelegate, FGuid, AsyncSTTID, bool, bInitResult, FString, InitRespMessage, FXGXunFeiRealTimeSTTInitInformation, RealTimeSTTInitInformation); 12 | 13 | DECLARE_DYNAMIC_DELEGATE_OneParam(FXGXunFeiRealTimeSTTRespDelegate, FXGXunFeiRealTimeSTTInformation, RealTimeSTTInformation); 14 | 15 | DECLARE_DYNAMIC_DELEGATE_FourParams(FXGXunFeiRealTimeSTTCloseDelegate, FGuid, AsyncSTTID, int32,StatusCode, FString, Reason, bool,bWasClean); 16 | 17 | 18 | 19 | UENUM() 20 | enum class EXGXunFeiRealTimeSTTStatus : uint8 21 | { 22 | Ready, 23 | Init, 24 | Processing, 25 | WaitToServerClose, 26 | Finish, 27 | }; 28 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/Public/XGXunFeiSTT.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | /** 7 | * FXGXunFeiSTTModule 8 | */ 9 | class FXGXunFeiSTTModule : public IModuleInterface 10 | { 11 | public: 12 | 13 | 14 | virtual void StartupModule() override; 15 | 16 | virtual void ShutdownModule() override; 17 | }; 18 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiSTT/XGXunFeiSTT.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class XGXunFeiSTT : ModuleRules 6 | { 7 | public XGXunFeiSTT(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicIncludePaths.AddRange( 12 | new string[] { 13 | "$(ModuleDir)/Public/AsyncNode", 14 | "$(ModuleDir)/Public/Subsystem", 15 | "$(ModuleDir)/Public/Type", 16 | "$(ModuleDir)/Public/Type/STT", 17 | 18 | } 19 | ); 20 | 21 | 22 | PrivateIncludePaths.AddRange( 23 | new string[] { 24 | "XGXunFeiSTT/Public/AsyncNode", 25 | "XGXunFeiSTT/Public/Log", 26 | "XGXunFeiSTT/Public/Subsystem", 27 | "XGXunFeiSTT/Public/Thread", 28 | "XGXunFeiSTT/Public/Type", 29 | "XGXunFeiSTT/Public/Type/STT", 30 | 31 | } 32 | ); 33 | 34 | 35 | PublicDependencyModuleNames.AddRange( 36 | new string[] 37 | { 38 | "Core", 39 | "Json", 40 | "JsonUtilities", 41 | "XGXunFeiCore", 42 | } 43 | ); 44 | 45 | 46 | PrivateDependencyModuleNames.AddRange( 47 | new string[] 48 | { 49 | "CoreUObject", 50 | "Engine", 51 | "AudioMixer", 52 | "AudioCapture", 53 | "WebSockets", 54 | 55 | 56 | 57 | } 58 | ); 59 | 60 | 61 | DynamicallyLoadedModuleNames.AddRange( 62 | new string[] 63 | { 64 | 65 | } 66 | ); 67 | 68 | //Need to make sure Android has Launch module. 69 | if (Target.Platform == UnrealTargetPlatform.Android) 70 | { 71 | PrivateIncludePathModuleNames.AddRange( 72 | new string[] { 73 | "Launch" 74 | } 75 | ); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Private/AsyncNode/XGXunFeiTTSAsyncAction.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiTTSAsyncAction.h" 4 | 5 | #include "WebSocketsModule.h" 6 | #include "IWebSocket.h" 7 | #include "JsonObjectConverter.h" 8 | #include "Async/Async.h" 9 | #include "Async/TaskGraphInterfaces.h" 10 | #include "Misc/Paths.h" 11 | #include "Misc/Base64.h" 12 | #include "Misc/FileHelper.h" 13 | #include "Containers/StringConv.h" 14 | #include "Sound/SoundWave.h" 15 | 16 | 17 | #include "XGXunFeiCoreSettings.h" 18 | #include "XGXunFeiCoreBPLibrary.h" 19 | #include "LogXGXunFeiTTS.h" 20 | #include "XGXunFeiTTSRespType.h" 21 | 22 | 23 | UXGXunFeiTTSAsyncAction::UXGXunFeiTTSAsyncAction(const FObjectInitializer& ObjectInitializer) 24 | : Super(ObjectInitializer) 25 | { 26 | 27 | 28 | } 29 | 30 | UXGXunFeiTTSAsyncAction::~UXGXunFeiTTSAsyncAction() 31 | { 32 | RealeaseResources(); 33 | } 34 | 35 | 36 | UXGXunFeiTTSAsyncAction* UXGXunFeiTTSAsyncAction::XGXunFeiTextToSpeech( 37 | UObject* WorldContextObject, 38 | FString InTTSAppID, 39 | FString InTTSAPISecret, 40 | FString InTTSAPIKey, 41 | const FString& InText, 42 | bool bInSaveToLocal, 43 | const FString& InSaveFileFullPath, 44 | FXGXunFeiTTSReqInfo InXunFeiTTSReqInfo) 45 | { 46 | UXGXunFeiTTSAsyncAction* XunFeiTTSAsyncAction = NewObject(); 47 | 48 | 49 | XunFeiTTSAsyncAction->TTSAppID = InTTSAppID; 50 | XunFeiTTSAsyncAction->TTSAPISecret = InTTSAPISecret; 51 | XunFeiTTSAsyncAction->TTSAPIKey = InTTSAPIKey; 52 | 53 | 54 | XunFeiTTSAsyncAction->SetXunFeiText(InText); 55 | XunFeiTTSAsyncAction->SetIsSaveToLocal(bInSaveToLocal); 56 | XunFeiTTSAsyncAction->SetSaveFileFullPath(InSaveFileFullPath); 57 | XunFeiTTSAsyncAction->SetXunFeiTTSReqInfo(InXunFeiTTSReqInfo); 58 | 59 | 60 | 61 | XunFeiTTSAsyncAction->RegisterWithGameInstance(WorldContextObject); 62 | 63 | 64 | return XunFeiTTSAsyncAction; 65 | } 66 | 67 | 68 | void UXGXunFeiTTSAsyncAction::Activate() 69 | { 70 | Super::Activate(); 71 | 72 | Then.Broadcast(AsyncID, false, TEXT("TTS is just started.Please wait to finish ! "), nullptr); 73 | 74 | } 75 | 76 | void UXGXunFeiTTSAsyncAction::Activate_Internal() 77 | { 78 | 79 | if (bSaveToLocal) 80 | { 81 | FString FileDirectory = FPaths::GetPath(SaveFileFullPath); 82 | bool bDirectory = FPaths::DirectoryExists(FileDirectory); 83 | FString FileExtension = FPaths::GetExtension(SaveFileFullPath); 84 | bool bExtension = FileExtension.Equals(TEXT("wav")); 85 | 86 | if (!bDirectory) 87 | { 88 | FString DirectoryErrorMessage = FString::Printf(TEXT("FileDirectory don't exist ! FilePath: [%s]"), *SaveFileFullPath); 89 | 90 | UE_LOG(LogXGXunFeiTTS, Error, TEXT("[%s]:[%s]"), *FString(__FUNCTION__), *DirectoryErrorMessage); 91 | 92 | CallOnFail(false, DirectoryErrorMessage); 93 | 94 | RealeaseResources(); 95 | 96 | return; 97 | } 98 | 99 | if (!bExtension) 100 | { 101 | FString FileNameErroeMessage = FString::Printf(TEXT("FileName is Wrong,it must endwith [.wav] ! FilePath: [%s]"), *FString(__FUNCTION__), *SaveFileFullPath); 102 | 103 | UE_LOG(LogXGXunFeiTTS, Error, TEXT("[%s]:[%s]"), *FString(__FUNCTION__), *FileNameErroeMessage); 104 | 105 | CallOnFail(false, FileNameErroeMessage); 106 | 107 | RealeaseResources(); 108 | 109 | return; 110 | } 111 | 112 | } 113 | 114 | if (XunFeiText.IsEmpty()) 115 | { 116 | FString TextErrorMessage = FString::Printf(TEXT("InText is Empty,it must be input!")); 117 | 118 | UE_LOG(LogXGXunFeiTTS, Error, TEXT("[%s]:[%s]"), *FString(__FUNCTION__), *TextErrorMessage); 119 | 120 | CallOnFail(false, TextErrorMessage); 121 | 122 | RealeaseResources(); 123 | 124 | return; 125 | } 126 | 127 | AsyncTask(ENamedThreads::GameThread, [this]() { 128 | 129 | CreateXunFeiTTSSocket(); 130 | }); 131 | 132 | 133 | } 134 | 135 | void UXGXunFeiTTSAsyncAction::RealeaseResources() 136 | { 137 | OnSoundWaveSuccess.Clear(); 138 | 139 | OnWavFileSuccess.Clear(); 140 | 141 | OnSoundWaveFail.Clear(); 142 | 143 | CloseXunFeiTTsSocket(); 144 | 145 | XunFeiAudioData.Empty(); 146 | 147 | SetReadyToDestroy(); 148 | 149 | } 150 | 151 | void UXGXunFeiTTSAsyncAction::CreateXunFeiTTSSocket() 152 | { 153 | FString APPID = TTSAppID; 154 | FString APISecret = TTSAPISecret; 155 | FString APIKey = TTSAPIKey; 156 | 157 | 158 | FString HttpDate = FDateTime::Now().UtcNow().ToHttpDate(); 159 | 160 | FString ServerURL = TEXT(""); 161 | 162 | FString host = TEXT("host: tts-api.xfyun.cn\n"); 163 | FString date = TEXT("date: ") + HttpDate + TEXT("\n"); 164 | FString requireLine = TEXT("GET /v2/tts HTTP/1.1"); 165 | 166 | FString signature_origin = host + date + requireLine; 167 | 168 | FString signature = UXGXunFeiCoreBPLibrary::XunFeiTTSHMACSHA256(APISecret, signature_origin); 169 | 170 | FString authorization_origin = 171 | FString::Printf(TEXT("api_key=\"%s\", algorithm=\"hmac-sha256\", headers=\"host date request-line\", signature=\"%s\""), *APIKey, *signature); 172 | 173 | FString authorization = FBase64::Encode(authorization_origin); 174 | 175 | HttpDate.ReplaceInline(TEXT(","), TEXT("%2C")); 176 | HttpDate.ReplaceInline(TEXT(" "), TEXT("%20")); 177 | HttpDate.ReplaceInline(TEXT(":"), TEXT("%3A")); 178 | 179 | ServerURL = TEXT("ws://tts-api.xfyun.cn/v2/tts?authorization="); 180 | ServerURL += authorization; 181 | ServerURL += TEXT("&date="); 182 | ServerURL += HttpDate; 183 | ServerURL += TEXT("&host=tts-api.xfyun.cn"); 184 | 185 | Socket = FWebSocketsModule::Get().CreateWebSocket(ServerURL); 186 | Socket->OnConnected().AddUObject(this, &UXGXunFeiTTSAsyncAction::OnConnected); 187 | Socket->OnConnectionError().AddUObject(this, &UXGXunFeiTTSAsyncAction::OnConnectionError); 188 | Socket->OnClosed().AddUObject(this, &UXGXunFeiTTSAsyncAction::OnClosed); 189 | Socket->OnMessage().AddUObject(this, &UXGXunFeiTTSAsyncAction::OnMessage); 190 | Socket->OnMessageSent().AddUObject(this, &UXGXunFeiTTSAsyncAction::OnMessageSent); 191 | 192 | Socket->Connect(); 193 | 194 | } 195 | 196 | void UXGXunFeiTTSAsyncAction::CloseXunFeiTTsSocket() 197 | { 198 | 199 | if (Socket.IsValid() && Socket->IsConnected()) 200 | { 201 | Socket->Close(); 202 | } 203 | 204 | Socket.Reset(); 205 | 206 | 207 | } 208 | 209 | void UXGXunFeiTTSAsyncAction::OnConnected() 210 | { 211 | UE_LOG(LogXGXunFeiTTS, Display, TEXT("[%s]:[%s] Connect Success!"), *FString(__FUNCTION__), *(AsyncID.ToString())); 212 | 213 | 214 | //UE_LOG(LogTemp, Error, TEXT("Src:[%s]"), *XunFeiText); 215 | 216 | auto UTF8String = StringCast(*XunFeiText); 217 | FString Base64XunFeiText = FBase64::Encode((uint8*)UTF8String.Get(), UTF8String.Length()); 218 | 219 | // //check right str after encode~ 220 | //TArray BackUTF8; 221 | //FBase64::Decode(Base64XunFeiText, BackUTF8); 222 | //FString Reulust = StringCast((UTF8CHAR*)BackUTF8.GetData(), BackUTF8.Num()).Get(); 223 | //UE_LOG(LogTemp,Error,TEXT("[%s]"), *Reulust); 224 | 225 | 226 | XunFeiTTSReqInfo.common.app_id = TTSAppID; 227 | XunFeiTTSReqInfo.data.text = Base64XunFeiText; 228 | 229 | XunFeiTTSReqInfo.business.speed = FMath::Clamp(XunFeiTTSReqInfo.business.speed, 0, 100); 230 | XunFeiTTSReqInfo.business.volume = FMath::Clamp(XunFeiTTSReqInfo.business.volume, 0, 100); 231 | XunFeiTTSReqInfo.business.pitch = FMath::Clamp(XunFeiTTSReqInfo.business.pitch, 0, 100); 232 | 233 | FString JsonStr; 234 | FJsonObjectConverter::UStructToJsonObjectString(XunFeiTTSReqInfo, JsonStr); 235 | 236 | Socket->Send(JsonStr); 237 | 238 | } 239 | 240 | void UXGXunFeiTTSAsyncAction::OnConnectionError(const FString& ErrorMessage) 241 | { 242 | 243 | UE_LOG(LogXGXunFeiTTS, Error, TEXT("[%s]:[%s] ConnectError,Message:[%s]!"), *FString(__FUNCTION__), *(AsyncID.ToString()), *ErrorMessage); 244 | 245 | CallOnFail(false, ErrorMessage); 246 | RealeaseResources(); 247 | 248 | } 249 | 250 | void UXGXunFeiTTSAsyncAction::OnClosed(int32 StatusCode, const FString& Reason, bool bWasClean) 251 | { 252 | 253 | UE_LOG(LogXGXunFeiTTS, Warning, TEXT("[%s]:[%s] ConnectOnClosed,StatusCode:[%d],Reason:[%s],bWasClean:[%s]!"), 254 | *FString(__FUNCTION__), *(AsyncID.ToString()), StatusCode, *Reason, bWasClean ? TEXT("true") : TEXT("false")); 255 | 256 | 257 | RealeaseResources(); 258 | 259 | 260 | } 261 | 262 | void UXGXunFeiTTSAsyncAction::OnMessage(const FString& Message) 263 | { 264 | //UE_LOG(LogXGXunFeiTTS, Log, TEXT("[%s], Message:%s"), *FString(__FUNCTION__), *Message); 265 | 266 | FXGXunFeiTTSRespInfo XunFeiTTSRespInfo; 267 | FJsonObjectConverter::JsonObjectStringToUStruct(Message, &XunFeiTTSRespInfo); 268 | 269 | if (XunFeiTTSRespInfo.code == 0) 270 | { 271 | FString Audio = XunFeiTTSRespInfo.data.audio; 272 | int32 Status = XunFeiTTSRespInfo.data.status; 273 | FString Ced = XunFeiTTSRespInfo.data.ced; 274 | 275 | bool bRightStatus = Status == 1 || Status == 2; 276 | 277 | if (!Audio.IsEmpty() && bRightStatus) 278 | { 279 | TArray AudioData; 280 | FBase64::Decode(Audio, AudioData); 281 | XunFeiAudioData.Append(AudioData); 282 | } 283 | 284 | if (Status == 2) 285 | { 286 | 287 | if (bSaveToLocal) 288 | { 289 | 290 | CallGenerateWavFile(); 291 | 292 | } 293 | 294 | USoundWave* SoundWave = UXGXunFeiCoreBPLibrary::ImportPCMToSoundWave(XunFeiAudioData); 295 | 296 | UE_LOG(LogXGXunFeiTTS, Log, TEXT("[%s]:Text To SPeech Success!"), *FString(__FUNCTION__)); 297 | 298 | CallOnSoundWaveSuccess(true, TEXT("Text To SPeech Success!"), SoundWave); 299 | 300 | RealeaseResources(); 301 | 302 | } 303 | 304 | 305 | } 306 | else 307 | { 308 | FString ErrorMessage = FString::Printf(TEXT("MessageError-Code:[%d]-Message:[%s]-sid-[%s]"), 309 | XunFeiTTSRespInfo.code, 310 | *(XunFeiTTSRespInfo.message), 311 | *(XunFeiTTSRespInfo.sid)); 312 | 313 | UE_LOG(LogXGXunFeiTTS, Error, TEXT("[%s]:[%s]"), *FString(__FUNCTION__), *ErrorMessage); 314 | 315 | CallOnFail(false, ErrorMessage); 316 | 317 | RealeaseResources(); 318 | 319 | } 320 | 321 | 322 | 323 | } 324 | 325 | void UXGXunFeiTTSAsyncAction::OnMessageSent(const FString& MessageString) 326 | { 327 | 328 | 329 | } 330 | 331 | void UXGXunFeiTTSAsyncAction::CallOnSoundWaveSuccess(bool InbResult, FString InMessage, USoundWave* InSoundWavePtr) 332 | { 333 | FXGXunFeiTTSDelegate TempXunFeiTTSDelegate = OnSoundWaveSuccess; 334 | FGuid InAsyncID = AsyncID; 335 | 336 | InSoundWavePtr->AddToRoot(); 337 | 338 | AsyncTask(ENamedThreads::GameThread, [=]() { 339 | 340 | InSoundWavePtr->RemoveFromRoot(); 341 | 342 | TempXunFeiTTSDelegate.Broadcast(InAsyncID, InbResult, InMessage, InSoundWavePtr); 343 | 344 | 345 | }); 346 | } 347 | 348 | 349 | 350 | void UXGXunFeiTTSAsyncAction::CallOnFail(bool InbResult, FString InMessage, USoundWave* InSoundWavePtr) 351 | { 352 | FXGXunFeiTTSDelegate TempXunFeiTTSDelegate = OnSoundWaveFail; 353 | FGuid InAsyncID = AsyncID; 354 | 355 | AsyncTask(ENamedThreads::GameThread, [=]() { 356 | 357 | TempXunFeiTTSDelegate.Broadcast(InAsyncID, InbResult, InMessage, InSoundWavePtr); 358 | 359 | 360 | }); 361 | 362 | } 363 | 364 | void UXGXunFeiTTSAsyncAction::CallGenerateWavFile() 365 | { 366 | FXGXunFeiTTSDelegate TempOnWavFileSuccess = OnWavFileSuccess; 367 | FXGXunFeiTTSDelegate TempOnWavFileFail = OnWavFileFail; 368 | 369 | 370 | TArray AudioData = XunFeiAudioData; 371 | FString WavFilePath = SaveFileFullPath; 372 | FGuid OutAsyncID = AsyncID; 373 | 374 | AsyncTask(ENamedThreads::AnyThread, [TempOnWavFileSuccess, TempOnWavFileFail, AudioData, WavFilePath, OutAsyncID]() { 375 | 376 | 377 | TArray WaveData; 378 | UXGXunFeiCoreBPLibrary::ConvertPCMToWave(AudioData, WaveData); 379 | 380 | bool bSave = FFileHelper::SaveArrayToFile(WaveData, *WavFilePath); 381 | FXGXunFeiTTSDelegate TempXunFeiTTSDelegate; 382 | FString WavFileMessage = TEXT(""); 383 | 384 | if (bSave) 385 | { 386 | TempXunFeiTTSDelegate = TempOnWavFileSuccess; 387 | WavFileMessage = TEXT("The wav file has been finished !"); 388 | } 389 | else 390 | { 391 | TempXunFeiTTSDelegate = TempOnWavFileFail; 392 | WavFileMessage = TEXT("The wav file failed to be generated"); 393 | } 394 | 395 | AsyncTask(ENamedThreads::GameThread, [TempXunFeiTTSDelegate, bSave, WavFileMessage, OutAsyncID]() { 396 | 397 | TempXunFeiTTSDelegate.Broadcast(OutAsyncID, bSave, WavFileMessage, nullptr); 398 | 399 | }); 400 | 401 | 402 | 403 | }); 404 | 405 | 406 | 407 | 408 | 409 | } 410 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Private/Log/LogXGXunFeiTTS.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #include "LogXGXunFeiTTS.h" 3 | 4 | DEFINE_LOG_CATEGORY(LogXGXunFeiTTS); -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Private/Type/XGXunFeiTTSReqType.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiTTSReqType.h" 4 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Private/Type/XGXunFeiTTSRespType.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiTTSRespType.h" -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Private/XGXunFeiTTS.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiTTS.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FXGXunFeiTTSModule" 6 | 7 | void FXGXunFeiTTSModule::StartupModule() 8 | { 9 | 10 | 11 | } 12 | 13 | void FXGXunFeiTTSModule::ShutdownModule() 14 | { 15 | 16 | 17 | } 18 | 19 | #undef LOCTEXT_NAMESPACE 20 | 21 | IMPLEMENT_MODULE(FXGXunFeiTTSModule, XGXunFeiTTS) -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Private/XGXunFeiTTSBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #include "XGXunFeiTTSBPLibrary.h" 4 | 5 | 6 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Public/AsyncNode/XGXunFeiTTSAsyncAction.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include "XGXunFeiCoreAsyncAction.h" 8 | #include "XGXunFeiTTSReqType.h" 9 | 10 | #include "XGXunFeiTTSAsyncAction.generated.h" 11 | 12 | 13 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FXGXunFeiTTSDelegate, FGuid, AsyncID, bool, bResult, FString, Message, USoundWave*, SoundWavePtr); 14 | 15 | 16 | class IWebSocket; 17 | class USoundWave; 18 | /** 19 | * UXGXunFeiTTSAsyncAction 20 | * Connect to iFlyTek Text To Speech Stream Webp Api 21 | * 22 | */ 23 | UCLASS(meta = (HideThen = true)) 24 | class XGXUNFEITTS_API UXGXunFeiTTSAsyncAction : public UXGXunFeiCoreAsyncAction 25 | { 26 | GENERATED_BODY() 27 | 28 | friend class UXGXunFeiLinkBPLibrary; 29 | 30 | public: 31 | 32 | UXGXunFeiTTSAsyncAction(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); 33 | 34 | virtual ~UXGXunFeiTTSAsyncAction(); 35 | 36 | protected: 37 | /** 38 | * XGXunFeiTextToSpeech BlueprintNode 39 | * If you want to use in C++,please see XGXunFeiLinkBPLibrary.h . 40 | * 41 | * @param WorldContextObject WorldContext 42 | * 43 | * @param InTTSAppID iFlyTek AppID 44 | * @param InTTSAPISecret iFlyTek APISecret 45 | * @param InTTSAPIKey iFlyTek APIKey 46 | * 47 | * @param InText The Str you want to Convert to Audio 48 | * @param bInSaveToLocal Whether to Save to local disk 49 | * @param InSaveFileFullPath The FilePath which the wmv file will save to . 50 | * This directory must exist,and the file name must end with ".wav" 51 | * This path is absoult path! 52 | * @param InXunFeiTTSReqInfo About TTS Settins,more to look iflytesk document.you can choose which voice to say,and so on. 53 | * 54 | * @return UXGXunFeiTTSAsyncAction* Self object ptr 55 | */ 56 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", 57 | WorldContext = "WorldContextObject", 58 | DisplayName = "XunFeiTextToSpeech", 59 | Keywords = "XG XunFei TTS Text To Speech "), 60 | Category = "XGXunFeiLink|TTS") 61 | static UXGXunFeiTTSAsyncAction* XGXunFeiTextToSpeech(UObject* WorldContextObject, 62 | FString InTTSAppID, 63 | FString InTTSAPISecret, 64 | FString InTTSAPIKey, 65 | const FString& InText, 66 | bool bInSaveToLocal, 67 | const FString& InSaveFileFullPath, 68 | FXGXunFeiTTSReqInfo InXunFeiTTSReqInfo); 69 | 70 | 71 | 72 | public: 73 | 74 | virtual void Activate() override; 75 | 76 | 77 | virtual void Activate_Internal() override; 78 | 79 | 80 | protected: 81 | 82 | void RealeaseResources(); 83 | 84 | void CreateXunFeiTTSSocket(); 85 | 86 | void CloseXunFeiTTsSocket(); 87 | 88 | FORCEINLINE void SetXunFeiText(const FString& InXunFeiText) { XunFeiText = InXunFeiText; } 89 | FORCEINLINE void SetIsSaveToLocal(bool bInSaveToLocal) { bSaveToLocal = bInSaveToLocal; } 90 | FORCEINLINE void SetSaveFileFullPath(const FString& InSaveFilePath) { SaveFileFullPath = InSaveFilePath; } 91 | FORCEINLINE void SetXunFeiTTSReqInfo(const FXGXunFeiTTSReqInfo& InXunFeiTTSReqInfo) { XunFeiTTSReqInfo = InXunFeiTTSReqInfo; } 92 | protected: 93 | 94 | void OnConnected(); 95 | void OnConnectionError(const FString& ErrorMessage); 96 | void OnClosed(int32 StatusCode, const FString& Reason, bool bWasClean); 97 | void OnMessage(const FString& Message); 98 | void OnMessageSent(const FString& MessageString); 99 | 100 | void CallOnSoundWaveSuccess(bool InbResult, FString InMessage, USoundWave* InSoundWavePtr); 101 | 102 | 103 | void CallOnFail(bool InbResult, FString InMessage, USoundWave* InSoundWavePtr = nullptr); 104 | 105 | 106 | void CallGenerateWavFile(); 107 | 108 | public: 109 | 110 | UPROPERTY(BlueprintAssignable) 111 | FXGXunFeiTTSDelegate Then; 112 | 113 | UPROPERTY(BlueprintAssignable) 114 | FXGXunFeiTTSDelegate OnSoundWaveSuccess; 115 | 116 | UPROPERTY(BlueprintAssignable) 117 | FXGXunFeiTTSDelegate OnSoundWaveFail; 118 | 119 | UPROPERTY(BlueprintAssignable) 120 | FXGXunFeiTTSDelegate OnWavFileSuccess; 121 | 122 | UPROPERTY(BlueprintAssignable) 123 | FXGXunFeiTTSDelegate OnWavFileFail; 124 | 125 | 126 | 127 | private: 128 | 129 | FString TTSAppID=TEXT(""); 130 | FString TTSAPISecret = TEXT(""); 131 | FString TTSAPIKey = TEXT(""); 132 | 133 | TSharedPtr Socket; 134 | 135 | TArray XunFeiAudioData; 136 | 137 | FString XunFeiText; 138 | 139 | bool bSaveToLocal = false; 140 | 141 | FString SaveFileFullPath = TEXT(""); 142 | 143 | FXGXunFeiTTSReqInfo XunFeiTTSReqInfo; 144 | 145 | 146 | 147 | 148 | 149 | }; 150 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Public/Log/LogXGXunFeiTTS.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | 6 | DECLARE_LOG_CATEGORY_EXTERN(LogXGXunFeiTTS, Log, All); 7 | 8 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Public/Type/XGXunFeiTTSReqType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | /** 4 | * 5 | * Be careful: 6 | * This TTS Module only support China region. 7 | * If you want to use it in other regiion,you can use TTSG Module. 8 | * iFlyTek Text To Speech Steam Document: 9 | * Chinese: 10 | * https://www.xfyun.cn/doc/tts/online_tts/API.html 11 | * 12 | */ 13 | 14 | 15 | #pragma once 16 | #include "CoreMinimal.h" 17 | 18 | #include "XGXunFeiTTSReqType.generated.h" 19 | 20 | 21 | 22 | /** 23 | * FXGXunFeiTTSReqCommonInfo 24 | */ 25 | USTRUCT() 26 | struct XGXUNFEITTS_API FXGXunFeiTTSReqCommonInfo 27 | { 28 | GENERATED_BODY() 29 | 30 | 31 | public: 32 | /** 33 | * Parameter:appid 34 | * Type:string 35 | * Required:Yes 36 | * Description:Appid message applied from the platform 37 | * Example:5f9c6d6a 38 | */ 39 | UPROPERTY() 40 | FString app_id = TEXT(""); 41 | 42 | }; 43 | 44 | /** 45 | * FXGXunFeiTTSReqBusinessInfo 46 | */ 47 | USTRUCT(BlueprintType) 48 | struct XGXUNFEITTS_API FXGXunFeiTTSReqBusinessInfo 49 | { 50 | GENERATED_BODY() 51 | 52 | 53 | public: 54 | /** 55 | * Parameter:aue 56 | * Type:string 57 | * Required:Yes 58 | * Description: 59 | * Audio coding, optional values: 60 | * raw:Uncompressed pcm 61 | * lame:mp3 (when aue=lame,required: sfl=1) 62 | * speex-org-wb;7: Open source standards speex(for speex_wideband,16k) 63 | * The number represents the specified compression level (the default level is 8) 64 | 65 | * speex-org-nb;7: Open source standards speex(for speex_narrowband,8k) 66 | * The number represents the specified compression level (the default level is 8) 67 | 68 | * speex;7:Standard open source compression format, compression level 1~10, default 7 (8k IFlytek Custom speex) 69 | * speex-wb;7:Compression format, compression level 1~10, default is 7 (16k IFlytek Custom speex) 70 | * Example: 71 | * "raw" 72 | * "speex-org-wb;7" ,The number Required 73 | * The number represents the specified compression level (the default level is 8) 74 | * 75 | * 76 | * Open source standards speex code and iFlyTek speexDescription ,please refer to Audio Description 77 | * 78 | * Only Support "raw". 79 | */ 80 | UPROPERTY() 81 | FString aue = TEXT("raw"); 82 | 83 | 84 | 85 | /** 86 | * Parameter:sfl 87 | * Type:int 88 | * Required:No 89 | * Description: 90 | * When aue=lame,Turn on stream return 91 | * mp3,audio format 92 | * value:1 ,Turn on. 93 | * 94 | * Example:1 95 | * This plug-in does not use this value 96 | 97 | */ 98 | //UPROPERTY() 99 | int32 sfl = -1; 100 | 101 | /** 102 | * Parameter:auf 103 | * Type:string 104 | * Required:No 105 | * Description: 106 | * Audio sampling rate, optional values: 107 | * audio/L16;rate=8000:Synthesize 8K audio 108 | * audio/L16;rate=16000:Synthesize 16K audio 109 | * auf No-pass value:Synthesize 16K audio 110 | * Example: 111 | * "audio/L16;rate=16000" 112 | * 113 | */ 114 | UPROPERTY() 115 | FString auf = TEXT("audio/L16;rate=16000"); 116 | 117 | 118 | 119 | /** 120 | * Parameter:vcn 121 | * Type:string 122 | * Required:Yes 123 | * Description: 124 | * Pronunciation person, optional value: 125 | * "xiaoyan", 126 | * "aisjiuxu", 127 | * "aisxping", 128 | * "aisjinger", 129 | * "aisbabyxu" 130 | * Please go to the console to add a trial or purchase pronunciation person, after adding the pronunciation person Parameter value will be displayed 131 | * Example: 132 | * "xiaoyan" 133 | * 134 | */ 135 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 136 | FString vcn = TEXT("xiaoyan"); 137 | 138 | /** 139 | * Parameter:speed 140 | * Type:int 141 | * Required:No 142 | * Description: 143 | * The value is optional: [0-100]. The default value is 50 144 | * Example: 145 | * 50 146 | * 147 | */ 148 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 149 | int32 speed = 50; 150 | 151 | /** 152 | * Parameter:volume 153 | * Type:int 154 | * Required:No 155 | * Description: 156 | * The value is optional: [0-100]. The default value is 50 157 | * Example: 158 | * 50 159 | * 160 | */ 161 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 162 | int32 volume = 50; 163 | 164 | /** 165 | * Parameter:pitch 166 | * Type:int 167 | * Required:No 168 | * Description: 169 | * The value is optional: [0-100]. The default value is 50 170 | * Example: 171 | * 50 172 | * 173 | */ 174 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 175 | int32 pitch = 50; 176 | 177 | /** 178 | * Parameter:bgs 179 | * Type:int 180 | * Required:No 181 | * Description: 182 | * Background sound for synthesized audio 183 | * 0: No background sound (default) 184 | * 1: Background sound 185 | * Example: 186 | * 0 187 | * 188 | */ 189 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 190 | int32 bgs = 0; 191 | 192 | 193 | /** 194 | * Parameter:tte 195 | * Type:string 196 | * Required:No 197 | * Description: 198 | * Text encoding format 199 | * GB2312 200 | * GBK 201 | * BIG5 202 | * UNICODE (UNICODE encoding is Required for minor languages, and utf16 encoding is required for synthesized text. See javaExampledemo for details.) 203 | * GB18030 204 | * UTF8(minority language) 205 | * Example: 206 | * "UTF8" 207 | * 208 | */ 209 | UPROPERTY() 210 | FString tte = TEXT("UTF8"); 211 | 212 | /** 213 | * Parameter:reg 214 | * Type:string 215 | * Required:No 216 | * Description: 217 | * Set English pronunciation: 218 | * 0: Automatic judgment processing, if not sure will be processed according to the English word spelling (default) 219 | * 1: All English is pronounced alphabetically 220 | * 2: Automatic judgment processing, if not sure will be read according to the letter 221 | * Default pronunciation according to English words 222 | * Example: 223 | * "2" 224 | * 225 | */ 226 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 227 | FString reg = TEXT("2"); 228 | 229 | /** 230 | * Parameter:rdn 231 | * Type:string 232 | * Required:No 233 | * Description: 234 | * Synthetic audio digital pronunciation 235 | * 0: Automatic judgment (default) 236 | * 1: full value 237 | * 2: complete string 238 | * 3: The string takes precedence 239 | * Example: "0" 240 | * 241 | */ 242 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 243 | FString rdn = TEXT("0"); 244 | 245 | 246 | 247 | }; 248 | 249 | 250 | 251 | /** 252 | * FXGXunFeiTTSReqDataInfo 253 | */ 254 | USTRUCT() 255 | struct XGXUNFEITTS_API FXGXunFeiTTSReqDataInfo 256 | { 257 | GENERATED_BODY() 258 | 259 | 260 | public: 261 | /** 262 | * Parameter:text 263 | * Type:string 264 | * Required:No 265 | * Description: 266 | * The text content needs to be base64 encoded; 267 | * The maximum length before base64 encoding must be less than 8000 bytes, about 2000 Chinese characters 268 | * 269 | * 270 | */ 271 | UPROPERTY() 272 | FString text = TEXT(""); 273 | 274 | 275 | /** 276 | * Parameter:text 277 | * Type:int 278 | * Required:Yes 279 | * Description: 280 | * Data status, fixed to 2 281 | * Note: Since the text of stream synthesis can only be transmitted once, and multiple segmented transmission is not supported, statusRequired is 2. 282 | * 283 | */ 284 | UPROPERTY() 285 | int32 status = 2; 286 | 287 | 288 | }; 289 | 290 | 291 | 292 | 293 | /** 294 | * FXGXunFeiTTSReqInfo 295 | */ 296 | USTRUCT(BlueprintType) 297 | struct XGXUNFEITTS_API FXGXunFeiTTSReqInfo 298 | { 299 | GENERATED_BODY() 300 | 301 | friend class UXGXunFeiTTSAsyncAction; 302 | 303 | public: 304 | /** 305 | * Parameter:business 306 | * Type:object 307 | * Required:Yes 308 | * Description: 309 | * Service parameter. 310 | * 311 | */ 312 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "XG iFylTek TTS") 313 | FXGXunFeiTTSReqBusinessInfo business; 314 | 315 | protected: 316 | /** 317 | * Parameter:common 318 | * Type:object 319 | * Required:Yes 320 | * Description: 321 | * Common parameter. 322 | * 323 | */ 324 | UPROPERTY() 325 | FXGXunFeiTTSReqCommonInfo common; 326 | /** 327 | * Parameter:data 328 | * Type:object 329 | * Required:Yes 330 | * Description: 331 | * Service data flow parameters. 332 | * 333 | */ 334 | UPROPERTY() 335 | FXGXunFeiTTSReqDataInfo data; 336 | 337 | }; -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Public/Type/XGXunFeiTTSRespType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "XGXunFeiTTSRespType.generated.h" 5 | 6 | 7 | 8 | USTRUCT() 9 | struct XGXUNFEITTS_API FXGXunFeiTTSRespInfoData 10 | { 11 | GENERATED_BODY() 12 | 13 | public: 14 | 15 | 16 | /** 17 | * Parameter:audio 18 | * Type:string 19 | * Description: 20 | * The synthesized audio snippets are encoded in base64 21 | * 22 | */ 23 | UPROPERTY() 24 | FString audio=TEXT(""); 25 | 26 | /** 27 | * Parameter:code 28 | * Type:int 29 | * Description: 30 | * Current audio stream status, 1 indicates synthesis, 2 indicates synthesis end 31 | * 32 | */ 33 | UPROPERTY() 34 | int32 status = -1; 35 | 36 | /** 37 | * Parameter:ced 38 | * Type:string 39 | * Description: 40 | * Synthesis progress refers to the number of bytes of the current synthesized text 41 | * Note: Please note that the composition is cut by sentence, if there is only one sentence of text, the ced is the same each time the result is returned. 42 | * 43 | */ 44 | UPROPERTY() 45 | FString ced=TEXT(""); 46 | }; 47 | 48 | 49 | 50 | 51 | 52 | USTRUCT() 53 | struct XGXUNFEITTS_API FXGXunFeiTTSRespInfo 54 | { 55 | GENERATED_BODY() 56 | 57 | friend class UXGXunFeiTTSAsyncAction; 58 | 59 | public: 60 | 61 | /** 62 | * Parameter:code 63 | * Type:int 64 | * Description: 65 | * Return code, 0 indicates success, other indicates exception. For details, see the error code. 66 | * 67 | */ 68 | UPROPERTY() 69 | int32 code=-1; 70 | 71 | /** 72 | * Parameter:message 73 | * Type:string 74 | * Description: 75 | * Description 76 | * 77 | */ 78 | UPROPERTY() 79 | FString message=TEXT(""); 80 | 81 | /** 82 | * Parameter名:data 83 | * Type:object 84 | * Description: 85 | * data may be returned as null. When referring to the Example code, be careful to make a non-null judgment 86 | * 87 | */ 88 | UPROPERTY() 89 | FXGXunFeiTTSRespInfoData data; 90 | 91 | /** 92 | * Parameter名:sid 93 | * Type:string 94 | * Description: 95 | * The id of this session is returned only on the first frame request 96 | * 97 | */ 98 | UPROPERTY() 99 | FString sid = TEXT(""); 100 | 101 | 102 | 103 | }; 104 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Public/XGXunFeiTTS.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | /** 7 | * FXGXunFeiTTSModule 8 | */ 9 | class FXGXunFeiTTSModule : public IModuleInterface 10 | { 11 | public: 12 | 13 | 14 | virtual void StartupModule() override; 15 | virtual void ShutdownModule() override; 16 | }; 17 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/Public/XGXunFeiTTSBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Kismet/BlueprintFunctionLibrary.h" 6 | #include "XGXunFeiTTSBPLibrary.generated.h" 7 | 8 | 9 | UCLASS() 10 | class UXGXunFeiTTSBPLibrary : public UBlueprintFunctionLibrary 11 | { 12 | GENERATED_BODY() 13 | 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/Source/XGXunFeiTTS/XGXunFeiTTS.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Xiao Gang. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class XGXunFeiTTS : ModuleRules 6 | { 7 | public XGXunFeiTTS(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicIncludePaths.AddRange( 12 | new string[] { 13 | "$(ModuleDir)/Public/AsyncNode", 14 | "$(ModuleDir)/Public/Type", 15 | } 16 | ); 17 | 18 | 19 | PrivateIncludePaths.AddRange( 20 | new string[] { 21 | "XGXunFeiTTS/Public/AsyncNode", 22 | "XGXunFeiTTS/Public/Log", 23 | "XGXunFeiTTS/Public/Type" 24 | } 25 | ); 26 | 27 | 28 | PublicDependencyModuleNames.AddRange( 29 | new string[] 30 | { 31 | "Core", 32 | "XGXunFeiCore" 33 | } 34 | ); 35 | 36 | 37 | PrivateDependencyModuleNames.AddRange( 38 | new string[] 39 | { 40 | "CoreUObject", 41 | "Engine", 42 | "WebSockets", 43 | "Json", 44 | "JsonUtilities", 45 | } 46 | ); 47 | 48 | if (Target.Platform == UnrealTargetPlatform.Android) 49 | { 50 | PrivateDependencyModuleNames.AddRange( 51 | new string[] 52 | { 53 | "Launch", 54 | } 55 | ); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /XGXunFeiLink-v2.4-FreeTrial(试用代码,可打包)/XGXunFeiLink.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "2.4", 5 | "FriendlyName": "XGXunFeiLink-Trial Version", 6 | "Description": "This plugin helps to connect XunFei(iFlyTek) to UnrealEngine 5.It contains Real-Time Automated Speech Recognition(Global) and Online Text To Speech(Global). It contains Real-Time Speech To Text , Stream Text To Speech,and Spark.It contains SparkHelper,SparkHint,SparkV3FunctionCall,ImgUnderstand", 7 | "Category": "XG", 8 | "CreatedBy": "XiaoGang", 9 | "CreatedByURL": "https://github.com/liuhuagang/XGIflytekToUE", 10 | "DocsURL": "https://github.com/liuhuagang/XGIflytekToUE/blob/main/README.md", 11 | "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/fe3549779b284f908e112db8cede2871", 12 | "SupportURL": "", 13 | "EngineVersion": "5.3.0", 14 | "CanContainContent": false, 15 | "IsBetaVersion": true, 16 | "IsExperimentalVersion": false, 17 | "EnabledByDefault": false, 18 | "Installed": false, 19 | "Modules": [ 20 | { 21 | "Name": "XGXunFeiBase", 22 | "Type": "Runtime", 23 | "LoadingPhase": "PreDefault", 24 | "PlatformAllowList": [ 25 | "Win64", 26 | "Android" 27 | ] 28 | 29 | }, 30 | { 31 | "Name": "XGXunFeiCore", 32 | "Type": "Runtime", 33 | "LoadingPhase": "Default", 34 | "PlatformAllowList": [ 35 | "Win64", 36 | "Android" 37 | ] 38 | }, 39 | { 40 | "Name": "XGXunFeiSTT", 41 | "Type": "Runtime", 42 | "LoadingPhase": "PostDefault", 43 | "PlatformAllowList": [ 44 | "Win64", 45 | "Android" 46 | ] 47 | }, 48 | { 49 | "Name": "XGXunFeiTTS", 50 | "Type": "Runtime", 51 | "LoadingPhase": "PostDefault", 52 | "PlatformAllowList": [ 53 | "Win64", 54 | "Android" 55 | ] 56 | }, 57 | { 58 | "Name": "XGXunFeiLink", 59 | "Type": "Runtime", 60 | "LoadingPhase": "PostEngineInit", 61 | "PlatformAllowList": [ 62 | "Win64", 63 | "Android" 64 | ] 65 | } 66 | ], 67 | "Plugins": [ 68 | { 69 | "Name": "AudioCapture", 70 | "Enabled": true 71 | } 72 | 73 | ] 74 | } -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Config/DefaultEditor.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Config/DefaultEditor.ini -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | [/Script/EngineSettings.GameMapsSettings] 4 | GameDefaultMap=/Game/XGXunFei/Maps/MainMap.MainMap 5 | EditorStartupMap=/Game/XGXunFei/Maps/MainMap.MainMap 6 | GameInstanceClass=/Game/XGXunFei/GameFrame/BP_XunFeiGameInstance.BP_XunFeiGameInstance_C 7 | 8 | [/Script/WindowsTargetPlatform.WindowsTargetSettings] 9 | DefaultGraphicsRHI=DefaultGraphicsRHI_DX12 10 | -D3D12TargetedShaderFormats=PCD3D_SM5 11 | +D3D12TargetedShaderFormats=PCD3D_SM6 12 | -D3D11TargetedShaderFormats=PCD3D_SM5 13 | +D3D11TargetedShaderFormats=PCD3D_SM5 14 | Compiler=Default 15 | AudioSampleRate=48000 16 | AudioCallbackBufferFrameSize=1024 17 | AudioNumBuffersToEnqueue=1 18 | AudioMaxChannels=0 19 | AudioNumSourceWorkers=4 20 | SpatializationPlugin= 21 | SourceDataOverridePlugin= 22 | ReverbPlugin= 23 | OcclusionPlugin= 24 | CompressionOverrides=(bOverrideCompressionTimes=False,DurationThreshold=5.000000,MaxNumRandomBranches=0,SoundCueQualityIndex=0) 25 | CacheSizeKB=65536 26 | MaxChunkSizeOverrideKB=0 27 | bResampleForDevice=False 28 | MaxSampleRate=48000.000000 29 | HighSampleRate=32000.000000 30 | MedSampleRate=24000.000000 31 | LowSampleRate=12000.000000 32 | MinSampleRate=8000.000000 33 | CompressionQualityModifier=1.000000 34 | AutoStreamingThreshold=0.000000 35 | SoundCueCookQualityIndex=-1 36 | 37 | 38 | [/Script/HardwareTargeting.HardwareTargetingSettings] 39 | TargetedHardwareClass=Desktop 40 | AppliedTargetedHardwareClass=Desktop 41 | DefaultGraphicsPerformance=Maximum 42 | AppliedDefaultGraphicsPerformance=Maximum 43 | 44 | [/Script/Engine.RendererSettings] 45 | r.GenerateMeshDistanceFields=True 46 | r.DynamicGlobalIlluminationMethod=1 47 | r.ReflectionMethod=1 48 | r.Shadow.Virtual.Enable=1 49 | r.DefaultFeature.AutoExposure.ExtendDefaultLuminanceRange=True 50 | 51 | [/Script/WorldPartitionEditor.WorldPartitionEditorSettings] 52 | CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet' 53 | 54 | [/Script/Engine.UserInterfaceSettings] 55 | bAuthorizeAutomaticWidgetVariableCreation=False 56 | 57 | [/Script/Engine.Engine] 58 | +ActiveGameNameRedirects=(OldGameName="TP_BlankBP",NewGameName="/Script/XunFeiLinkDemo") 59 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_BlankBP",NewGameName="/Script/XunFeiLinkDemo") 60 | 61 | [/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings] 62 | bEnablePlugin=True 63 | bAllowNetworkConnection=True 64 | SecurityToken=66C7896745DAE8FFAA17649EC560A59A 65 | bIncludeInShipping=False 66 | bAllowExternalStartInShipping=False 67 | bCompileAFSProject=False 68 | bUseCompression=False 69 | bLogFiles=False 70 | bReportStats=False 71 | ConnectionType=USBOnly 72 | bUseManualIPAddress=False 73 | ManualIPAddress= 74 | 75 | -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | [/Script/EngineSettings.GeneralProjectSettings] 4 | ProjectID=53D47A5E4DB8FA223D81C3B3285A2C24 5 | 6 | [/Script/UnrealEd.ProjectPackagingSettings] 7 | Build=IfProjectHasCode 8 | BuildConfiguration=PPBC_Development 9 | BuildTarget= 10 | FullRebuild=False 11 | ForDistribution=False 12 | IncludeDebugFiles=False 13 | BlueprintNativizationMethod=Disabled 14 | bIncludeNativizedAssetsInProjectGeneration=False 15 | bExcludeMonolithicEngineHeadersInNativizedCode=False 16 | UsePakFile=True 17 | bUseIoStore=True 18 | bUseZenStore=False 19 | bMakeBinaryConfig=False 20 | bGenerateChunks=False 21 | bGenerateNoChunks=False 22 | bChunkHardReferencesOnly=False 23 | bForceOneChunkPerFile=False 24 | MaxChunkSize=0 25 | bBuildHttpChunkInstallData=False 26 | HttpChunkInstallDataDirectory=(Path="") 27 | WriteBackMetadataToAssetRegistry=Disabled 28 | bCompressed=True 29 | PackageCompressionFormat=Oodle 30 | bForceUseProjectCompressionFormatIgnoreHardwareOverride=False 31 | PackageAdditionalCompressionOptions= 32 | PackageCompressionMethod=Kraken 33 | PackageCompressionLevel_DebugDevelopment=4 34 | PackageCompressionLevel_TestShipping=5 35 | PackageCompressionLevel_Distribution=7 36 | PackageCompressionMinBytesSaved=1024 37 | PackageCompressionMinPercentSaved=5 38 | bPackageCompressionEnableDDC=False 39 | PackageCompressionMinSizeToConsiderDDC=0 40 | HttpChunkInstallDataVersion= 41 | IncludePrerequisites=True 42 | IncludeAppLocalPrerequisites=False 43 | bShareMaterialShaderCode=True 44 | bDeterministicShaderCodeOrder=False 45 | bSharedMaterialNativeLibraries=True 46 | ApplocalPrerequisitesDirectory=(Path="") 47 | IncludeCrashReporter=False 48 | InternationalizationPreset=English 49 | -CulturesToStage=en 50 | +CulturesToStage=en 51 | LocalizationTargetCatchAllChunkId=0 52 | bCookAll=False 53 | bCookMapsOnly=False 54 | bSkipEditorContent=False 55 | bSkipMovies=False 56 | -IniKeyDenylist=KeyStorePassword 57 | -IniKeyDenylist=KeyPassword 58 | -IniKeyDenylist=rsa.privateexp 59 | -IniKeyDenylist=rsa.modulus 60 | -IniKeyDenylist=rsa.publicexp 61 | -IniKeyDenylist=aes.key 62 | -IniKeyDenylist=SigningPublicExponent 63 | -IniKeyDenylist=SigningModulus 64 | -IniKeyDenylist=SigningPrivateExponent 65 | -IniKeyDenylist=EncryptionKey 66 | -IniKeyDenylist=DevCenterUsername 67 | -IniKeyDenylist=DevCenterPassword 68 | -IniKeyDenylist=IOSTeamID 69 | -IniKeyDenylist=SigningCertificate 70 | -IniKeyDenylist=MobileProvision 71 | -IniKeyDenylist=IniKeyDenylist 72 | -IniKeyDenylist=IniSectionDenylist 73 | +IniKeyDenylist=KeyStorePassword 74 | +IniKeyDenylist=KeyPassword 75 | +IniKeyDenylist=rsa.privateexp 76 | +IniKeyDenylist=rsa.modulus 77 | +IniKeyDenylist=rsa.publicexp 78 | +IniKeyDenylist=aes.key 79 | +IniKeyDenylist=SigningPublicExponent 80 | +IniKeyDenylist=SigningModulus 81 | +IniKeyDenylist=SigningPrivateExponent 82 | +IniKeyDenylist=EncryptionKey 83 | +IniKeyDenylist=DevCenterUsername 84 | +IniKeyDenylist=DevCenterPassword 85 | +IniKeyDenylist=IOSTeamID 86 | +IniKeyDenylist=SigningCertificate 87 | +IniKeyDenylist=MobileProvision 88 | +IniKeyDenylist=IniKeyDenylist 89 | +IniKeyDenylist=IniSectionDenylist 90 | -IniSectionDenylist=HordeStorageServers 91 | -IniSectionDenylist=StorageServers 92 | +IniSectionDenylist=HordeStorageServers 93 | +IniSectionDenylist=StorageServers 94 | +MapsToCook=(FilePath="/Game/XGXunFei/Maps/MainMap") 95 | +MapsToCook=(FilePath="/Game/XGXunFei/Maps/TalkMap") 96 | 97 | -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Config/DefaultInput.ini: -------------------------------------------------------------------------------- 1 | [/Script/Engine.InputSettings] 2 | -AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 3 | -AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 4 | -AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 5 | -AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 6 | -AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 7 | -AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 8 | -AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 9 | +AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 10 | +AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 11 | +AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 12 | +AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 13 | +AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 14 | +AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 15 | +AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 16 | +AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 17 | +AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 18 | +AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 19 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 20 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 21 | +AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 22 | +AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 23 | +AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 24 | +AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 25 | +AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 26 | +AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 27 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 28 | +AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 29 | +AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 30 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 31 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 32 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 33 | +AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 34 | +AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 35 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 36 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 37 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 38 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 39 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 40 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 41 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 42 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 43 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 44 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 45 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 46 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 47 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 48 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 49 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 50 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 51 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 52 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 53 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 54 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 55 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 56 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 57 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 58 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 59 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 60 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 61 | bAltEnterTogglesFullscreen=True 62 | bF11TogglesFullscreen=True 63 | bUseMouseForTouch=False 64 | bEnableMouseSmoothing=True 65 | bEnableFOVScaling=True 66 | bCaptureMouseOnLaunch=True 67 | bEnableLegacyInputScales=True 68 | bEnableMotionControls=True 69 | bFilterInputByPlatformUser=False 70 | bShouldFlushPressedKeysOnViewportFocusLost=True 71 | bAlwaysShowTouchInterface=False 72 | bShowConsoleOnFourFingerTap=True 73 | bEnableGestureRecognizer=False 74 | bUseAutocorrect=False 75 | DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown 76 | DefaultViewportMouseLockMode=LockOnCapture 77 | FOVScale=0.011110 78 | DoubleClickTime=0.200000 79 | DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput 80 | DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent 81 | DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks 82 | -ConsoleKeys=Tilde 83 | +ConsoleKeys=Tilde 84 | +ConsoleKeys=Caret 85 | 86 | -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Enum/E_SparkInformationType.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Enum/E_SparkInformationType.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/BP_XunFeiGameInstance.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/BP_XunFeiGameInstance.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Common/BP_XunFeiGameMode.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Common/BP_XunFeiGameMode.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_Audio.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_Audio.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_TalkGameMode.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_TalkGameMode.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_TalkHUD.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_TalkHUD.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_TalkLibrary.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/GameFrame/Talk/BP_TalkLibrary.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Maps/MainMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Maps/MainMap.umap -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Maps/TalkMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Maps/TalkMap.umap -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_SparkTalkMessage.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_SparkTalkMessage.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_TTSAduio.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_TTSAduio.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_TTSTask.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_TTSTask.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_VDSNText.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/Struct/S_VDSNText.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Main/WBP_Main_Layout.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Main/WBP_Main_Layout.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_InformationItem.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_InformationItem.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_InputText.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_InputText.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_TalkBox.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_TalkBox.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_TalkSpark_Layout.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_TalkSpark_Layout.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_VCN.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuhuagang/XGIflytekToUE/e846d43e24f32fc20d2a8c56dd75be4a8dbdd06b/XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/Content/XGXunFei/UI/Talk/WBP_VCN.uasset -------------------------------------------------------------------------------- /XunFeiLinDemo-v4.4-UE_5.3(正版可用,插件工程)/XunFeiLinkDemo.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "5.3", 4 | "Category": "", 5 | "Description": "", 6 | "Plugins": [ 7 | { 8 | "Name": "ModelingToolsEditorMode", 9 | "Enabled": true, 10 | "TargetAllowList": [ 11 | "Editor" 12 | ] 13 | }, 14 | { 15 | "Name": "XGXunFeiLink", 16 | "Enabled": true, 17 | "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/fe3549779b284f908e112db8cede2871" 18 | } 19 | ] 20 | } --------------------------------------------------------------------------------