OSSSpeech

public class OSSSpeech : NSObject
extension OSSSpeech: SFSpeechRecognitionTaskDelegate, SFSpeechRecognizerDelegate

Speech is the primary interface. To use, set the voice and then call .speak(string: "your string")

Variables

  • Delegate allows for the recieving of spoken events.

    Declaration

    Swift

    public weak var delegate: OSSSpeechDelegate?
  • An object that allows overriding the default AVVoice options.

    Declaration

    Swift

    public var voice: OSSVoice?
  • Speech recognition variable to determine if recognition should use on device capabilities if available

    Not all devices support on device speech recognition and only devices operating with iOS 13 or higher support it.

    On device recognition offers many benefits such as working without network connectivity, no data costs and longer recording-to-transcription.

    On device recognition comes at a cost of accurate transcription though; speech recognition is less accurate with on device recognition.

    Declaration

    Swift

    public var shouldUseOnDeviceRecognition: Bool
  • The task type by default is undefined. Changing the task type will change how speech recognition performs.

    Declaration

    Swift

    public var recognitionTaskType: OSSSpeechRecognitionTaskType
  • The object used to enable translation of strings to synthsized voice.

    Declaration

    Swift

    public var utterance: OSSUtterance?
  • Audio Session can be overriden should you choose to.

    Declaration

    Swift

    public var audioSession: AVAudioSession { get set }
  • srp

    This property handles permission authorization. This property is intentionally named vaguely to prevent accidental overriding.

    Declaration

    Swift

    public var srp: SFSpeechRecognizer.Type

Lifecycle

  • A singleton object to ensure conformity accross the application it is used in.

    Declaration

    Swift

    public class var shared: OSSSpeech { get }

Public Methods

  • Pass in a string to speak. This will set the speechString on the utterance.

    Declaration

    Swift

    public func speakText(_ text: String? = nil)

    Parameters

    text

    An String object.

  • Pass in an attributed string to speak. This will set the attributed string on the utterance.

    Declaration

    Swift

    public func speakAttributedText(attributedText: NSAttributedString)

    Parameters

    attributedText

    An NSAttributedString object.

Public Voice Recording Methods

  • Record and recognise speech

    This method will check to see if user is authorised to record. If they are, the recording will proceed.

    Upon checking the authorisation and being registered successful, a check to determine if a recording session is active will be made and any active session will be cancelled.

    Declaration

    Swift

    public func recordVoice(requestMicPermission requested: Bool = true)
  • End recording of speech session if one exists.

    Declaration

    Swift

    public func endVoiceRecording()

Private Voice Recording

  • Undocumented

    Declaration

    Swift

    func engineSetup(_ engine: AVAudioEngine) -> Bool

SFSpeechRecognitionTaskDelegate Methods

SFSpeechRecognizerDelegate Methods

  • Docs available by Google searching for SFSpeechRecognizerDelegate

    Declaration

    Swift

    public func speechRecognizer(_ speechRecognizer: SFSpeechRecognizer, availabilityDidChange available: Bool)