Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a long pause for AVSpeechSynthesizer?

I found -- can add a small pause like the number count down:

10--9--8--7--6--5--4--3--2--1--

But I don't know how to add a long pause, for like 1 sec?

Any idea?

like image 585
mko Avatar asked Dec 29 '13 10:12

mko


3 Answers

Even easier in Swift 3

utterance.preUtteranceDelay = 1.0

or

utterance.postUtteranceDelay = 1.0

for a one second delay assuming each number is it's own utterance (like in a loop). You'd probably have to reduce the delay slightly to take account for the actual speaking duration of each number.

like image 137
User Avatar answered Oct 20 '22 19:10

User


For a normal delay we can add a ":" (colon) between each of the words.

eg:-

utterance = AVSpeechUtterance(string: String(format: "Time: 20 minutes: 15 seconds")

the output will ----- " Time (delay) 20 minutes (delay) 15 seconds "

like image 37
Kiran P Nair Avatar answered Oct 20 '22 19:10

Kiran P Nair


AVSpeechUtterance has postUtteranceDelay properity which decides the delay. utterance.postUtteranceDelay = 1.0f; // or 1s equaivalent to NSTimeInterval

@property(nonatomic) NSTimeInterval postUtteranceDelay Description The amount of time a speech synthesizer will wait after the utterance is spoken before handling the next queued utterance.

like image 1
Liangjun Avatar answered Oct 20 '22 20:10

Liangjun