- Accessing voice function with one line code
- Corresponds to the language of 37 countries
- Easy to use, fully customisable regarding speech speed and voice tone
- Enable to know when the speech start and when it's end
- Available as sound player
Add the Speaker to your project manually (drag & drop the file into your project).
Pass text
and language
or country
to Speaker. That's all!
Speaker.speech(text: "Hello Speaker!", language: "en-US")
Speaker.speech(text: "Hello Speaker!", country: .US)
Here is a list of supported languages
interrupt
can interrupt the speaking in the middle of the speech. The default value is false
.
Speaker.speech(text: "Hello Speaker!", country: .US, interrupt: true)
rate
can adjust the speed of the speech. It is ranged from 0.0
to 1.0
. The default value is 0.0
.
Speaker.speech(text: "Hello Speaker!", country: .US, rate: 1.0)
pitch
can decide the pitch of the voice. Value range is from 0.5
to 2.0
. The default value is 1.0
.
Speaker.speech(text: "Hello Speaker!", country: .US, pitch: 1.0)
You might like to know when the speech starts and when it ends. In this case, bellow is how to get these callbacks.
Speaker.speech(text: "Hello Speaker!", country: .US, started: {
print("Started")
})
Speaker.speech(text: "Hello Speaker!", country: .US, finished: {
print("Finished")
})
- You can sets both callbacks
Speaker.speech(text: "Hello Speaker", language: "en-US", started: {
print("Started")
}, finished: {
print("Finished")
})
- You can play sounds too.
Speaker.play(resource: "sample", type: "mp3")
- Callback (finished only) also can be implemented like bellow sample
Speaker.play(resource: "sample", type: "mp3", finished: {
print("Finished")
})
iOS 8+ Swift 3.0+ Xcode 8.0+
This project is available under the MIT license. See the LICENSE file for more info.