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.


    record sound but cant replay it in speaker

    Pythonista
    3
    3
    1859
    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.
    • easy_fly
      easy_fly last edited by easy_fly

      import sound
      import dialogs
      
      recorder = sound.Recorder('speech.m4a')
      #recorder.record()
      
      dialogs.alert('Recording...', '',   'Finish', hide_cancel_button=True)
      
      #recorder.stop()
      
      p=sound.Player('speech.m4a')
      p.play()
      
      
      

      When I comment that record code, the sound came out from the speaker.

      but when i use the record code,the player sound come from the headphone.

      how can i record sound and replay it in speaker at once?

      thx

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

        I had same problem with you.

        i think there’s a bug about mute switch when recording.

        anyway if you do like this, you can play sound in speaker again.

        sound.set_honors_silent_switch(False)

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

          I think OMZ should add a method to sound module to control the audio routing. For now you can use objective-c calls after recording / before playing:

          import objc_util
          
          au = objc_util.ObjCClass("AVAudioSession").sharedInstance()
          
          # force playback on speaker
          au.setCategory_withOptions_error_("AVAudioSessionCategoryPlayback",1,None)
          
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors