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 Recognition failed

    Pythonista
    6
    69
    17513
    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.
    • cvp
      cvp @Python567 last edited by

      @Python567 3 remarks:

      1. try always to include in your post the error message
      2. never do a while loop without waiting either an input, either a time.sleep(), see other topic
      3. do you initialize your timestamp?
      Python567 1 Reply Last reply Reply Quote 0
      • Python567
        Python567 @cvp last edited by Python567

        @cvp

        1. The error message: Speech Recognition failed: Retry
        2. ok, I include it in my code
        3. yes I do

        Edit: The problem is with this line: result = speech.recognize('speech.m4a', 'de_DE')

        cvp 2 Replies Last reply Reply Quote 0
        • cvp
          cvp @Python567 last edited by

          @Python567 said:

          The error message: Speech Recognition failed: Retry

          Sorry, badly read your first post

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

            @Python567 said:

            ok, I include it in my code

            Same problem after you did it?

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

              @cvp yes, but there is something I don‘t understand: The recorder starts, the recorder stops and print the result, and after the print from the result, there comes the error! I don‘t understand that

              cvp 2 Replies Last reply Reply Quote 0
              • cvp
                cvp @Python567 last edited by cvp

                @Python567 try, I think that the problem occurs when you don't speak

                def s_action(sender):
                    global timestamp
                    recorder = sound.Recorder('speech.m4a')
                    recorder.record()
                    timestamp = time.time()
                    if s.value == True:
                        while True:
                            time.sleep(1)
                            if s.value == False:
                                break
                        
                            elif clock2.uhrgedruckt == True:
                                clock2.uhrgedruckt = False
                                print('ok')
                        
                            elif timestamp - time.time() <= -5:
                                recorder.stop()
                                try:
                                    result = speech.recognize('speech.m4a', 'de_DE')
                                    if result[0][0] == 'Hallo':
                                        print('Du hast hallo gesagt')
                                    else:
                                        print('Fehler')
                                except Exception as e:
                                    print(e)
                                timestamp = time.time()
                                recorder.record()
                        
                    else:
                        pass
                
                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @Python567 last edited by

                  @Python567 and, please, don't forget the time.sleep between two successive tests

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

                    @cvp ok, now my app crashed, but the skript isn‘t long

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

                      @Python567 if not long, post it

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

                        @cvp I think I have the problem why the app crashed. I have while True:

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

                          @Python567 you have to foresee a way to leave (break) this infinite loop.

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

                            @cvp two questions:

                            1. If I open a shortcut on ios with the shortcuts module the app shortcut is open, can I close it from the skript or can I bring Pythonista to the front?
                            2. How can I change the language for this code:
                            t = f"{datetime.datetime.now():%A}"
                            cvp 3 Replies Last reply Reply Quote 0
                            • cvp
                              cvp @Python567 last edited by

                              @Python567 said:

                              If I open a shortcut on ios with the shortcuts module the app shortcut is open, can I close it from the skript or can I bring Pythonista to the front?

                              It depends: how do you open the shortcuts module?
                              Anyway, you can't never close an app from another app

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

                                @cvp I open it with

                                shortcuts.open_shortcuts_app(name='', shortcut_input='')
                                

                                And how can I change the language on the code which I posted before?

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

                                  @Python567 said:

                                  How can I change the language for this code:

                                  Normally, Python allows the locale.setlocale function to do that, but it has never worked in the past.
                                  I know I did it viaObjectiveC but I don't find my script, let me some time, not free this morning.

                                  Of course, if somebody knows a way, don't hesitate to help.

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

                                    @Python567 said:

                                    If I open a shortcut on ios with the shortcuts module the app shortcut is open, can I close it from the skript or can I bring Pythonista to the front?

                                    I think you can ask shortcut to go back to Pythonista...

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

                                      @cvp Yes that‘s a good idea. I found following in the documentation, but I don‘t know how the set it in german

                                      Weekday as locale’s abbreviated name.
                                      Sun, Mon, ..., Sat (en_US);
                                      So, Mo, ..., Sa (de_DE)
                                      (1)
                                      %A Weekday as locale’s full name.
                                      Sunday, Monday, ..., Saturday (en_US);
                                      Sonntag, Montag, ..., Samstag (de_DE)

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

                                        @Python567 the doc = Python doc but locale did never function in Pythonista

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

                                          @cvp it‘s the pythonista doc

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

                                            @Python567 yes but this Pythonista doc, for Python keywords, points to standard doc. And this locale function has never worked.

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