-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ryan Lintott
committed
Jul 29, 2021
1 parent
5e1d3cc
commit 438a9bc
Showing
5 changed files
with
106 additions
and
51 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
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,51 @@ | ||
// | ||
// OEVoice+AVFoundation.swift | ||
// OEVoice | ||
// | ||
// Created by Ryan Lintott on 2021-07-29. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
@available(iOS 10.0, *) | ||
extension OEVoice { | ||
public var shortIdentifier: String { | ||
switch self { | ||
case .siriMarthaGBcompact: | ||
if #available(iOS 14.5, *) { | ||
return "siri_Martha_en-GB_compact" | ||
} else { | ||
return "siri_female_en-GB_compact" | ||
} | ||
case .siriArthurGBcompact: | ||
if #available(iOS 14.5, *) { | ||
return "siri_Aurthur_en-GB_compact" | ||
} else { | ||
return "siri_male_en-GB_compact" | ||
} | ||
case .siriNickyUScompact: | ||
if #available(iOS 14.5, *) { | ||
return "siri_Nicky_en-US_compact" | ||
} else { | ||
return "siri_female_en-US_compact" | ||
} | ||
case .siriAaronUScompact: | ||
if #available(iOS 14.5, *) { | ||
return "siri_Aaron_en-US_compact" | ||
} else { | ||
return "siri_male_en-US_compact" | ||
} | ||
case .danielGBcompact: | ||
return "Daniel-compact" | ||
} | ||
} | ||
|
||
public var identifier: String { | ||
return "com.apple.ttsbundle.".appending(shortIdentifier) | ||
} | ||
|
||
public var voice: AVSpeechSynthesisVoice? { | ||
AVSpeechSynthesisVoice(identifier: identifier) | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// SpecialCharacter.swift | ||
// TextToSpeech | ||
// OEVoice | ||
// | ||
// Created by Ryan Lintott on 2021-06-23. | ||
// | ||
|
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,30 @@ | ||
// | ||
// String-extensions.swift | ||
// Wordhord | ||
// | ||
// Created by Ryan Lintott on 2020-11-06. | ||
// | ||
|
||
import SwiftUI | ||
|
||
internal extension String { | ||
func droppingSuffix<S: StringProtocol>(_ string: S) -> String { | ||
guard self.hasSuffix(string) else { return String(self) } | ||
return String(self.dropLast(string.count)) | ||
} | ||
|
||
func droppingPrefix<S: StringProtocol>(_ string: S) -> String { | ||
guard self.hasPrefix(string) else { return String(self) } | ||
return String(self.dropFirst(string.count)) | ||
} | ||
|
||
func replacingSuffixOccurrence(of string: String, with replacement: String) -> String { | ||
guard self.hasSuffix(string) else { return self } | ||
return self.droppingSuffix(string).appending(replacement) | ||
} | ||
|
||
func replacingPrefixOccurrence(of string: String, with replacement: String) -> String { | ||
guard self.hasPrefix(string) else { return self } | ||
return replacement.appending(self.droppingPrefix(string)) | ||
} | ||
} |