Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Using Siri voices in Speech module
-
@cvp said:
@rex_noctis Did you try the 3 Australian voices?
speech: en-AU Objective-c: en-AU, Name: Catherine speech: en-AU Objective-c: en-AU, Name: Gordon speech: en-AU Objective-c: en-AU, Name: Karen```
How do I determine between those in the
speech.say()
line cause they’re allen-AU
-
@rex_noctis This code doesn’t use the Pythonista speech module but the Objective-c module.
-
@cvp okay thanks for your help!
-
@cvp Very interesting. Do you have a complete list of of the Objective-c number codes for each available Siri voice?
-
@djl if you print voices in previous script, you get
0 [AVSpeechSynthesisVoice 0x282513d80] Language: ar-SA, Name: Maged, Quality: Default [com.apple.ttsbundle.Maged-compact] [AVSpeechSynthesisVoice 0x282513d80] Language: ar-SA, Name: Maged, Quality: Default [com.apple.ttsbundle.Maged-compact] 1 [AVSpeechSynthesisVoice 0x282528540] Language: cs-CZ, Name: Zuzana, Quality: Default [com.apple.ttsbundle.Zuzana-compact] [AVSpeechSynthesisVoice 0x282528540] Language: cs-CZ, Name: Zuzana, Quality: Default [com.apple.ttsbundle.Zuzana-compact] 2 [AVSpeechSynthesisVoice 0x28256e2a0] Language: da-DK, Name: Sara, Quality: Default [com.apple.ttsbundle.Sara-compact] [AVSpeechSynthesisVoice 0x28256e2a0] Language: da-DK, Name: Sara, Quality: Default [com.apple.ttsbundle.Sara-compact] 3 [AVSpeechSynthesisVoice 0x282516310] Language: de-DE, Name: Anna, Quality: Default [com.apple.ttsbundle.Anna-compact] [AVSpeechSynthesisVoice 0x282516310] Language: de-DE, Name: Anna, Quality: Default [com.apple.ttsbundle.Anna-compact] 4 [AVSpeechSynthesisVoice 0x282517b20] Language: de-DE, Name: Helena, Quality: Default [com.apple.ttsbundle.siri_female_de-DE_compact] [AVSpeechSynthesisVoice 0x282517b20] Language: de-DE, Name: Helena, Quality: Default [com.apple.ttsbundle.siri_female_de-DE_compact] 5 [AVSpeechSynthesisVoice 0x28256fc00] Language: de-DE, Name: Martin, Quality: Default [com.apple.ttsbundle.siri_male_de-DE_compact] [AVSpeechSynthesisVoice 0x28256fc00] Language: de-DE, Name: Martin, Quality: Default [com.apple.ttsbundle.siri_male_de-DE_compact] 6 [AVSpeechSynthesisVoice 0x28256c880] Language: el-GR, Name: Melina, Quality: Default [com.apple.ttsbundle.Melina-compact] [AVSpeechSynthesisVoice 0x28256c880] Language: el-GR, Name: Melina, Quality: Default [com.apple.ttsbundle.Melina-compact] 7 [AVSpeechSynthesisVoice 0x282516670] Language: en-AU, Name: Catherine, Quality: Default [com.apple.ttsbundle.siri_female_en-AU_compact] [AVSpeechSynthesisVoice 0x282516670] Language: en-AU, Name: Catherine, Quality: Default [com.apple.ttsbundle.siri_female_en-AU_compact] 8 [AVSpeechSynthesisVoice 0x282516860] Language: en-AU, Name: Gordon, Quality: Default [com.apple.ttsbundle.siri_male_en-AU_compact] [AVSpeechSynthesisVoice 0x282516860] Language: en-AU, Name: Gordon, Quality: Default [com.apple.ttsbundle.siri_male_en-AU_compact] 9 [AVSpeechSynthesisVoice 0x282516ad0] Language: en-AU, Name: Karen, Quality: Default [com.apple.ttsbundle.Karen-compact] [AVSpeechSynthesisVoice 0x282516ad0] Language: en-AU, Name: Karen, Quality: Default [com.apple.ttsbundle.Karen-compact] 10 [AVSpeechSynthesisVoice 0x2825172a0] Language: en-GB, Name: Arthur, Quality: Default [com.apple.ttsbundle.siri_male_en-GB_compact] [AVSpeechSynthesisVoice 0x2825172a0] Language: en-GB, Name: Arthur, Quality: Default [com.apple.ttsbundle.siri_male_en-GB_compact] 11 [AVSpeechSynthesisVoice 0x282516760] Language: en-GB, Name: Daniel, Quality: Default [com.apple.ttsbundle.Daniel-compact] [AVSpeechSynthesisVoice 0x282516760] Language: en-GB, Name: Daniel, Quality: Default [com.apple.ttsbundle.Daniel-compact] 12 [AVSpeechSynthesisVoice 0x282523c70] Language: en-GB, Name: Martha, Quality: Default [com.apple.ttsbundle.siri_female_en-GB_compact] [AVSpeechSynthesisVoice 0x282523c70] Language: en-GB, Name: Martha, Quality: Default [com.apple.ttsbundle.siri_female_en-GB_compact] 13 [AVSpeechSynthesisVoice 0x28256f760] Language: en-IE, Name: Moira, Quality: Default [com.apple.ttsbundle.Moira-compact] [AVSpeechSynthesisVoice 0x28256f760] Language: en-IE, Name: Moira, Quality: Default [com.apple.ttsbundle.Moira-compact] 14 [AVSpeechSynthesisVoice 0x28256f930] Language: en-US, Name: Aaron, Quality: Default [com.apple.ttsbundle.siri_male_en-US_compact] [AVSpeechSynthesisVoice 0x28256f930] Language: en-US, Name: Aaron, Quality: Default [com.apple.ttsbundle.siri_male_en-US_compact] 15 [AVSpeechSynthesisVoice 0x282516ef0] Language: en-US, Name: Fred, Quality: Default [com.apple.speech.synthesis.voice.Fred] [AVSpeechSynthesisVoice 0x282516ef0] Language: en-US, Name: Fred, Quality: Default [com.apple.speech.synthesis.voice.Fred] 16 [AVSpeechSynthesisVoice 0x28256cca0] Language: en-US, Name: Nicky, Quality: Default [com.apple.ttsbundle.siri_female_en-US_compact] [AVSpeechSynthesisVoice 0x28256cca0] Language: en-US, Name: Nicky, Quality: Default [com.apple.ttsbundle.siri_female_en-US_compact] 17 [AVSpeechSynthesisVoice 0x28256cc40] Language: en-US, Name: Samantha, Quality: Default [com.apple.ttsbundle.Samantha-compact] [AVSpeechSynthesisVoice 0x28256cc40] Language: en-US, Name: Samantha, Quality: Default [com.apple.ttsbundle.Samantha-compact] 18 [AVSpeechSynthesisVoice 0x28256f3e0] Language: en-ZA, Name: Tessa, Quality: Default [com.apple.ttsbundle.Tessa-compact] [AVSpeechSynthesisVoice 0x28256f3e0] Language: en-ZA, Name: Tessa, Quality: Default [com.apple.ttsbundle.Tessa-compact] 19 [AVSpeechSynthesisVoice 0x28256e660] Language: es-ES, Name: Monica, Quality: Default [com.apple.ttsbundle.Monica-compact] [AVSpeechSynthesisVoice 0x28256e660] Language: es-ES, Name: Monica, Quality: Default [com.apple.ttsbundle.Monica-compact] 20 [AVSpeechSynthesisVoice 0x28256f270] Language: es-MX, Name: Paulina, Quality: Default [com.apple.ttsbundle.Paulina-compact] [AVSpeechSynthesisVoice 0x28256f270] Language: es-MX, Name: Paulina, Quality: Default [com.apple.ttsbundle.Paulina-compact] 21 [AVSpeechSynthesisVoice 0x28256f910] Language: fi-FI, Name: Satu, Quality: Default [com.apple.ttsbundle.Satu-compact] [AVSpeechSynthesisVoice 0x28256f910] Language: fi-FI, Name: Satu, Quality: Default [com.apple.ttsbundle.Satu-compact] 22 [AVSpeechSynthesisVoice 0x282516530] Language: fr-CA, Name: Amelie, Quality: Default [com.apple.ttsbundle.Amelie-compact] [AVSpeechSynthesisVoice 0x282516530] Language: fr-CA, Name: Amelie, Quality: Default [com.apple.ttsbundle.Amelie-compact] 23 [AVSpeechSynthesisVoice 0x282516b10] Language: fr-FR, Name: Daniel, Quality: Default [com.apple.ttsbundle.siri_male_fr-FR_compact] [AVSpeechSynthesisVoice 0x282516b10] Language: fr-FR, Name: Daniel, Quality: Default [com.apple.ttsbundle.siri_male_fr-FR_compact] 24 [AVSpeechSynthesisVoice 0x28251bd00] Language: fr-FR, Name: Marie, Quality: Default [com.apple.ttsbundle.siri_female_fr-FR_compact] [AVSpeechSynthesisVoice 0x28251bd00] Language: fr-FR, Name: Marie, Quality: Default [com.apple.ttsbundle.siri_female_fr-FR_compact] 25 [AVSpeechSynthesisVoice 0x28256e200] Language: fr-FR, Name: Thomas, Quality: Default [com.apple.ttsbundle.Thomas-compact] [AVSpeechSynthesisVoice 0x28256e200] Language: fr-FR, Name: Thomas, Quality: Default [com.apple.ttsbundle.Thomas-compact] 26 [AVSpeechSynthesisVoice 0x282514d40] Language: he-IL, Name: Carmit, Quality: Default [com.apple.ttsbundle.Carmit-compact] [AVSpeechSynthesisVoice 0x282514d40] Language: he-IL, Name: Carmit, Quality: Default [com.apple.ttsbundle.Carmit-compact] 27 [AVSpeechSynthesisVoice 0x282516a60] Language: hi-IN, Name: Lekha, Quality: Default [com.apple.ttsbundle.Lekha-compact] [AVSpeechSynthesisVoice 0x282516a60] Language: hi-IN, Name: Lekha, Quality: Default [com.apple.ttsbundle.Lekha-compact] 28 [AVSpeechSynthesisVoice 0x282523d30] Language: hu-HU, Name: Mariska, Quality: Default [com.apple.ttsbundle.Mariska-compact] [AVSpeechSynthesisVoice 0x282523d30] Language: hu-HU, Name: Mariska, Quality: Default [com.apple.ttsbundle.Mariska-compact] 29 [AVSpeechSynthesisVoice 0x282517990] Language: id-ID, Name: Damayanti, Quality: Default [com.apple.ttsbundle.Damayanti-compact] [AVSpeechSynthesisVoice 0x282517990] Language: id-ID, Name: Damayanti, Quality: Default [com.apple.ttsbundle.Damayanti-compact] 30 [AVSpeechSynthesisVoice 0x282516730] Language: it-IT, Name: Alice, Quality: Default [com.apple.ttsbundle.Alice-compact] [AVSpeechSynthesisVoice 0x282516730] Language: it-IT, Name: Alice, Quality: Default [com.apple.ttsbundle.Alice-compact] 31 [AVSpeechSynthesisVoice 0x282515fe0] Language: ja-JP, Name: Hattori, Quality: Default [com.apple.ttsbundle.siri_male_ja-JP_compact] [AVSpeechSynthesisVoice 0x282515fe0] Language: ja-JP, Name: Hattori, Quality: Default [com.apple.ttsbundle.siri_male_ja-JP_compact] 32 [AVSpeechSynthesisVoice 0x282516450] Language: ja-JP, Name: Kyoko, Quality: Default [com.apple.ttsbundle.Kyoko-compact] [AVSpeechSynthesisVoice 0x282516450] Language: ja-JP, Name: Kyoko, Quality: Default [com.apple.ttsbundle.Kyoko-compact] 33 [AVSpeechSynthesisVoice 0x28256d8a0] Language: ja-JP, Name: O-ren, Quality: Default [com.apple.ttsbundle.siri_female_ja-JP_compact] [AVSpeechSynthesisVoice 0x28256d8a0] Language: ja-JP, Name: O-ren, Quality: Default [com.apple.ttsbundle.siri_female_ja-JP_compact] 34 [AVSpeechSynthesisVoice 0x2825287b0] Language: ko-KR, Name: Yuna, Quality: Default [com.apple.ttsbundle.Yuna-compact] [AVSpeechSynthesisVoice 0x2825287b0] Language: ko-KR, Name: Yuna, Quality: Default [com.apple.ttsbundle.Yuna-compact] 35 [AVSpeechSynthesisVoice 0x282515ef0] Language: nl-BE, Name: Ellen, Quality: Default [com.apple.ttsbundle.Ellen-compact] [AVSpeechSynthesisVoice 0x282515ef0] Language: nl-BE, Name: Ellen, Quality: Default [com.apple.ttsbundle.Ellen-compact] 36 [AVSpeechSynthesisVoice 0x28256fa30] Language: nl-NL, Name: Xander, Quality: Default [com.apple.ttsbundle.Xander-compact] [AVSpeechSynthesisVoice 0x28256fa30] Language: nl-NL, Name: Xander, Quality: Default [com.apple.ttsbundle.Xander-compact] 37 [AVSpeechSynthesisVoice 0x28256f8e0] Language: no-NO, Name: Nora, Quality: Default [com.apple.ttsbundle.Nora-compact] [AVSpeechSynthesisVoice 0x28256f8e0] Language: no-NO, Name: Nora, Quality: Default [com.apple.ttsbundle.Nora-compact] 38 [AVSpeechSynthesisVoice 0x282528200] Language: pl-PL, Name: Zosia, Quality: Default [com.apple.ttsbundle.Zosia-compact] [AVSpeechSynthesisVoice 0x282528200] Language: pl-PL, Name: Zosia, Quality: Default [com.apple.ttsbundle.Zosia-compact] 39 [AVSpeechSynthesisVoice 0x2825166f0] Language: pt-BR, Name: Luciana, Quality: Default [com.apple.ttsbundle.Luciana-compact] [AVSpeechSynthesisVoice 0x2825166f0] Language: pt-BR, Name: Luciana, Quality: Default [com.apple.ttsbundle.Luciana-compact] 40 [AVSpeechSynthesisVoice 0x282517f30] Language: pt-PT, Name: Joana, Quality: Default [com.apple.ttsbundle.Joana-compact] [AVSpeechSynthesisVoice 0x282517f30] Language: pt-PT, Name: Joana, Quality: Default [com.apple.ttsbundle.Joana-compact] 41 [AVSpeechSynthesisVoice 0x282515010] Language: ro-RO, Name: Ioana, Quality: Default [com.apple.ttsbundle.Ioana-compact] [AVSpeechSynthesisVoice 0x282515010] Language: ro-RO, Name: Ioana, Quality: Default [com.apple.ttsbundle.Ioana-compact] 42 [AVSpeechSynthesisVoice 0x28256d220] Language: ru-RU, Name: Milena, Quality: Default [com.apple.ttsbundle.Milena-compact] [AVSpeechSynthesisVoice 0x28256d220] Language: ru-RU, Name: Milena, Quality: Default [com.apple.ttsbundle.Milena-compact] 43 [AVSpeechSynthesisVoice 0x2825174e0] Language: sk-SK, Name: Laura, Quality: Default [com.apple.ttsbundle.Laura-compact] [AVSpeechSynthesisVoice 0x2825174e0] Language: sk-SK, Name: Laura, Quality: Default [com.apple.ttsbundle.Laura-compact] 44 [AVSpeechSynthesisVoice 0x282517810] Language: sv-SE, Name: Alva, Quality: Default [com.apple.ttsbundle.Alva-compact] [AVSpeechSynthesisVoice 0x282517810] Language: sv-SE, Name: Alva, Quality: Default [com.apple.ttsbundle.Alva-compact] 45 [AVSpeechSynthesisVoice 0x282516820] Language: th-TH, Name: Kanya, Quality: Default [com.apple.ttsbundle.Kanya-compact] [AVSpeechSynthesisVoice 0x282516820] Language: th-TH, Name: Kanya, Quality: Default [com.apple.ttsbundle.Kanya-compact] 46 [AVSpeechSynthesisVoice 0x28252fca0] Language: tr-TR, Name: Yelda, Quality: Default [com.apple.ttsbundle.Yelda-compact] [AVSpeechSynthesisVoice 0x28252fca0] Language: tr-TR, Name: Yelda, Quality: Default [com.apple.ttsbundle.Yelda-compact] 47 [AVSpeechSynthesisVoice 0x282516790] Language: zh-CN, Name: Li-mu, Quality: Default [com.apple.ttsbundle.siri_male_zh-CN_compact] [AVSpeechSynthesisVoice 0x282516790] Language: zh-CN, Name: Li-mu, Quality: Default [com.apple.ttsbundle.siri_male_zh-CN_compact] 48 [AVSpeechSynthesisVoice 0x28256e010] Language: zh-CN, Name: Ting-Ting, Quality: Default [com.apple.ttsbundle.Ting-Ting-compact] [AVSpeechSynthesisVoice 0x28256e010] Language: zh-CN, Name: Ting-Ting, Quality: Default [com.apple.ttsbundle.Ting-Ting-compact] 49 [AVSpeechSynthesisVoice 0x28252fb20] Language: zh-CN, Name: Yu-shu, Quality: Default [com.apple.ttsbundle.siri_female_zh-CN_compact] [AVSpeechSynthesisVoice 0x28252fb20] Language: zh-CN, Name: Yu-shu, Quality: Default [com.apple.ttsbundle.siri_female_zh-CN_compact] 50 [AVSpeechSynthesisVoice 0x28256f880] Language: zh-HK, Name: Sin-Ji, Quality: Default [com.apple.ttsbundle.Sin-Ji-compact] [AVSpeechSynthesisVoice 0x28256f880] Language: zh-HK, Name: Sin-Ji, Quality: Default [com.apple.ttsbundle.Sin-Ji-compact] 51 [AVSpeechSynthesisVoice 0x28256f650] Language: zh-TW, Name: Mei-Jia, Quality: Default [com.apple.ttsbundle.Mei-Jia-compact] [AVSpeechSynthesisVoice 0x28256f650] Language: zh-TW, Name: Mei-Jia, Quality: Default [com.apple.ttsbundle.Mei-Jia-compact]
But not sure it is what you want
-
Right. And if the enhanced Alex voice has been downloaded, you get one more at the end:
[AVAlexSpeechSynthesisVoice 0x28210ce80] Language: en-US, Name: Alex, Quality: Enhanced [com.apple.speech.voice.Alex]
-
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 tospeech.say
, but running directly onobjc_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. -
-
@cvp yes you're right I'm still getting used to the names here on the forum. Definitely a big thank you to @jonb for this work too.
It's still a WIP, and I can't guarantee the interface won't change. Consider it alpha at this point. Segfaults with "logical" operations have been fixed (Do not attempt to access a class from
ObjCInstance
instead ofObjCClass
, because it will segfault; and on that same note, do not attempt to write with theobjc_utils
module when tired), but any testing beyond that has still to be done. Documentation is incomplete too. onlyAVSpeechSynthesisVoice
is pretty complete at this point, but I'm considering a couple method name changes in a more pythonic style. Who knows... Either way have fun in case you want to try it: https://gist.github.com/boisei0/08e6f9f619e8c045ba08dae100e63b17 Dump all those files in a folder namedav_speech
in your site-packages, then import it like the sample above. -
@afelix Thanks for the scripts! It seems however, you made some refactoring before upload.
The name of the fileav_synthesis_voice_quality
should beav_speech_synthesis_voice_quality.py
and ofav_synthesis_voice_gender.py
should beav_speech_synthesis_voice_gender.py
. Forav_speech_synthesizer
the.py
is missing.
For everybody else struggling with the module: it is important to restart Pythonista after upload. -
@edgar you're completely right. I just fixed the gist. The problem wasn't caused by refactoring though, but by being not careful enough when typing the filenames in gist while looking at my phone for how I defined them :P