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.


    Speech to ear speaker?

    Pythonista
    2
    4
    3117
    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.
    • dwildbore
      dwildbore last edited by

      Is there away to use the text to speak so that it outputs to the ear speaker and not the speaker phone?

      Phuket2 1 Reply Last reply Reply Quote 0
      • Phuket2
        Phuket2 @dwildbore last edited by

        @dwildbore , hi I used the example below from the Pythonista docs. I am using apple Airpods on iPad 12.5' 2nd gen. The sound worked fine for me. When the AirPods in, the speech came though them and after removal the sound come out of the speaker. I didn't have a wired pair of earphones handy to see if it worked differently or not.

        import speech
        import time
        
        def finish_speaking():
            # Block until speech synthesis has finished
            while speech.is_speaking():
                time.sleep(0.1)
        
        # US English:
        speech.say('Hello World', 'en_US')
        finish_speaking()
        # Spanish:
        speech.say('Hola mundo', 'es_ES')
        finish_speaking()
        # German:
        speech.say('Hallo Welt', 'de_DE')
        finish_speaking()
        
        1 Reply Last reply Reply Quote 0
        • dwildbore
          dwildbore last edited by

          I should have clarified. I mean like the speaker used during a phone call that you hold up to your ear. Good to know the ear pods work tho, i'm hoping to get a pair! thanks!

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

            In case anyone is wondering I got it working:

            from objc_util import *
            import speech
            import time

            AVAudioSession = ObjCClass('AVAudioSession')
            audioSession = AVAudioSession.sharedInstance()

            oldCategory = audioSession.category()

            audioSession.setCategory_error_(ns('AVAudioSessionCategoryPlayAndRecord'), None)

            speech.say('hello') #like a phone call

            time.sleep(1)
            audioSession.setCategory_error_(ns(oldCategory), None)

            speech.say('hello again') # speaker phone

            1 Reply Last reply Reply Quote 3
            • First post
              Last post
            Powered by NodeBB Forums | Contributors