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.
How to use speech.say() in different voice?
-
If you check the setting in iOS you will find that voice can be spoken in different people:
For example:en-US
: the default is Samantha(female), there is Fred(male), and you also can download Allison, Ava, Nick... as well as Siri
How can we use them inspeech.say()
?The propose is because that the quality of default voice of
zh-cn
is terrible which is read by Tian-Tian, but I check others like Ting-Ting or female Siri, the quality is much better.Does anyone know how to change the setting?
Many thanks
-
-
Awesome!!!!!!!! ~~~~ Thanks a lot!!!
-
@uncompleted Awesome = @JonB 😀 I only did a Google search "Pythonista speech voice"
-
Remark that speech.get_languages() gives 53 elements like AVSpeechSynthesisVoice.speechVoices() but speech module does not allow, I think, to select particular voice for the same language...
-
@omz the script here-after shows that the speech module 'knows' all the 53 languages offered by the Apple module, it could be possible to get a wanted voice by passing to the say function the language and, for instance, the voice name, isn'it?
import speech from objc_util import * AVSpeechSynthesisVoice=ObjCClass('AVSpeechSynthesisVoice') l1 = speech.get_synthesis_languages() l2 = AVSpeechSynthesisVoice.speechVoices() for i in range(0,len(l1)): l = str(l2[i].description()) j = l.find('Language: ') k = l.find(', Quality:') # [AVSpeechSynthesisVoice 0x1c0a15f40] Language: ar-SA, Name: Maged, Quality: Default [com.apple.ttsbundle.Maged-compact] print('speech:',l1[i],'Objective-c:',l[j+10:k])```
-
I can get it to change languages, and apparently Klingon is an option in pythonista. Not sure what it accomplishes, but it is fun. By default it will use the language set on the phone but you can lookup other BCP 47 language identifier. They usually look like "en-US" for American English or "de" for German.
def count_down(): num = input("Number to countdown from: ") for i in range(int(num), -1, -1): speech.say(str(i), "i-klingon") print(i) time.sleep(1.0) speech.say("SoHDaq destruct ghuS", "i-klingon") if __name__ == "__main__": count_down()