Skip to content

Speaker is a sound management library with easy use for AVSpeechSynthesizer and AVAudioPlayer.

License

Notifications You must be signed in to change notification settings

wataru-maeda/speaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Speaker

Features

  • 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

Installation

Add the Speaker to your project manually (drag & drop the file into your project).

Usage

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 speech

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)

Change Speed

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)

Change Pitch

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)

Get Start and End

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")
})

Play Sound file

  • 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")
})

Requirements

iOS 8+ Swift 3.0+ Xcode 8.0+

License

This project is available under the MIT license. See the LICENSE file for more info.

About

Speaker is a sound management library with easy use for AVSpeechSynthesizer and AVAudioPlayer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages