omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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?

    Pythonista
    3
    7
    7266
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • uncompleted
      uncompleted last edited by

      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 in speech.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

      1 Reply Last reply Reply Quote 0
      • cvp
        cvp last edited by

        see topic

        and @JonB example

        I just tested it and it's ok but I changed a little bit to find the wanted voice

        voices=AVSpeechSynthesisVoice.speechVoices()
        for i in range(0,len(voices)):
        	print(i,voices[i])
        ...
        #voice=AVSpeechSynthesisVoice.voiceWithLanguage_('fr-FR')
        voice = voices[25]
        
        1 Reply Last reply Reply Quote 0
        • uncompleted
          uncompleted last edited by

          Awesome!!!!!!!! ~~~~ Thanks a lot!!!

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @uncompleted last edited by

            @uncompleted Awesome = @JonB 😀 I only did a Google search "Pythonista speech voice"

            1 Reply Last reply Reply Quote 1
            • cvp
              cvp last edited by cvp

              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...

              1 Reply Last reply Reply Quote 0
              • cvp
                cvp last edited by

                @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])```
                1 Reply Last reply Reply Quote 0
                • Darth Friese
                  Darth Friese last edited by ccc

                  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()
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors