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/Sound Module Q's

    Pythonista
    5
    9
    7173
    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.
    • jpython6
      jpython6 last edited by jpython6

      I'm attempting to convert speech to text using speech's new recognize function, but when I pass a .m4a audio file (recorded using sound.recorder) through the recognize function, it gives a "corrupt" error. Am I using the wrong kind of audio file or something like that?

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

        Can you post the code you've used?

        jpython6 1 Reply Last reply Reply Quote 0
        • jpython6
          jpython6 @omz last edited by jpython6

          @omz

          import speech, sound, time

          sound.Recorder("audio").record()
          time.sleep(3)
          sound.Recorder("audio").stop()
          text = speech.recognize("audio.m4a")

          I'm also unable to play back the audio using sound.Player, so it's probably me doing something wrong.

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

            The problem is that you're creating two separate Recorder objects instead of stopping the one you've created for recording.

            This should work better:

            import speech, sound, time
            rec = sound.Recorder("audio.m4a")
            rec.record()
            time.sleep(3)
            rec.stop()
            result = speech.recognize("audio.m4a")
            print(result)
            
            jpython6 1 Reply Last reply Reply Quote 0
            • jpython6
              jpython6 @omz last edited by

              @omz this works! Thank you so much!

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

                Hi - I'm wondering how you knew about sound.Recorder. I'm looking at the documentation at

                http://omz-software.com/pythonista/docs/ios/sound.html

                which doesn't mention it at all. (I also noticed that sound.play_effect accepts two additional undocumented arguments. I haven't figured out what the fourth does; the fifth appears to cause the sound to loop until stopped if it's anything other than 0.)

                Is there additional documentation or a forum post describing sound.Recorder that I'm missing?

                Thanks!

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

                  @oakandsage The documentation on the website is a bit outdated I think. You should look at the offline documentation inside the app, that one is usually up-to-date.

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

                    Oh! Thank you -- I had assumed the in app documentation was accessing either the website or a cached copy of it! But I see now it is more complete.

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

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors