Code Monkey home page Code Monkey logo

qhspeechsynthesizerqueue's Introduction

QHSpeechSynthesizerQueue

Build Status
Queue management system for AVSpeechSynthesizer

Installation

Cocoapods

Add this to your Podfile:

pod 'QHSpeechSynthesizerQueue'

Run a pod install and import the header where you need it:

#import <QHSpeechSynthesizerQueue.h>

Manually

Drop QHSpeechSynthesizerQueue.h and QHSpeechSynthesizerQueue.m in your project, then

#import "QHSpeechSynthesizerQueue.h"

##Usage

Initialization

QHSpeechSynthesizerQueue *synthesizerQueue = [[QHSpeechSynthesizerQueue alloc] init];

Adding messages to the queue

Add a message at the end of the queue
[synthesizerQueue readLast:@"This message will be added to the end of the queue" 
                  withLanguage:@"en_US"
                  andRate:@"0.2"];
Insert a message to be read immediatly after the current message being read
[synthesizerQueue readNext:@"This message will be read next"
                  withLanguage:@"en_US"
                  andRate:@"0.2"
                  andClearQueue:NO];

If you set andClearQueue: to YES, the queue will be cleared and this will be the last message to be read.

Interrupt the current message and read this one immediately
[synthesizerQueue readImmediately:@"This message will be read next"
                  withLanguage:@"en_US"
                  andRate:@"0.2"
                  andClearQueue:NO];

If you set andClearQueue: to YES, the queue will be cleared and this will be the last message to be read.

Playback actions

Stop

Stop the queue's playback and clear the queue immediately.

[synthesizerQueue stop];
Stop after current

Stop the queue's playback and clear the queue. If something is currently being read, it will stop afterwards.

[synthesizerQueue stopAfterCurrent];
Pause

Pause the queue's playback immediately.

[synthesizerQueue pause];
Pause after current

Pause the queue's playback. If something is currently being read, it will pause afterwards.

[synthesizerQueue pauseAfterCurrent];
Resume

Resume the queue's playback.

[synthesizerQueue resume];
Clear queue

Clear the queue. If something is being read, it will not be interupted and future added messages will be read if not paused/stopped.

[synthesizerQueue clearQueue];

Properties

BOOL duckOthers

Set this to YES to duck all the device's audio sessions when a string is being read. Defaults to YES.

synthesizerQueue.duckOthers = YES;
NSTimeInterval preDelay

The delay before reading a message. Default is 0.0

synthesizerQueue.preDelay = 1.0;
NSTimeInterval postDelay

The delay after reading a message. Default is 0.0

synthesizerQueue.postDelay = 1.0;

Delegate

You can set a QHSpeechSynthesizerQueueDelegate to be notified of playback events.

@protocol QHSpeechSynthesizerQueueDelegate <NSObject>

@optional
- (void)speechSynthesizerQueueDidStartTalking:(QHSpeechSynthesizerQueue *)queue;
- (void)speechSynthesizerQueueDidFinishTalking:(QHSpeechSynthesizerQueue *)queue;
- (void)speechSynthesizerQueueDidPauseTalking:(QHSpeechSynthesizerQueue *)queue;
- (void)speechSynthesizerQueueDidContinueTalking:(QHSpeechSynthesizerQueue *)queue;
- (void)speechSynthesizerQueueDidCancelTalking:(QHSpeechSynthesizerQueue *)queue;
- (void)speechSynthesizerQueueWillStartTalking:(QHSpeechSynthesizerQueue *)queue;

@end

qhspeechsynthesizerqueue's People

Contributors

quentinhayot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.