Skip to content

Instantly share code, notes, and snippets.

View jevgenits's full-sized avatar

Jevgeni Tsaikin jevgenits

View GitHub Profile
#import "TSTextToSpeechUtils.h"
@interface TSTextToSpeechUtils ()
@property (strong, nonatomic) AVSpeechSynthesizer *synthesizer;
@property (strong, nonatomic) AVSpeechUtterance *lastPlayingUtterance;
@property (strong, nonatomic) AVAudioSession *audioSession;
@end
@jevgenits
jevgenits / textospeechheader.h
Last active May 27, 2020 15:28
textospeechheader
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
@interface TSTextToSpeechUtils : NSObject<AVSpeechSynthesizerDelegate>
- (void)synthesizeSpeechForText:(NSString *)text;
@end
@jevgenits
jevgenits / texttospeechsynthesizerobjc.m
Created October 24, 2017 18:59
texttospeechsynthesizerobjc
// HEADER FILE
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
@interface TSTextToSpeechUtils : NSObject<AVSpeechSynthesizerDelegate>
- (void)synthesizeSpeechForText:(NSString *)text;
@end
@jevgenits
jevgenits / texttospeechsynthesizerswift.swift
Created October 24, 2017 18:53
texttospeechsynthesizerswift
@objc
class TextToSpeechUtils: NSObject, AVSpeechSynthesizerDelegate {
let synthesizer = AVSpeechSynthesizer()
let audioSession = AVAudioSession.sharedInstance()
let defaultLanguage = "en-US"
var lastPlayingUtterance: AVSpeechUtterance?
public func synthesizeSpeech(forText text: String) {