-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 合并查字和查词功能,更加方便高效 - 优化应用细节和体验
- Loading branch information
Showing
14 changed files
with
428 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,12 @@ | |
/* Begin PBXBuildFile section */ | ||
2D6303726115B67060D09E85 /* Pods_iWuBiTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AA5AA6FD67142615E34DC61 /* Pods_iWuBiTests.framework */; }; | ||
3719B7397CAA52057F9F1153 /* Pods_iWuBiUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6E83B6E1E91072EBEA6E329 /* Pods_iWuBiUITests.framework */; }; | ||
6D0B41282983DDFE006F8C18 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6D0B41272983DDFE006F8C18 /* [email protected] */; }; | ||
6D0B41292983DDFE006F8C18 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6D0B41272983DDFE006F8C18 /* [email protected] */; }; | ||
6D0B412B2983E336006F8C18 /* TCVoiceUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0B412A2983E336006F8C18 /* TCVoiceUtils.swift */; }; | ||
6D0B412C2983E336006F8C18 /* TCVoiceUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0B412A2983E336006F8C18 /* TCVoiceUtils.swift */; }; | ||
6D0B412E2983FB1E006F8C18 /* IHTCTTSViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0B412D2983FB1E006F8C18 /* IHTCTTSViewController.swift */; }; | ||
6D0B412F2983FB1E006F8C18 /* IHTCTTSViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0B412D2983FB1E006F8C18 /* IHTCTTSViewController.swift */; }; | ||
6D0BF3BF2442186B009EA94B /* IHTC98WordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB88DEB225B8E340099AC80 /* IHTC98WordViewController.swift */; }; | ||
6D0BF3C02442186B009EA94B /* IHTCAboutAppViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB88DE2225B8E340099AC80 /* IHTCAboutAppViewController.swift */; }; | ||
6D0BF3C12442186B009EA94B /* IHTCMeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB88DE3225B8E340099AC80 /* IHTCMeViewController.swift */; }; | ||
|
@@ -293,6 +299,9 @@ | |
4DFAA5851858A4D9CB53BF20 /* libPods-iWuBi-MacCatylyst.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iWuBi-MacCatylyst.a"; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
5AA5AA6FD67142615E34DC61 /* Pods_iWuBiTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iWuBiTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
5FABFA1D936DFEDD99C5AC4A /* Pods_iWuBi.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iWuBi.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
6D0B41272983DDFE006F8C18 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; }; | ||
6D0B412A2983E336006F8C18 /* TCVoiceUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TCVoiceUtils.swift; sourceTree = "<group>"; }; | ||
6D0B412D2983FB1E006F8C18 /* IHTCTTSViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IHTCTTSViewController.swift; sourceTree = "<group>"; }; | ||
6D0BF43E2442186B009EA94B /* iWuBi.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iWuBi.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
6D0BF441244218FC009EA94B /* iWuBi.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iWuBi.entitlements; sourceTree = "<group>"; }; | ||
6D3B83D5225E238200037787 /* iWuBi-orange-word.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "iWuBi-orange-word.png"; sourceTree = "<group>"; }; | ||
|
@@ -664,6 +673,7 @@ | |
6DB88DB9225B8E340099AC80 /* Images */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
6D0B41272983DDFE006F8C18 /* [email protected] */, | ||
6DA588A02605FD2400C351C4 /* [email protected] */, | ||
6DA588A12605FD2400C351C4 /* [email protected] */, | ||
6DA588932605FBC600C351C4 /* [email protected] */, | ||
|
@@ -758,6 +768,7 @@ | |
6D76E2F022632C1F005EACCA /* IHTCLearnDetailViewController.swift */, | ||
6DB88DE3225B8E340099AC80 /* IHTCMeViewController.swift */, | ||
6DA588AA2605FDC800C351C4 /* IHTCFavoritesListVC.swift */, | ||
6D0B412D2983FB1E006F8C18 /* IHTCTTSViewController.swift */, | ||
6DB88DE2225B8E340099AC80 /* IHTCAboutAppViewController.swift */, | ||
6DB88DE8225B8E340099AC80 /* IHTCAboutAppViewController.xib */, | ||
6DB1AF962278A7640051A288 /* ITAdvancelDetailViewController.swift */, | ||
|
@@ -789,6 +800,7 @@ | |
6DB88E1D225B8E720099AC80 /* Common */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
6D0B412A2983E336006F8C18 /* TCVoiceUtils.swift */, | ||
6DB88E1E225B8E720099AC80 /* CommonDefine.swift */, | ||
6DB88E1F225B8E720099AC80 /* ITCommonAPI.swift */, | ||
6D76E2B62262C613005EACCA /* IAppleServiceUtil.swift */, | ||
|
@@ -984,6 +996,7 @@ | |
6D0BF4002442186B009EA94B /* Main.storyboard in Resources */, | ||
6D0BF4012442186B009EA94B /* [email protected] in Resources */, | ||
6D0BF4022442186B009EA94B /* ITQuestionListViewCell.xib in Resources */, | ||
6D0B41292983DDFE006F8C18 /* [email protected] in Resources */, | ||
6D0BF4032442186B009EA94B /* [email protected] in Resources */, | ||
6D0BF4042442186B009EA94B /* iWuBi-orange-word.png in Resources */, | ||
6D0BF4052442186B009EA94B /* InfoPlist.strings in Resources */, | ||
|
@@ -1067,6 +1080,7 @@ | |
6D3B83E0225E27B500037787 /* Main.storyboard in Resources */, | ||
6D76E2D72263118D005EACCA /* [email protected] in Resources */, | ||
6DB88E0C225B8E340099AC80 /* ITQuestionListViewCell.xib in Resources */, | ||
6D0B41282983DDFE006F8C18 /* [email protected] in Resources */, | ||
6D531B71226379CB00C921B8 /* [email protected] in Resources */, | ||
6D3B83D6225E238300037787 /* iWuBi-orange-word.png in Resources */, | ||
6D3B83F2225E307700037787 /* InfoPlist.strings in Resources */, | ||
|
@@ -1281,12 +1295,14 @@ | |
6D0BF3D42442186B009EA94B /* ITQuestionListViewCell.swift in Sources */, | ||
6D0BF3D52442186B009EA94B /* ITCopyLabel.swift in Sources */, | ||
6D0BF3D62442186B009EA94B /* IAppleServiceUtil.swift in Sources */, | ||
6D0B412F2983FB1E006F8C18 /* IHTCTTSViewController.swift in Sources */, | ||
6DEB12B8244B536500CD4192 /* SceneDelegate.swift in Sources */, | ||
6D0BF3D72442186B009EA94B /* IHTC86WordViewController.swift in Sources */, | ||
6D0BF3D82442186B009EA94B /* ITBasePushTransitionVC.swift in Sources */, | ||
6D0BF3D92442186B009EA94B /* IHTCWuBiWordViewCell.swift in Sources */, | ||
6D0BF3DA2442186B009EA94B /* IHTCImgModel.swift in Sources */, | ||
6D0BF3DB2442186B009EA94B /* ITScalePopTransition.swift in Sources */, | ||
6D0B412C2983E336006F8C18 /* TCVoiceUtils.swift in Sources */, | ||
6D0BF3DC2442186B009EA94B /* IHTCLearnDetailViewController.swift in Sources */, | ||
6D0BF3DD2442186B009EA94B /* TableHeaderView.swift in Sources */, | ||
6D0BF3DE2442186B009EA94B /* ITPageTitleView.swift in Sources */, | ||
|
@@ -1326,12 +1342,14 @@ | |
6DB88E08225B8E340099AC80 /* ITQuestionListViewCell.swift in Sources */, | ||
6DB88E09225B8E340099AC80 /* ITCopyLabel.swift in Sources */, | ||
6D76E2B72262C613005EACCA /* IAppleServiceUtil.swift in Sources */, | ||
6D0B412E2983FB1E006F8C18 /* IHTCTTSViewController.swift in Sources */, | ||
6DEB12B7244B536500CD4192 /* SceneDelegate.swift in Sources */, | ||
6DB88E19225B8E340099AC80 /* IHTC86WordViewController.swift in Sources */, | ||
6DB88E14225B8E340099AC80 /* ITBasePushTransitionVC.swift in Sources */, | ||
6D76E27F225F95F7005EACCA /* IHTCWuBiWordViewCell.swift in Sources */, | ||
6D76E27C225F9064005EACCA /* IHTCImgModel.swift in Sources */, | ||
6DB88E1C225B8E340099AC80 /* ITScalePopTransition.swift in Sources */, | ||
6D0B412B2983E336006F8C18 /* TCVoiceUtils.swift in Sources */, | ||
6D76E2F122632C1F005EACCA /* IHTCLearnDetailViewController.swift in Sources */, | ||
6DB1AF952278A75D0051A288 /* TableHeaderView.swift in Sources */, | ||
6DB88E0A225B8E340099AC80 /* ITPageTitleView.swift in Sources */, | ||
|
@@ -1418,7 +1436,7 @@ | |
CODE_SIGN_ENTITLEMENTS = iWuBi/iWuBi.entitlements; | ||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; | ||
CODE_SIGN_STYLE = Automatic; | ||
CURRENT_PROJECT_VERSION = 2023.01.24; | ||
CURRENT_PROJECT_VERSION = 2023.01.27; | ||
DEVELOPMENT_TEAM = 28PV6G96R7; | ||
INFOPLIST_FILE = "$(SRCROOT)/iWuBi/Info.plist"; | ||
IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
|
@@ -1427,7 +1445,7 @@ | |
"@executable_path/Frameworks", | ||
); | ||
LIBRARY_SEARCH_PATHS = "$(inherited)"; | ||
MARKETING_VERSION = 7.0.0; | ||
MARKETING_VERSION = 7.1.0; | ||
PRODUCT_BUNDLE_IDENTIFIER = com.iHTCboy.iWuBi; | ||
PRODUCT_NAME = iWuBi; | ||
SUPPORTS_MACCATALYST = YES; | ||
|
@@ -1447,7 +1465,7 @@ | |
CODE_SIGN_ENTITLEMENTS = iWuBi/iWuBi.entitlements; | ||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; | ||
CODE_SIGN_STYLE = Automatic; | ||
CURRENT_PROJECT_VERSION = 2023.01.24; | ||
CURRENT_PROJECT_VERSION = 2023.01.27; | ||
DEVELOPMENT_TEAM = 28PV6G96R7; | ||
INFOPLIST_FILE = "$(SRCROOT)/iWuBi/Info.plist"; | ||
IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
|
@@ -1456,7 +1474,7 @@ | |
"@executable_path/Frameworks", | ||
); | ||
LIBRARY_SEARCH_PATHS = "$(inherited)"; | ||
MARKETING_VERSION = 7.0.0; | ||
MARKETING_VERSION = 7.1.0; | ||
PRODUCT_BUNDLE_IDENTIFIER = com.iHTCboy.iWuBi; | ||
PRODUCT_NAME = iWuBi; | ||
SUPPORTS_MACCATALYST = YES; | ||
|
@@ -1593,7 +1611,7 @@ | |
CODE_SIGN_ENTITLEMENTS = iWuBi/iWuBi.entitlements; | ||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; | ||
CODE_SIGN_STYLE = Automatic; | ||
CURRENT_PROJECT_VERSION = 2023.01.24; | ||
CURRENT_PROJECT_VERSION = 2023.01.27; | ||
DEVELOPMENT_TEAM = 28PV6G96R7; | ||
INFOPLIST_FILE = iWuBi/Info.plist; | ||
IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
|
@@ -1602,7 +1620,7 @@ | |
"@executable_path/Frameworks", | ||
); | ||
LIBRARY_SEARCH_PATHS = "$(inherited)"; | ||
MARKETING_VERSION = 7.0.0; | ||
MARKETING_VERSION = 7.1.0; | ||
PRODUCT_BUNDLE_IDENTIFIER = com.iHTCboy.iWuBi; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
SUPPORTS_MACCATALYST = YES; | ||
|
@@ -1622,7 +1640,7 @@ | |
CODE_SIGN_ENTITLEMENTS = iWuBi/iWuBi.entitlements; | ||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; | ||
CODE_SIGN_STYLE = Automatic; | ||
CURRENT_PROJECT_VERSION = 2023.01.24; | ||
CURRENT_PROJECT_VERSION = 2023.01.27; | ||
DEVELOPMENT_TEAM = 28PV6G96R7; | ||
INFOPLIST_FILE = iWuBi/Info.plist; | ||
IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
|
@@ -1631,7 +1649,7 @@ | |
"@executable_path/Frameworks", | ||
); | ||
LIBRARY_SEARCH_PATHS = "$(inherited)"; | ||
MARKETING_VERSION = 7.0.0; | ||
MARKETING_VERSION = 7.1.0; | ||
PRODUCT_BUNDLE_IDENTIFIER = com.iHTCboy.iWuBi; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
SUPPORTS_MACCATALYST = YES; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// | ||
// TCVoiceUtils.swift | ||
// iEnglish | ||
// | ||
// Created by HTC on 2023/1/26. | ||
// Copyright © 2023 iHTCboy. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
class TCVoiceUtils: NSObject { | ||
|
||
static let shared = TCVoiceUtils() | ||
// 参数 | ||
static var setupSuccess: Bool = false | ||
static var completion: (() -> Void)? | ||
|
||
// TTS | ||
static var synthesizer: AVSpeechSynthesizer = AVSpeechSynthesizer() | ||
static var utterance:AVSpeechUtterance = AVSpeechUtterance(string: "") | ||
|
||
static func playTTS(text: String, completion: (() -> Void)? = nil) { | ||
|
||
// 设置声音 | ||
if !TCVoiceUtils.setupSuccess { | ||
TCVoiceUtils.setupSuccess = true | ||
TCVoiceUtils.setupVoiceSystem(allowVoice: true) | ||
} | ||
|
||
if synthesizer.isSpeaking { | ||
utterance.volume = 0 | ||
synthesizer.delegate = nil | ||
synthesizer.stopSpeaking(at: AVSpeechBoundary.immediate) | ||
} | ||
|
||
TCVoiceUtils.completion = completion | ||
|
||
synthesizer.delegate = TCVoiceUtils.shared | ||
utterance = AVSpeechUtterance(string: text) | ||
utterance.voice = AVSpeechSynthesisVoice(language:"zh-CN") | ||
// utterance.volume = 1 | ||
utterance.rate = AVSpeechUtteranceDefaultSpeechRate // 范围:0~1 | ||
synthesizer.speak(utterance) | ||
} | ||
|
||
@discardableResult | ||
static func pauseTTS() -> Bool { | ||
return synthesizer.pauseSpeaking(at: AVSpeechBoundary.word) | ||
} | ||
|
||
@discardableResult | ||
static func continueTTS() -> Bool { | ||
return synthesizer.continueSpeaking() | ||
} | ||
|
||
static func stopTTS() { | ||
if synthesizer.isSpeaking { | ||
utterance.volume = 0 | ||
synthesizer.delegate = nil | ||
synthesizer.stopSpeaking(at: AVSpeechBoundary.immediate) | ||
} | ||
} | ||
|
||
static func playSound(audioPath: String, soundId: inout SystemSoundID) { | ||
let fileUrl = URL.init(fileURLWithPath: audioPath) | ||
|
||
AudioServicesCreateSystemSoundID(fileUrl as CFURL, &soundId) | ||
|
||
AudioServicesAddSystemSoundCompletion(soundId, nil, nil, { | ||
(soundID:SystemSoundID, _:UnsafeMutableRawPointer?) in | ||
}, nil) | ||
|
||
AudioServicesPlaySystemSound(soundId) | ||
} | ||
|
||
//设置声音模式(是否设备静音也播放) | ||
/// - Parameter allowVoice: 是否设备静音也播放 | ||
static func setupVoiceSystem(allowVoice: Bool) { | ||
if allowVoice { | ||
let audioSession = AVAudioSession.sharedInstance() | ||
try? audioSession.setCategory(AVAudioSession.Category.playback) | ||
try? audioSession.setActive(true, options: AVAudioSession.SetActiveOptions(rawValue: 0)) | ||
} else { | ||
let audioSession = AVAudioSession.sharedInstance() | ||
try? audioSession.setCategory(AVAudioSession.Category.ambient) | ||
try? audioSession.setActive(true, options: AVAudioSession.SetActiveOptions(rawValue: 0)) | ||
} | ||
} | ||
} | ||
|
||
extension TCVoiceUtils: AVSpeechSynthesizerDelegate { | ||
|
||
func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) { | ||
// 结束播放 | ||
TCVoiceUtils.completion?() | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.