I am currently working on a high level Python interface to the AVSpeechUtterance/AVSpeechSynthesizer/AVSpeechSynthesisVoice triad. To do so, I'm creating Python classes that bridge the access to the Objective-c classes, following the Apple Documentation. The low level classes are just about directly bridging the objc classes to Python, with a method on each of them to convert the python instance back to an ObjCInstance
. On top of that, a high level interface will be created that functions similar to speech.say
, but running directly on objc_util
. Means that to use it you can follow the top level interface, without worrying about the objective-c classes in the backend.
I'm currently halfway through the low level Python classes, hoping to release to PyPI (Python 3 only though) later this week.
@cvp thanks for the research you've already did on this, it's on that snippet I've been able to figure the rest out :)
Edit: Quick prototype for the high level interface works nicely together, here's a sample of how the code above would look like (though it will get a couple naming upgrades and more configuration options):
import av_speech
speech = av_speech.AVSpeech()
voices = av_speech.AVSpeechSynthesisVoice.get_speech_voices()
for voice in voices:
print(voice)
speech.set_voice(av_speech.AVSpeechSynthesisVoice.voice_with_identifier('com.apple.ttsbundle.siri_male_en-AU_compact'))
speech.say('Hello, I'm the voice of the Australian male of Siri')
Alternative for the set_voice line is speech.set_voice(av_speech.AVSpeechSynthesisVoice.voice_with_language('en-AU', av_speech.AVSpeechSynthesisVoiceGender.MALE))
, so it is easy to configure.