From 0a6dabac2b8b1731c60b519295a19d4b86e97d38 Mon Sep 17 00:00:00 2001 From: liangzhenying <867174124@qq.com> Date: Tue, 16 Sep 2025 14:09:07 +0800 Subject: [PATCH] =?utf8?q?=E6=94=B9=E4=BA=86=E4=B8=AD=E8=8B=B1=E4=BA=92?= =?utf8?q?=E8=AF=91=EF=BC=8C=E8=B0=83=E9=80=9A=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ShenYin/ShenYin.xcodeproj/project.pbxproj | 33 +-- .../xcshareddata/xcschemes/ShenYin.xcscheme | 78 +++++++ .../xcshareddata/swiftpm/Package.resolved | 15 -- ShenYin/ShenYin/AppLaunch.swift | 10 +- .../home/Frame 2247_slices/Contents.json | 6 - .../play_animate_1.imageset/Contents.json | 23 +++ .../play_animate_1.imageset/Group 2094.png | Bin 0 -> 183 bytes .../play_animate_1.imageset/Group 2094@2x.png | Bin 0 -> 305 bytes .../play_animate_1.imageset/Group 2094@3x.png | Bin 0 -> 496 bytes .../play_animate_2.imageset/Contents.json | 23 +++ .../play_animate_2.imageset/Group 2288.png | Bin 0 -> 352 bytes .../play_animate_2.imageset/Group 2288@2x.png | Bin 0 -> 616 bytes .../play_animate_2.imageset/Group 2288@3x.png | Bin 0 -> 1044 bytes .../play_animate_3.imageset/Contents.json | 23 +++ .../play_animate_3.imageset/Group 2289.png | Bin 0 -> 544 bytes .../play_animate_3.imageset/Group 2289@2x.png | Bin 0 -> 1065 bytes .../play_animate_3.imageset/Group 2289@3x.png | Bin 0 -> 1878 bytes .../home/polygon.imageset/Contents.json | 22 ++ .../home/polygon.imageset/Polygon_2@2x.png | Bin 0 -> 440 bytes .../home/polygon.imageset/Polygon_2@3x.png | Bin 0 -> 723 bytes ShenYin/ShenYin/Info.plist | 2 - ShenYin/ShenYin/JoySdkManager.swift | 14 +- ShenYin/ShenYin/SceneDelegate.swift | 2 +- ShenYin/ShenYin/ShenYin.entitlements | 5 + ShenYin/ShenYin/UI/Home/CallingRecordVC.swift | 108 +++++++++- ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift | 2 +- .../Chinese2English/Chinese2EnglishCell.swift | 119 +++++++++++ .../Chinese2English/Chinese2EnglishVC.swift | 186 +++++++++++++++++ .../ShenYin/UI/Home/Chinese2EnglishVC.swift | 67 ------ .../Home/FieldRecording/FieldRecordBar.swift | 7 +- .../FieldRecording/FieldRecordingVC.swift | 2 +- .../UI/Home/FieldRecording/RecordBar.swift | 90 ++++++++- .../UI/Home/RecordDetail/RecordDetailVC.swift | 2 +- .../ShenYin/UI/Home/RecordTranslateVC.swift | 191 +++++++++++++++--- .../TextTranslateVC.swift | 0 .../TranslateCell.swift | 0 ShenYin/ShenYin/UI/Scan/QrVC.swift | 2 +- ShenYin/ShenYin/UI/common/AppManager.swift | 2 +- ShenYin/ShenYin/UI/common/LogVC.swift | 4 +- .../UI/common/PlaceHolderTextView.swift | 66 ++++++ .../LanguagePicker/LanguagePickerView.swift | 2 + .../ShenYin/UI/common/pop/PopTextField.swift | 2 +- .../UI/common/pop/RecordTipsView.swift | 4 +- 43 files changed, 933 insertions(+), 179 deletions(-) create mode 100644 ShenYin/ShenYin.xcodeproj/xcshareddata/xcschemes/ShenYin.xcscheme delete mode 100644 ShenYin/ShenYin.xcworkspace/xcshareddata/swiftpm/Package.resolved delete mode 100644 ShenYin/ShenYin/Assets.xcassets/home/Frame 2247_slices/Contents.json create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Contents.json create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094@2x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094@3x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_2.imageset/Contents.json create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_2.imageset/Group 2288.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_2.imageset/Group 2288@2x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_2.imageset/Group 2288@3x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Contents.json create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289@2x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289@3x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Contents.json create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Polygon_2@2x.png create mode 100644 ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Polygon_2@3x.png create mode 100644 ShenYin/ShenYin/ShenYin.entitlements create mode 100644 ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift create mode 100644 ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC.swift delete mode 100644 ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift rename ShenYin/ShenYin/UI/Home/{textTranslateVC => TextTranslate}/TextTranslateVC.swift (100%) rename ShenYin/ShenYin/UI/Home/{textTranslateVC => TextTranslate}/TranslateCell.swift (100%) create mode 100644 ShenYin/ShenYin/UI/common/PlaceHolderTextView.swift diff --git a/ShenYin/ShenYin.xcodeproj/project.pbxproj b/ShenYin/ShenYin.xcodeproj/project.pbxproj index 52afbf1..229bec3 100644 --- a/ShenYin/ShenYin.xcodeproj/project.pbxproj +++ b/ShenYin/ShenYin.xcodeproj/project.pbxproj @@ -9,8 +9,6 @@ /* Begin PBXBuildFile section */ 3F79C6142E6055E500EC38B9 /* JoyGemAI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F79C4902E603B4700EC38B9 /* JoyGemAI.framework */; }; 3F79C6152E6055E500EC38B9 /* JoyGemAI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3F79C4902E603B4700EC38B9 /* JoyGemAI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 3FF8A4622E72CBBA00271F9E /* DSWaveformImage in Frameworks */ = {isa = PBXBuildFile; productRef = 3FF8A4612E72CBBA00271F9E /* DSWaveformImage */; }; - 3FF8A4642E72CBBA00271F9E /* DSWaveformImageViews in Frameworks */ = {isa = PBXBuildFile; productRef = 3FF8A4632E72CBBA00271F9E /* DSWaveformImageViews */; }; F2E449CAD5874BE652A69B50 /* Pods_ShenYin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3862D5561144E20721225B96 /* Pods_ShenYin.framework */; }; /* End PBXBuildFile section */ @@ -65,9 +63,7 @@ buildActionMask = 2147483647; files = ( F2E449CAD5874BE652A69B50 /* Pods_ShenYin.framework in Frameworks */, - 3FF8A4622E72CBBA00271F9E /* DSWaveformImage in Frameworks */, 3F79C6142E6055E500EC38B9 /* JoyGemAI.framework in Frameworks */, - 3FF8A4642E72CBBA00271F9E /* DSWaveformImageViews in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -163,7 +159,6 @@ mainGroup = 3F887B932E38D8DC00C98658; minimizedProjectReferenceProxies = 1; packageReferences = ( - 3FF8A4602E72CBBA00271F9E /* XCRemoteSwiftPackageReference "DSWaveformImage" */, ); preferredProjectObjectVersion = 77; productRefGroup = 3F887B9D2E38D8DC00C98658 /* Products */; @@ -248,6 +243,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ShenYin/ShenYin.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = M33X987285; @@ -257,6 +253,7 @@ ); GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = ShenYin/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "深音"; INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "扫描附近蓝牙设备需要获得权限"; INFOPLIST_KEY_NSCameraUsageDescription = "修改用户头像、提交意见反馈需要访问相册使用摄像头"; INFOPLIST_KEY_NSMicrophoneUsageDescription = "录音需要使用麦克风"; @@ -289,6 +286,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ShenYin/ShenYin.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = M33X987285; @@ -298,6 +296,7 @@ ); GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = ShenYin/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "深音"; INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "扫描附近蓝牙设备需要获得权限"; INFOPLIST_KEY_NSCameraUsageDescription = "修改用户头像、提交意见反馈需要访问相册使用摄像头"; INFOPLIST_KEY_NSMicrophoneUsageDescription = "录音需要使用麦克风"; @@ -468,30 +467,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - -/* Begin XCRemoteSwiftPackageReference section */ - 3FF8A4602E72CBBA00271F9E /* XCRemoteSwiftPackageReference "DSWaveformImage" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/dmrschmidt/DSWaveformImage"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 14.2.2; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - 3FF8A4612E72CBBA00271F9E /* DSWaveformImage */ = { - isa = XCSwiftPackageProductDependency; - package = 3FF8A4602E72CBBA00271F9E /* XCRemoteSwiftPackageReference "DSWaveformImage" */; - productName = DSWaveformImage; - }; - 3FF8A4632E72CBBA00271F9E /* DSWaveformImageViews */ = { - isa = XCSwiftPackageProductDependency; - package = 3FF8A4602E72CBBA00271F9E /* XCRemoteSwiftPackageReference "DSWaveformImage" */; - productName = DSWaveformImageViews; - }; -/* End XCSwiftPackageProductDependency section */ }; rootObject = 3F887B942E38D8DC00C98658 /* Project object */; } diff --git a/ShenYin/ShenYin.xcodeproj/xcshareddata/xcschemes/ShenYin.xcscheme b/ShenYin/ShenYin.xcodeproj/xcshareddata/xcschemes/ShenYin.xcscheme new file mode 100644 index 0000000..7b6a0f6 --- /dev/null +++ b/ShenYin/ShenYin.xcodeproj/xcshareddata/xcschemes/ShenYin.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShenYin/ShenYin.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ShenYin/ShenYin.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 6851bcf..0000000 --- a/ShenYin/ShenYin.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,15 +0,0 @@ -{ - "originHash" : "eb3e6467aa3b79663b371a20cbe7f1b7c7a6a3c9f98e6945bc9704361b5ae42d", - "pins" : [ - { - "identity" : "dswaveformimage", - "kind" : "remoteSourceControl", - "location" : "https://github.com/dmrschmidt/DSWaveformImage", - "state" : { - "revision" : "4c56578ee10128ee2b2c04c9c5aa73812de722db", - "version" : "14.2.2" - } - } - ], - "version" : 3 -} diff --git a/ShenYin/ShenYin/AppLaunch.swift b/ShenYin/ShenYin/AppLaunch.swift index d021252..1fa4370 100644 --- a/ShenYin/ShenYin/AppLaunch.swift +++ b/ShenYin/ShenYin/AppLaunch.swift @@ -27,10 +27,10 @@ class AppLaunch:NSObject{ static func loadCache(){ let list = DeviceCache.shared.getDeviceList() Logger.debug("缓存设备",list) - if list.count > 0 { - CacheManager.shared.currentDevice = list.first - BleManager.shared.startScanDevice() - App.shared.enter() - } +// if list.count > 0 { +// CacheManager.shared.currentDevice = list.first +// BleManager.shared.startScanDevice() +// App.shared.enter() +// } } } diff --git a/ShenYin/ShenYin/Assets.xcassets/home/Frame 2247_slices/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/Frame 2247_slices/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/ShenYin/ShenYin/Assets.xcassets/home/Frame 2247_slices/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Contents.json new file mode 100644 index 0000000..7be0bc8 --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Group 2094.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group 2094@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group 2094@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094.png b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094.png new file mode 100644 index 0000000000000000000000000000000000000000..e30d1ec5d3a5896b56029c82b3a89152021c24bb GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^d_XM3!3HF=W8NDAsT@xi$B+ufHxoAUHaKv&?$;~& z#+Ud|Z`<{($9#7@#QYvG`828AxDeBE*3^9g!$0r3e;xC$9`q_$dq}fp(Ff*7TOXa< zYqz@SMd`JhB~G~uc&u5(6+{+=q$K#Y%n^I?@>=u?ULMcAE1K>2x95z^mHj+#v+sY; zuJdh?7iT`%x;ZH9Rc-@+@Agfr7{j7cPyGHVKQ%3t_h)X~qav5WyNSiq?#=&ywBcsr z?(Izh(GEO}J%X-F+swY2zBF=Jx-4u{LyG{jz;$T>|3`273)why)|!j>?O5G>Re6Wu zfi07rI|UWK)Q50ik*-aN{S+&$P_p!+oTrVu()Afz@L! BdKUly literal 0 HcmV?d00001 diff --git a/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_1.imageset/Group 2094@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..58800066f765df4480374167446248da97601bee GIT binary patch literal 496 zcmV`B&dBmvc4<$r}sA&SG^GS~iQPTuW=aU{4 zqNWL$&L=%8L`@SgolkmHh?*u~I$wf&^y*^*)mk1G^<$jZPf@9_quiJ_O(<+WFVX7j z3|j3noYXyBoB%k2g%By+)ym zR4+|a8}8rPGRC`8S|GNqW)yS5mEBpi-I3sUv=PmydI~P5nix}^;CQqVuhFhuqH-;o z`smQ*x&fL^JrLL4Yt;U{gX5IQ)LYMh0sq0}1v znpR<1E3nle3b}U-@v(fhw{zbpW^34+f52|`5rxb%ikUB;F6INj(U=Wz%ZX7gDXvb4 za!GM@LX=C2s}rJJQe2%7<&xs+geaF3SNCs;ash?b3DMBV2D~6d2LK8kP7Kjs00030 m|I%fQUH||921!IgR09C}c1LYHLMjaa0000bF5Qo3HAjmy{9D<3>RSH(t7Is>S_Xt;-!ar!C*xMxOYy}&A3kxgltgJ2;+6W?I zah_psZYo`cDg!mKzq#@(Z&3g*4wb0|(t9$TQGpeJRx0a|@!* zw6dn7ucP!IQ;4)pb`}dNIYsfHe=n_cWltIgA62iaEEq>AakNFe`e>x&Jw(Zd{?IE& z%b%v_EEaT{$mm=@Obf-0E0y~xAS);};BPT02i;r`cEVl0qAtgsUl%C%^t0ey9>(eA2ei`*XUwL4%P{Lg2Ceo#Oq|49nc(K0abT%J@{BSwy zw0hvk!~+mN1?U2Rt1xCkpvOdSZc9PpACCn-$9N!fcmN1>5S_>7XNXsW6p_87L24(H z0b*^Zf&I_el=|8VL%Ml(tb_*w)8c(&w6VhPd}2c}*Ef`VG5vHx*Lz^IHV2l=43giG z@1k5ei{#`M-@bb$C~c@6_#ESbc3^Y-4I1OO(WpPdwG+Q>Du~{HDxJ&ZzTsB&SH|bc z5STaoc;$)=DNDG<^x6r1uLmZJWf1NKrOCVuyu#>#Bc>(wGIx$Ypi%uSxu~WGc6lL8CE*sQ(BaAgc;XcW!beVJRR>4CPqy(*E{z)s6X956ex zpdJ7VZrt|M4*r(@2LJ&7|K0sf{{R3021!IgR09Bv6mv-d(7HeX00009j;6vzK(E=nKqRYIelMudn&A{G`%Ln0ysArcD-v9Lf(5jMUO3nD414IyG-XCd*C zAVfrJr5jZuG;R7NO;u=`*RS{P9p|QfUhmxdp7zdk(e&M%$;|oB%$Z+L@66mMFh-s% zsOf)HHlx{$n$Cdfc-eO}n^DslFdc84yrU1Lh4PjKC~sVj@}|YO+7>aL$z(jejJ7px z0qo}h)c~>zIsIo)**+Dc@aTa8mzik=Lt0$V=v0dCYZs9>I8yF1B6{0C1QHhHB zsG@7T;X&=hZxFQx5JccuS8%^!azI~bDLiQLl0HbB;+6ZjC`KF6Db^{XmKz?_UDoD} zB=MM=4woS&^B}Ml7iuRB5w)6npvMdUz;SNzCi>;0AZ$Ti?tGsfQqTi+7tLMt9-y~S zABn|C&>B?^>+6FaqBtD;E(0k4eh>uhhM`9v)CCdtJFdQQ@tUL}lz-3his3vnpzaAk zc`3}E`>y2Ac);#OKv2DB#9Ft=$4b(>{dO<5% zW+T>J#s~HbJ|i!1taA`}iV4nbTx(dwetNTginG_rMYWl#5XSdr6jaJVCU8+qy4qSq>={Z&%AIK2?DTL^E&UvIWCmXW zMSl9RG7sI-$PP}wM*1EFl)k1PN*&0hfO~y#h7@ir{~scq_Q4Tal^Z-2z)oCZC&ooJ z_XFe+(9xlG{PS%Q;kN&DAQ}bGMAvh^yD#yMPkp`-xJ?zj^Y7!(>Nvv$o0R+k4Sz;0 z>vQmgk*VH{o?02hbXWO_&z1$OsX)q(m5Md2HNps*LE z(Rv(R_!38=uW-1a4y6S_yE!#=;F{c#5|SIkB!Va0a&SJ=Y zyz!=a!^$|H9?y_pZRGuQW9xxRdjsHXbOU(`i8cuF1bg4R zpg8(Pm34egQ1OWu_kP+*d_W{}hjpW-2ihI0;$zAEy)00-xE8KvZ4dZ4G5 zb)h6$3`with?SuJb$nSExiXo}V|t*;P$dg%ajc*Q?r*20X1F#3Y8WagToyDaD>~Y^ z&8SY&GS1CrG-G-~bY?ReB54_?jG2u71pom5{}tFCQ2+n{21!IgR09AzaPMs|T#i@( O0000Flc literal 0 HcmV?d00001 diff --git a/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Contents.json new file mode 100644 index 0000000..d30d76e --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Group 2289.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group 2289@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group 2289@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289.png b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289.png new file mode 100644 index 0000000000000000000000000000000000000000..22d828f382d07c52c1fa690d5154406439b0896c GIT binary patch literal 544 zcmV+*0^j|KP)A~N=iIiLT&qwE(tbB5>J2);Gv$BSd zMyrb8r~REa({6co2YqEdg_?c#s!cC(Wh6ggn?#mdheYRy3dacd_5apC00030{{;%^ idH?_b21!IgR09BA#erYJEe+KG0000m38Up10eMsC6`?(t>3t^SioH4@qaJuSv>!8a z>Okoy)d4|M;;t{0_Btq<#Xnc|#Hr4W)dAa$V*r2dJgPuwqGtX?L8}g^PFu~xVC+!Q z5#uX#uf2_2D-YPcI4W5_0*>>9Z~~JgaMexVa)7;vRX&EBjzvBIWDg^)|3O(z5Peu3+O!+W1>&dUDz1Q8Gh%| zX?g8Ery-1B-5V}>$^%ZnbxoXvNx=9{bYZu#H2!VaRr=Tt!pZ~6X3(R(a>^wYEm8D| z9rG-T!Z;GYlWtiZU`tL(d^R-(Xfyu0FoJxGmd*z%X05eWEvkn;As}s;*9#B3 zjUygrl+KR_WDXNR>mkvH8KYRNan=z)q<0hr&1W>B;94;H1x8P+*f?XmXlNxncPiQE z_V^P5+hxIb#vJbPVXsIe<}kKQHgD zCt}T2mPFwmDg;bcR~*(2ej{sjp|~?0h=m-FIQvk#ct)90dBD!qItV|jks~tuotz39 zKSEf6%u7epH5yhF*?^%9AIab@x)kzrn0ReobheiVjCixPaBN`G ziJ_oBRbE3h>nA{YK+ykU7-ub`Q+T>v3vxQj#;*@kQ#+)sJfQxatsPu14o1*!{GK{+ zqsBOj!jE!<{9|Nr;g j5^Mkf00v1!K~w_(Q7iyhku+uN00000NkvXXu0mjfM@{6Q literal 0 HcmV?d00001 diff --git a/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/play_animate_3.imageset/Group 2289@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..1b719072866626c99905f4ba5b7f57b8c2c6d678 GIT binary patch literal 1878 zcmV-c2dVgpP)vPv#_uhLtv+Mo#&U|xs)z41|8qVA~=Qoe@`|h1N zGxvT9|B>`R(d+%7vVTX{9_)eTho)g=eLbq{nz7V&()C4K2cJ$giw*>xQv3=V+}s~=cYK=m3{+=BG*ZPc6rf+7O_Z9K6k9VR3M>(a{e`5S zTfL-w1%A^+!IDK!fiQU6*?_qZnw!VF>aLw=?Li@i2dzP6i&V9!IZ$rlra7l#GeDA& zo|v6?_1cLB{%M(SN7Fr_5TUme`Y__COhG}QpT?P#9VtwuXli~WGNba^iB{g%DuH~y z4CGiCGzw?cP^n86@8+FSxka)m1icA7j4C#`83wL41;HjE`;~MHCC7wIB=C(x)tQ!1^4^}&=0T^qaS>F)P@aP_1Fuda|WgjrV98ucWO1tnG>B(Z3qK> z=&&9?2#TITS82wb7vTDlkc|YvK*Un!MD<`Q_)&_#B%8uC0@Z)#o1kS;xZOfJOyxb) zp>$lY4^bTf2eqvs1H-Vg?oHXl-@@{`aaeZP znAq_FQhI>zQhHp;_wJ9IX?j?&Uod;x2*ed~Nr_3c=E&_5Y?mSQzLnKjC9U3o!q>iG*3E8z?G{Ztg#^|3}n|ZDmsnaAQ0oCWLuK^L@k+* zMQW@xZlYmGqu!DegiFxOU9aGTp54NPo4RXb5v9G!9q1$qoR6rZ3oAWVeuojea(E(U zC8(56lwkDJgLifg{KaDE$t{H;`T+7Ja58IxAE`Dj<@P%F*_FtM1SZk> z1DbFPmLtG0xf72=;V~#R0zNIojEV+ym54_;t1o&90sV4ohJEj&WtECp}FNr`SzK z*NZUx2EBI}AtvS*?c1^9;euIx;ma@Bgwfq zWRZWD%h50xNii{Pn zt1~33cFQ2<(T=elg@qpoo-F$NJu7_xa{u)$159-} zGW_QDSR!-V^=HEgwC3yajONI%Dfw)x53p-W7mhM z9_dPQ;Liq!Pe}ODU;pAgbSPSlzP~iY!MJ{7i0V(?D-S&nqJ?lp3CP_nD)`h6NrKDQ}Wvf6m66_7f z>GH|lzMeSfXP;=~bXM6hRQ5fBD)Mm+>0bZ<0RR8Ken2Gv000I_L_t&o0PzI{i-~S_ QssI2007*qoM6N<$f=Ty_qW}N^ literal 0 HcmV?d00001 diff --git a/ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Contents.json new file mode 100644 index 0000000..8b4e60a --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Polygon_2@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Polygon_2@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Polygon_2@2x.png b/ShenYin/ShenYin/Assets.xcassets/home/polygon.imageset/Polygon_2@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..3467ca6991fe352a77d1932bba340341d2cc49f6 GIT binary patch literal 440 zcmV;p0Z0CcP)HV{6vZ7o2}4j6C1PfPl?`=ZMf^JqAOS)Gb)iBap{@*|We1p6P+|U(p)0WU@ilXz_VqgQt6!II90MP5KjxpY<8KX-*DXcH5?AV zx-a4})NZ$b;9Q&`cW$cxvlCUzvewoD`0ZfWM z&zx(zuG=yJsUaaS7z|c0^@gznV}lOArsxHfB9bB7whiv^A!;U!3xk5kG`dTaB9b9g z91i$f;wKmj+{iMuOB6-wZd60)Dcfw@RR(`xRM;Hk+azzpNQh%d;g#|o)dw&VxPi-~ znn?K~DV8Boz^{QP#8oK6D&2V{OLDJAF?6J+)oSTXh+hN$i9rx+)lqIxj_-VIL#XWX zS>&tyjj=CSTg&BgPg(T5&6x{D5<^P2+chyI4!GYtX^U^xY_r+i2)%N^Vj@FAtJmv& z=FrYF-hqb@ubO!buN+RqjfoA33(=)}#5+)QLuae*LovrxG91egPhZP0j9GXRp5g&` zQ_Ll^a!{ongvt3kafbE)009608xybluetooth-central audio - CFBundleDisplayName - 深音 diff --git a/ShenYin/ShenYin/JoySdkManager.swift b/ShenYin/ShenYin/JoySdkManager.swift index ff76bd3..64f2405 100644 --- a/ShenYin/ShenYin/JoySdkManager.swift +++ b/ShenYin/ShenYin/JoySdkManager.swift @@ -16,7 +16,7 @@ class JoySdkManager:NSObject{ //MARK: 初始化SDK JoyGemAIManager.shared().initSdk() //MARK: 配置日志类型 - JoyGemAIManager.shared().setLogMode(JoyGemLogMode.close) + JoyGemAIManager.shared().setLogMode(JoyGemLogMode.all) let fileManager = FileManager.default @@ -28,12 +28,12 @@ class JoySdkManager:NSObject{ do { // 创建 log 文件夹 try fileManager.createDirectory(at: logDirectory, withIntermediateDirectories: true, attributes: nil) - print("log 文件夹已创建: \(logDirectory.path)") + Logger.debug("log 文件夹已创建: \(logDirectory.path)") } catch { - print("创建 log 文件夹时出错: \(error.localizedDescription)") + Logger.debug("创建 log 文件夹时出错: \(error.localizedDescription)") } } else { - print("log 文件夹已存在: \(logDirectory.path)") + Logger.debug("log 文件夹已存在: \(logDirectory.path)") } // 获取当前日期并格式化 @@ -50,15 +50,15 @@ class JoySdkManager:NSObject{ if !fileManager.fileExists(atPath: filePath.path) { // 创建空文件 fileManager.createFile(atPath: filePath.path, contents: nil, attributes: nil) - print("日志文件已创建: \(filePath.path)") + Logger.debug("日志文件已创建: \(filePath.path)") } else { - print("日志文件已存在: \(filePath.path)") + Logger.debug("日志文件已存在: \(filePath.path)") } //MARK: 配置日志路径 JoyGemAIManager.shared().setLogPath(filePath.path) } else { - print("无法找到应用支持目录") + Logger.debug("无法找到应用支持目录") } //MARK: 配置缓存路径 diff --git a/ShenYin/ShenYin/SceneDelegate.swift b/ShenYin/ShenYin/SceneDelegate.swift index 593c36c..cdba428 100644 --- a/ShenYin/ShenYin/SceneDelegate.swift +++ b/ShenYin/ShenYin/SceneDelegate.swift @@ -20,7 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { App.shared.window = window window?.rootViewController = BaseTC() -// window?.rootViewController = UINavigationController(rootViewController: TextTranlateVC()) + window?.rootViewController = UINavigationController(rootViewController: RecordTranslateVC()) AppLaunch.start() } diff --git a/ShenYin/ShenYin/ShenYin.entitlements b/ShenYin/ShenYin/ShenYin.entitlements new file mode 100644 index 0000000..0c67376 --- /dev/null +++ b/ShenYin/ShenYin/ShenYin.entitlements @@ -0,0 +1,5 @@ + + + + + diff --git a/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift b/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift index 3a156d8..40e4993 100644 --- a/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift +++ b/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift @@ -6,19 +6,28 @@ // import UIKit - +import JoyGemAI +import AVFAudio class CallingRecordVC:BaseVC{ let toolBar = FieldRecordBar() let textView = UITextView() let rhythView = RhythView() + var messageList : [(String,UInt)] = [] + var recordFilePath : String? + + override func viewDidLoad() { super.viewDidLoad() } override func setupViews() { navBar.title = "通话录音" + toolBar.delegate = self + toolBar.hasRightItem = false + textView.do { v in v.isEditable = false v.font = .regular(14) + v.text = "" v.textColor = .hexString("#121212") v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18) } @@ -42,7 +51,104 @@ class CallingRecordVC:BaseVC{ make.bottom.equalTo(toolBar.snp.top) } } + override func setupData() { + JoyGemCallManager.shared().delegate = self +// JoyGemCallManager.shared().stereoDelegate = self//双声道 + } func scrollToBottom(){ + } + ///播放最后一次录音文件 + @objc func playRecord() { + guard let file = recordFilePath else {return;} + +// do { +// // 创建 AVAudioPlayer 实例 +// audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: file)) +// audioPlayer?.prepareToPlay() // 准备播放 +// audioPlayer?.play() // 播放音频 +// } catch { +// debugPrint("播放音频时发生错误: \(error.localizedDescription)") +// } + } +} + +extension CallingRecordVC:FieldRecordBarDelegate{ + func fieldRecordBar(_ bar: FieldRecordBar, languageChange language: AiSupportLanguage) { + JoyGemCallManager.shared().originalLanguage = language.value + } + + func fieldRecordBar(_ bar: FieldRecordBar, stateChange state: RecordSate) { + if state == .start { + textView.text = "" + messageList.removeAll() + JoyGemCallManager.shared().start() + } + else if state == .stop{ + JoyGemCallManager.shared().stop() + bar.recordBtn.startAnimating {[weak self] in + guard let self = self else{return} + // toolBar.recordBtn.stopCli() + let v = PopTextField() + v.show() + v.cancelTap = { + + } + v.okTap = { + + } + } + } + } +} +extension CallingRecordVC : JoyGemCallManagerDelegate { + + func callManagerStopped(_ manager: JoyGemCallManager, reason code: JoyGemRecordStopCode) { + if (code == .actively) { + YLprogressHUD.showAutoHiden( "用户主动结束") + } else { + YLprogressHUD.showAutoHiden( "自动结束") + ///判断当前蓝牙是否连接从而确定是否因为蓝牙断开造成的录音断开 + } + } + + func callManagerNotonCall(_ manager: JoyGemCallManager) { + YLprogressHUD.showAutoHiden("未处于通话状态") + } + + func callManager(_ manager: JoyGemCallManager, saveFile path: String) { + debugPrint("path: \(path)") + recordFilePath = path + } + + func callManager(_ manager: JoyGemCallManager, stateChange code: JoyGemStateCode) { + debugPrint("code: \(code)") + } + + func callManager(_ manager: JoyGemCallManager, onError code: JoyGemErrorCode) { + + } + + func callManager(_ manager: JoyGemCallManager, didUpdateAsr model: JoyGemAsrModel) { + debugPrint("text: \(model.text),index: \(model.index)") + let msg = messageList.firstIndex (where: { (str,idx) in + return idx == model.index; + }) + if (msg == nil) { + messageList.append((model.text,model.index)) + } else { + messageList[msg!] = (model.text,model.index) + } + + textView.text = messageList.compactMap({ (str,idx) in + return str + }).joined(separator: "\n") + } + +} + +extension CallingRecordVC:JoyGemCallStereoDelegate{ + func callManager(_ manager: JoyGemCallManager, didUpdateStereoAsr model: JoyGemAsrModel, channel index: UInt) { + } } diff --git a/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift b/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift index 93d5cf2..1534d1e 100644 --- a/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift +++ b/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift @@ -182,7 +182,7 @@ extension ChatVC : JoyGemChatManagerDelegate { try AVAudioSession.sharedInstance().setCategory(.playback, options: [options]) try AVAudioSession.sharedInstance().setActive(true) } catch { - print(error) + Logger.debug(error) } } // stateLabel.text = "正在录音" diff --git a/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift new file mode 100644 index 0000000..69b31f3 --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift @@ -0,0 +1,119 @@ +// +// Chinese2EnglishCell.swift +// ShenYin +// +// Created by liangshi on 2025/9/15. +// + +class Chinese2EnglishCellModel{ + var send = "" + var response = "" + + init(send: String = "", response: String = "") { + self.send = send + self.response = response + } +} + + + + +class Chinese2EnglishCell:BaseTableViewCell{ + let bgView = UIView() + let line = BrokenLineView() + let originalLabel = UILabel() + let translationLabel = UILabel() + let copyIcon = UIImageView() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func setupViews() { + contentView.backgroundColor = .rgb(0xF6F6F6) + + bgView.do { v in + v.yc.setCornerRadius(12) + v.backgroundColor = .white + } + originalLabel.do { v in + v.font = .regular(14) + v.textColor = .hexString("#606D80") + v.numberOfLines = 0 + v.textAlignment = .left + } + translationLabel.do { v in + v.font = .regular(14) + v.textColor = .hexString("#121212") + v.numberOfLines = 0 + v.textAlignment = .left + } + line.do { v in + // v.backgroundColor = .hexString("#93C6EC") + } + copyIcon.do { v in + v.image = UIImage(named: "play_animate_3") + v.animationImages = [UIImage(named: "play_animate_1")!,UIImage(named: "play_animate_2")!,UIImage(named: "play_animate_3")!] + v.animationDuration = 0.6 + v.animationRepeatCount = 0 + v.yc.addTap(target: self, action: #selector(copyAction)) + } + contentView.addSubview(bgView) + bgView.addSubviews([originalLabel,translationLabel,line,copyIcon]) + } + + override func setupLayout() { + bgView.snp.makeConstraints { make in + make.top.bottom.equalToSuperview().inset(10) + make.width.lessThanOrEqualTo(kScreenWid - 58) + make.left.equalToSuperview().inset(18) + } + + originalLabel.snp.makeConstraints { make in + make.top.equalToSuperview().inset(14) + make.left.equalToSuperview().inset(12) + make.width.lessThanOrEqualTo(kScreenWid - 82) + } + line.snp.makeConstraints { make in + make.left.right.equalToSuperview().inset(12) + make.height.equalTo(1) + make.top.equalTo(originalLabel.snp.bottom).offset(15) + } + + translationLabel.snp.makeConstraints { make in + make.top.equalTo(line.snp.bottom).offset(15) + make.left.equalToSuperview().inset(12) + make.width.lessThanOrEqualTo(kScreenWid - 82) + make.bottom.equalToSuperview().inset(47) + } + copyIcon.snp.makeConstraints { make in + make.right.equalToSuperview().inset(12) + make.size.equalTo(24) + make.bottom.equalToSuperview().inset(10) + } + } + + var data:Chinese2EnglishCellModel!{ + didSet{ + originalLabel.text = data.send + translationLabel.text = data.response + } + } + @objc func copyAction(){ +// UIPasteboard.general.string = data.send + "\n" + data.response +// YLprogressHUD.showAutoHiden("已拷贝") + if copyIcon.isAnimating { + copyIcon.stopAnimating() + } + else{ + copyIcon.startAnimating() + } + } +} + + diff --git a/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC.swift b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC.swift new file mode 100644 index 0000000..14fdfae --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC.swift @@ -0,0 +1,186 @@ +// +// Chinese2EnglishVC.swift +// ShenYin +// +// Created by liangshi on 2025/8/6. +// + +import UIKit +import JoyGemAI +import AVFAudio +class Chinese2EnglishVC:BaseVC{ + let toolBar = RecordBar() + let tableView = UITableView(frame: CGRectZero, style: .plain) + var dataList:[(Chinese2EnglishCellModel,UInt)] = [] + var pcmData = Data() + override func viewDidLoad() { + super.viewDidLoad() + } + override func setupViews() { + navBar.title = "中英互译" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + toolBar.delegate = self + + tableView.backgroundColor = .clear + tableView.delegate = self + tableView.dataSource = self + tableView.estimatedRowHeight = 60 + tableView.separatorStyle = .none + tableView.register(Chinese2EnglishCell.self, forCellReuseIdentifier: Chinese2EnglishCell.reuseID) + view.addSubview(tableView) + view.addSubview(toolBar) + + } + override func setupLayout() { + toolBar.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(120) + make.bottom.equalToSuperview().inset(20) + } + tableView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(80) + make.left.right.equalToSuperview() + make.bottom.equalTo(toolBar.snp.top) + } + } + override func setupData() { + JoyGemSIDeviceManager.shared().delegate = self + + PcmSound.sharedInstance().delegate = self; + PcmSound.sharedInstance().setup(16000, withchannels: 1) +// do { +// try AVAudioSession.sharedInstance().setActive(true) +// } catch { +// print(error) +// } + } + override func navRightViewTapped() { + let tip = RecordTipsView(type: .chinese2english) + tip.show() + } + func refreshData(){ + tableView.reloadData() + if dataList.count > 0 { + tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) + } + } +} +extension Chinese2EnglishVC:RecordBarDelegate{ + + func recordBar(_ bar: RecordBar, stateChange state: RecordBarSate) { + if state == .start { + pcmData = Data() + dataList.removeAll() + refreshData() + + JoyGemSIDeviceManager.shared().originalLanguage = bar.leftItem.language.value + JoyGemSIDeviceManager.shared().targetLanguage = bar.rightItem.language.value + JoyGemSIDeviceManager.shared().start() +// do { +// try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.defaultToSpeaker]) +// try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker) +// } catch { +// print(error) +// } + } + else if state == .stop{ + JoyGemSIDeviceManager.shared().stop() + bar.recordBtn.startAnimating {[weak self] in + guard let self = self else{return} + // toolBar.recordBtn.stopCli() + let v = PopTextField() + v.show() + v.cancelTap = { + + } + v.okTap = { + + } + } + } + } +} +extension Chinese2EnglishVC:UITableViewDelegate,UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return dataList.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = Chinese2EnglishCell.cell(withTableView: tableView, indexPath: indexPath) + let (vallue,index) = dataList[indexPath.row] + cell.data = vallue + return cell + } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + } +} + +extension Chinese2EnglishVC:JoyGemSIDeviceManagerDelegate{ + func siDeviceManagerStopped(_ manager: JoyGemSIDeviceManager, reason code: JoyGemRecordStopCode) { + Logger.debug("停止",code.rawValue) + if code == .passively { + toolBar.recordBtn.isSelected = false + } + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateRaw model: JoyGemAsrModel) { + debugPrint("text: \(model.text),index: \(model.index)") + let msg = dataList.firstIndex (where: { (str,idx) in + return idx == model.index; + }) + if (msg == nil) { + dataList.append((Chinese2EnglishCellModel(send: model.text),model.index)) + } else { + let (item,_) = dataList[msg!] + item.send = model.text + } +// +// ///监听到一句话结束,自动结束当前录音 +// if (model.definite == true) { +// stopEarRecord() +// } + refreshData() + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateTranslate model: JoyGemAsrModel) { + let msg = dataList.firstIndex (where: { (str,idx) in + return idx == model.index; + }) + if (msg == nil) { + dataList.append((Chinese2EnglishCellModel(response: model.text),model.index)) + } else { + let (item,_) = dataList[msg!] + item.response = model.text + } + refreshData() + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateAudioData data: Data) { + pcmData.append(data) + PcmSound.sharedInstance().feed(data) + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, update mode: JoyGemRecordMode) { + + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, saveFile path: String) { + debugPrint("path: \(path)") + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, stateChange code: JoyGemStateCode) { + debugPrint("code: \(code)") + } + + func siDeviceManager(_ manager: JoyGemSIDeviceManager, onError code: JoyGemErrorCode) { + + } +} +extension Chinese2EnglishVC:PcmSoundDelegate{ + func remaining(_ frames: UInt) { + + } + + +} diff --git a/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift b/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift deleted file mode 100644 index 063792c..0000000 --- a/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift +++ /dev/null @@ -1,67 +0,0 @@ -// -// Chinese2EnglishVC.swift -// ShenYin -// -// Created by liangshi on 2025/8/6. -// - -import UIKit - -class Chinese2EnglishVC:BaseVC{ - let toolBar = RecordBar() - let tableView = UITableView(frame: CGRectZero, style: .plain) - var dataList = [1,2,3] - override func viewDidLoad() { - super.viewDidLoad() - } - override func setupViews() { - navBar.title = "中英互译" - navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) - - - tableView.backgroundColor = .clear - tableView.delegate = self - tableView.dataSource = self - tableView.estimatedRowHeight = 60 - tableView.separatorStyle = .none - tableView.register(TranslateCell.self, forCellReuseIdentifier: TranslateCell.reuseID) - view.addSubview(tableView) - view.addSubview(toolBar) - - } - override func setupLayout() { - toolBar.snp.makeConstraints { make in - make.width.centerX.equalToSuperview() - make.height.equalTo(120) - make.bottom.equalToSuperview().inset(20) - } - tableView.snp.makeConstraints { make in - make.top.equalToSuperview().inset(80) - make.left.right.equalToSuperview() - make.bottom.equalTo(toolBar.snp.top) - } - } - override func navRightViewTapped() { - let tip = RecordTipsView(type: .chinese2english) - tip.show() - } - func scrollToBottom(){ - if dataList.count > 0 { - tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) - } - } -} -extension Chinese2EnglishVC:UITableViewDelegate,UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return dataList.count - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = TranslateCell.cell(withTableView: tableView, indexPath: indexPath) - // cell.data = dataList[indexPath.row] - return cell - } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - - } -} diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift index 018aaaf..bc6c279 100644 --- a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift @@ -24,6 +24,7 @@ class FieldRecordBar: BaseView { let rightItem = RecordBarButton() var state:RecordSate = .stop var delegate:FieldRecordBarDelegate? + var hasRightItem:Bool = true override func setupViews() { backgroundColor = .white @@ -81,8 +82,12 @@ class FieldRecordBar: BaseView { rightItem.state = .start rightItem.isHidden = !recordBtn.isSelected + if hasRightItem == false{ + rightItem.isHidden = true + } + if recordBtn.isSelected { - leftItem.alpha = 0.5 + leftItem.alpha = 0.3 } else{ leftItem.alpha = 1 diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift index 75a807a..dc2c896 100644 --- a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift @@ -59,7 +59,7 @@ class FieldRecordingVC:BaseVC{ try AVAudioSession.sharedInstance().setCategory(.playback, options: [options]) try AVAudioSession.sharedInstance().setActive(true) } catch { - print(error) + Logger.debug(error) } } func scrollToBottom(){ diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift index 03c9012..1ffbbde 100644 --- a/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift @@ -5,11 +5,21 @@ // Created by liangshi on 2025/8/27. // +enum RecordBarSate:Int{ + case start + case stop +} + +protocol RecordBarDelegate { +// func recordBar(_ bar:RecordBar,languageChange language:AiSupportLanguage) + func recordBar(_ bar:RecordBar,stateChange state:RecordBarSate) +} + class RecordBar: BaseView { - let recordBtn = UIButton() + let recordBtn = LoadingButton() let leftItem = RecordBarItem() let rightItem = RecordBarItem() - + var delegate:RecordBarDelegate? override func setupViews() { backgroundColor = .white @@ -20,11 +30,14 @@ class RecordBar: BaseView { v.setImage(UIImage(named: "btn_record_stop"), for: .selected) v.addTarget(self, action: #selector(recordBtnAction), for: .touchUpInside) } - leftItem.do {v in -// v.backgroundColor = .green + leftItem.do { (v) in + v.language = AiSupportLanguage.chinse + v.yc.addTap(target: self, action: #selector(leftAction)) } - rightItem.do {v in -// v.backgroundColor = .yellow + rightItem.do { (v) in + + v.language = AiSupportLanguage.english + v.yc.addTap(target: self, action: #selector(rightAction)) } } @@ -34,12 +47,12 @@ class RecordBar: BaseView { make.center.equalToSuperview() } leftItem.snp.makeConstraints { make in - make.size.equalTo(56) + make.height.equalTo(56) make.centerY.equalTo(recordBtn) make.right.equalToSuperview().offset(-(kScreenWid/2 + 60)) } rightItem.snp.makeConstraints { make in - make.size.equalTo(56) + make.height.equalTo(56) make.centerY.equalTo(recordBtn) make.left.equalToSuperview().offset(kScreenWid/2 + 60) } @@ -47,6 +60,56 @@ class RecordBar: BaseView { @objc func recordBtnAction(){ recordBtn.isSelected = !recordBtn.isSelected + if recordBtn.isSelected { + delegate?.recordBar(self, stateChange: .start) + } + else{ + delegate?.recordBar(self, stateChange: .stop) + } + + if recordBtn.isSelected { + leftItem.alpha = 0.3 + rightItem.alpha = 0.3 + } + else{ + leftItem.alpha = 1 + rightItem.alpha = 1 + } + } + + @objc func leftAction(){ + if recordBtn.isSelected { + return + } + let v = LanguagePickerView(languages: AiSupportLanguage.translate,isLeft: true,left: leftItem.language,right: rightItem.language) + v.selectedIndex = v.list.firstIndex(where: {$0.title == leftItem.language.title}) ?? 0 + v.show() + v.didSelected = {[weak self] (index,value) in + guard let self = self else { return } + if index == 0 { + leftItem.language = value + } + else{ + rightItem.language = value + } + } + } + @objc func rightAction(){ + if recordBtn.isSelected { + return + } + let v = LanguagePickerView(languages: AiSupportLanguage.translate,isLeft: false,left: leftItem.language,right: rightItem.language) + v.selectedIndex = v.list.firstIndex(where: {$0.title == rightItem.language.title}) ?? 0 + v.show() + v.didSelected = {[weak self] (index,value) in + guard let self = self else { return } + if index == 0 { + leftItem.language = value + } + else{ + rightItem.language = value + } + } } class RecordBarItem: BaseView { @@ -54,17 +117,21 @@ class RecordBar: BaseView { let titleLabel = UILabel() let valueLabel = UILabel() + var language:AiSupportLanguage = AiSupportLanguage.chinse{ + didSet{ + titleLabel.text = language.title + } + } + override func setupViews() { // backgroundColor = .red addSubviews([titleLabel,valueLabel,icon]) icon.do { v in - v.image = UIImage(named: "") - v.backgroundColor = .black + v.image = UIImage(named: "polygon") } titleLabel.do { v in v.textColor = .rgb(0x121212) v.font = .bold(16) - v.text = "中文" } valueLabel.do { v in v.textColor = .rgb(0x666666) @@ -82,6 +149,7 @@ class RecordBar: BaseView { titleLabel.snp.makeConstraints { make in make.right.equalTo(icon.snp.left).offset(-5) make.centerY.equalTo(icon) + make.left.equalToSuperview() } valueLabel.snp.makeConstraints { make in make.right.equalTo(titleLabel) diff --git a/ShenYin/ShenYin/UI/Home/RecordDetail/RecordDetailVC.swift b/ShenYin/ShenYin/UI/Home/RecordDetail/RecordDetailVC.swift index 867562c..479fdd5 100644 --- a/ShenYin/ShenYin/UI/Home/RecordDetail/RecordDetailVC.swift +++ b/ShenYin/ShenYin/UI/Home/RecordDetail/RecordDetailVC.swift @@ -71,7 +71,7 @@ class RecordDetailVC:BaseVC{ try AVAudioSession.sharedInstance().setCategory(.playback, options: [options]) try AVAudioSession.sharedInstance().setActive(true) } catch { - print(error) + Logger.debug(error) } } override func navRightViewTapped() { diff --git a/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift b/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift index 52b2cc2..86e9c8d 100644 --- a/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift +++ b/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift @@ -7,28 +7,52 @@ import UIKit - +import JoyGemAI +import AVFoundation class RecordTranslateVC:BaseVC{ let toolBar = RecordBar() - let tableView = UITableView(frame: CGRectZero, style: .plain) - var dataList = [1,2,3] + let textView = PlaceHolderTextView() + let translateTextView = PlaceHolderTextView() + var messageList : [(String,UInt)] = [] + var translateList : [(String,UInt)] = [] + var recordFilePath : String? + override func viewDidLoad() { super.viewDidLoad() } override func setupViews() { navBar.title = "同传听译" navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + view.addSubviews([toolBar,textView,translateTextView]) + toolBar.delegate = self - tableView.backgroundColor = .clear - tableView.delegate = self - tableView.dataSource = self - tableView.estimatedRowHeight = 60 - tableView.separatorStyle = .none - tableView.register(TranslateCell.self, forCellReuseIdentifier: TranslateCell.reuseID) - view.addSubview(tableView) - view.addSubview(toolBar) - + textView.do { v in + v.isEditable = false + v.font = .regular(14) + v.text = "" + v.textColor = .hexString("#121212") + v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18) + } + textView.do { v in + v.isEditable = false + v.font = .regular(14) + v.text = "" + v.textColor = .hexString("#121212") + v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18) + v.yc.setBorder(width: 1, color: .black) + } + translateTextView.do { v in + v.isEditable = false + v.font = .regular(14) + v.text = "" + v.textColor = .hexString("#121212") +// v.yc.addgradientLayer(colors: [.hexString("#0092E1").withAlphaComponent(0.1),.white], direction: .top2down,rect: CGRect(x: 0, y: 0, width: kScreenWid, height: (kScreenHei - kNavBtm - 120 - 10)/2)) +// v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18) + v.yc.setBorder(width: 1, color: .black) +// v.yc.setCorners(withRoundedRect: CGRect(x: 0, y: 0, width: kScreenWid, height: (kScreenHei - kNavBtm - 120 - 10)/2), roundingCorners: [.topLeft,.topRight], cornerRadii: CGSize(width: 20, height: 20)) + + } } override func setupLayout() { toolBar.snp.makeConstraints { make in @@ -36,33 +60,152 @@ class RecordTranslateVC:BaseVC{ make.height.equalTo(120) make.bottom.equalToSuperview().inset(20) } - tableView.snp.makeConstraints { make in + textView.snp.makeConstraints { make in make.top.equalToSuperview().inset(80) make.left.right.equalToSuperview() + make.height.equalTo((kScreenHei - kNavBtm - 120 - 10)/2) + } + translateTextView.snp.makeConstraints { make in + make.top.equalTo(textView.snp.bottom).offset(10) + make.left.right.equalToSuperview() make.bottom.equalTo(toolBar.snp.top) } } + override func setupData() { + JoyGemSIManager.shared().delegate = self + + PcmSound.sharedInstance().delegate = self; + do { + try AVAudioSession.sharedInstance().setCategory(.playback) + try AVAudioSession.sharedInstance().setActive(true) + } catch { + Logger.debug(error) + } + PcmSound.sharedInstance().setup(16000, withchannels: 1) + } override func navRightViewTapped() { let tip = RecordTipsView(type: .tongchuan) tip.show() } func scrollToBottom(){ - if dataList.count > 0 { - tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) - } + let range = NSMakeRange(textView.text.count - 1, 1) + textView.scrollRangeToVisible(range) } } -extension RecordTranslateVC:UITableViewDelegate,UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return dataList.count + +extension RecordTranslateVC:RecordBarDelegate{ + + func recordBar(_ bar: RecordBar, stateChange state: RecordBarSate) { + textView.text = "123" + +// if state == .start { +// messageList.removeAll() +// translateList.removeAll() +// textView.text = nil +// translateTextView.text = nil +// +// if Thread.isMainThread { +// do { +// try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .default, options: []) +// try AVAudioSession.sharedInstance().setActive(true) +// } catch let error as NSError { +// Logger.debug("An error occurred setting the audio session category: \(error.localizedDescription)") +// } +// } else { +// DispatchQueue.main.sync { +// do { +// try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .default, options: []) +// try AVAudioSession.sharedInstance().setActive(true) +// } catch let error as NSError { +// Logger.debug("An error occurred setting the audio session category: \(error.localizedDescription)") +// } +// } +// } +// JoyGemSIManager.shared().originalLanguage = toolBar.leftItem.language.value +// JoyGemSIManager.shared().targetLanguage = toolBar.rightItem.language.value +// JoyGemSIManager.shared().start() +// } +// else if state == .stop{ +// JoyGemSIManager.shared().stop() +// bar.recordBtn.startAnimating {[weak self] in +// guard let self = self else{return} +// // toolBar.recordBtn.stopCli() +// let v = PopTextField() +// v.show() +// v.cancelTap = { +// +// } +// v.okTap = { +// +// } +// } +// } + } +} + +extension RecordTranslateVC : JoyGemSIManagerDelegate { + func siManagerStopped(_ manager: JoyGemSIManager, reason code: JoyGemRecordStopCode) { + if (code == .actively) { + YLprogressHUD.showAutoHiden("用户主动结束") + } else { + YLprogressHUD.showAutoHiden("用户被动结束") + } } - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = TranslateCell.cell(withTableView: tableView, indexPath: indexPath) - // cell.data = dataList[indexPath.row] - return cell + func siManager(_ manager: JoyGemSIManager, didUpdateRaw model: JoyGemAsrModel) { + debugPrint("text: \(model.text),index: \(model.index)") + let msg = messageList.firstIndex (where: { (str,idx) in + return idx == model.index; + }) + if (msg == nil) { + messageList.append((model.text,model.index)) + } else { + messageList[msg!] = (model.text,model.index) + } + + textView.text = messageList.compactMap({ (str,idx) in + return str + }).joined(separator: "\n") } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + func siManager(_ manager: JoyGemSIManager, didUpdateTranslate model: JoyGemAsrModel) { + debugPrint("translate text: \(model.text),index: \(model.index)") + let msg = translateList.firstIndex (where: { (str,idx) in + return idx == model.index; + }) + if (msg == nil) { + translateList.append((model.text,model.index)) + } else { + translateList[msg!] = (model.text,model.index) + } + translateTextView.text = translateList.compactMap({ (str,idx) in + return str + }).joined(separator: "\n") + } + + + func siManager(_ manager: JoyGemSIManager, saveFile path: String) { + debugPrint("path: \(path)") + recordFilePath = path + } + + func siManager(_ manager: JoyGemSIManager, stateChange code: JoyGemStateCode) { + debugPrint("code: \(code)") + } + + func siManager(_ manager: JoyGemSIManager, didUpdateAudioData data: Data) { + PcmSound.sharedInstance().feed(data) + } + + func siManager(_ manager: JoyGemSIManager, onError code: JoyGemErrorCode) { + + } +} + +extension RecordTranslateVC : PcmSoundDelegate { + + func remaining(_ frames: UInt) { + debugPrint("[frame:\(frames)]"); } } diff --git a/ShenYin/ShenYin/UI/Home/textTranslateVC/TextTranslateVC.swift b/ShenYin/ShenYin/UI/Home/TextTranslate/TextTranslateVC.swift similarity index 100% rename from ShenYin/ShenYin/UI/Home/textTranslateVC/TextTranslateVC.swift rename to ShenYin/ShenYin/UI/Home/TextTranslate/TextTranslateVC.swift diff --git a/ShenYin/ShenYin/UI/Home/textTranslateVC/TranslateCell.swift b/ShenYin/ShenYin/UI/Home/TextTranslate/TranslateCell.swift similarity index 100% rename from ShenYin/ShenYin/UI/Home/textTranslateVC/TranslateCell.swift rename to ShenYin/ShenYin/UI/Home/TextTranslate/TranslateCell.swift diff --git a/ShenYin/ShenYin/UI/Scan/QrVC.swift b/ShenYin/ShenYin/UI/Scan/QrVC.swift index e68a558..eb10eb3 100644 --- a/ShenYin/ShenYin/UI/Scan/QrVC.swift +++ b/ShenYin/ShenYin/UI/Scan/QrVC.swift @@ -37,7 +37,7 @@ class QrVC: LBXScanViewController { for result: LBXScanResult in arrayResult { if let str = result.strScanned { - print(str) + Logger.debug(str) } } diff --git a/ShenYin/ShenYin/UI/common/AppManager.swift b/ShenYin/ShenYin/UI/common/AppManager.swift index e9b1d90..9edb7d6 100644 --- a/ShenYin/ShenYin/UI/common/AppManager.swift +++ b/ShenYin/ShenYin/UI/common/AppManager.swift @@ -12,7 +12,7 @@ class App{ func topVC()->UIViewController!{ guard let vc = window?.rootViewController else{ - print("页面异常!!!") + Logger.debug("页面异常!!!") return UIViewController() } return getTopViewController(from: vc) diff --git a/ShenYin/ShenYin/UI/common/LogVC.swift b/ShenYin/ShenYin/UI/common/LogVC.swift index 2a0ce84..68882d2 100644 --- a/ShenYin/ShenYin/UI/common/LogVC.swift +++ b/ShenYin/ShenYin/UI/common/LogVC.swift @@ -50,10 +50,10 @@ class LogVC: BaseVC { let data = self.textView.text.data(using:.utf8) do { try data?.write(to: url, options:.atomic) - print(filePath) + Logger.debug(filePath) self.saveFile(withFilePath: filePath) } catch { - print(error) + Logger.debug(error) } } diff --git a/ShenYin/ShenYin/UI/common/PlaceHolderTextView.swift b/ShenYin/ShenYin/UI/common/PlaceHolderTextView.swift new file mode 100644 index 0000000..1662bc5 --- /dev/null +++ b/ShenYin/ShenYin/UI/common/PlaceHolderTextView.swift @@ -0,0 +1,66 @@ +// +// PlaceHolderTextView.swift +// ShenYin +// +// Created by liangshi on 2025/9/13. +// + +import UIKit + +extension UITextView { + @objc dynamic var observedText: String { + return text + } +} + +class PlaceHolderTextView: UITextView { + let label = UILabel() + + var placeHolde:String = ""{ + didSet{ + label.text = placeHolde + } + } + + + override init(frame: CGRect, textContainer: NSTextContainer?) { + super.init(frame: frame, textContainer: textContainer) + + self.addObserver(self, forKeyPath: "observedText", options: [.new,.old], context: nil) + + + label.do { v in + v.text = "此处将显示原文" + v.textAlignment = .center + v.textColor = .hexString("#666666") + v.font = .regular(16) + } + addSubview(label) + label.snp.makeConstraints { make in + make.center.equalToSuperview() + } + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { + if keyPath == "observedText", let textView = object as? UITextView { + if let newText = change?[.newKey] as? String { + Logger.debug("Text changed to: \(newText)") + if newText.isNotEmpty { + label.isHidden = true + } + else{ + label.isHidden = false + } + } + else{ + label.isHidden = false + } + } + } + + +} diff --git a/ShenYin/ShenYin/UI/common/pop/LanguagePicker/LanguagePickerView.swift b/ShenYin/ShenYin/UI/common/pop/LanguagePicker/LanguagePickerView.swift index 589a3f0..a89d4d5 100644 --- a/ShenYin/ShenYin/UI/common/pop/LanguagePicker/LanguagePickerView.swift +++ b/ShenYin/ShenYin/UI/common/pop/LanguagePicker/LanguagePickerView.swift @@ -91,6 +91,8 @@ class LanguagePickerView: BasePresentView { let language = segView.currentLanguage selectedIndex = list.firstIndex(where: {$0 == language})! tableView.reloadData() + didSelected?(0 ,segView.leftLabel.language) + didSelected?(1 ,segView.rightLabel.language) } } extension LanguagePickerView:UITableViewDelegate,UITableViewDataSource { diff --git a/ShenYin/ShenYin/UI/common/pop/PopTextField.swift b/ShenYin/ShenYin/UI/common/pop/PopTextField.swift index 07d9e51..6f7df53 100644 --- a/ShenYin/ShenYin/UI/common/pop/PopTextField.swift +++ b/ShenYin/ShenYin/UI/common/pop/PopTextField.swift @@ -18,7 +18,7 @@ class PopTextField: BasePresentView2 { var okTap:(()->Void)? init() { - super.init() + super.init(backgroundEnabled: false) } required init?(coder: NSCoder) { diff --git a/ShenYin/ShenYin/UI/common/pop/RecordTipsView.swift b/ShenYin/ShenYin/UI/common/pop/RecordTipsView.swift index dbdf37d..4ae8ed7 100644 --- a/ShenYin/ShenYin/UI/common/pop/RecordTipsView.swift +++ b/ShenYin/ShenYin/UI/common/pop/RecordTipsView.swift @@ -106,7 +106,7 @@ class RecordTipsView: BasePresentView { m.left.right.equalToSuperview().inset(30) } actionbtn.snp.makeConstraints { (m) in - m.top.equalTo(desLabel2.snp.bottom).offset(40) + m.bottom.equalToSuperview().inset(30) m.left.right.equalToSuperview().inset(52) m.height.equalTo(46) } @@ -169,6 +169,6 @@ class RecordTipsView: BasePresentView { hide() } @objc func btnAction(){ - + hide() } } -- 2.17.1