문제

I am using AVSpeechSynthesizer for text-to-speech in my app. Is it possible to stop the playback in the middle, e.g. if the user hits a stop button?

도움이 되었습니까?

해결책

Looking at the Documentation for AVSpeechSynthesizer, you need to call -[AVSpeechSynthesizer pauseSpeakingAtBoundary:] to stop speaking, and, then -[AVSpeechSynthesizer continueSpeaking] to continue speaking again afterwards.

You can choose to pause speaking right away (AVSpeechBoundaryImmediate), or, at the end of the current word (AVSpeechBoundaryWord).

다른 팁

In swift:

synthesizer.stopSpeaking(at: .immediate)

or

synthesizer.stopSpeaking(at: .word)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top