{"action":"created","issue":{"url":"https://api.github.com/repos/Uberi/speech_recognition/issues/181","repository_url":"https://api.github.com/repos/Uberi/speech_recognition","labels_url":"https://api.github.com/repos/Uberi/speech_recognition/issues/181/labels{/name}","comments_url":"https://api.github.com/repos/Uberi/speech_recognition/issues/181/comments","events_url":"https://api.github.com/repos/Uberi/speech_recognition/issues/181/events","html_url":"https://github.com/Uberi/speech_recognition/issues/181","id":194234965,"number":181,"title":"Inconsistent voice activity detection","user":{"login":"chrisspen","id":116631,"avatar_url":"https://avatars.githubusercontent.com/u/116631?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisspen","html_url":"https://github.com/chrisspen","followers_url":"https://api.github.com/users/chrisspen/followers","following_url":"https://api.github.com/users/chrisspen/following{/other_user}","gists_url":"https://api.github.com/users/chrisspen/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisspen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisspen/subscriptions","organizations_url":"https://api.github.com/users/chrisspen/orgs","repos_url":"https://api.github.com/users/chrisspen/repos","events_url":"https://api.github.com/users/chrisspen/events{/privacy}","received_events_url":"https://api.github.com/users/chrisspen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-08T03:00:04Z","updated_at":"2016-12-11T16:20:52Z","closed_at":"2016-12-11T16:20:52Z","body":"Is there any built-in voice activity detection, or are you relying on the backend for that? It seems to be inconsistent or non-existent, and this makes the microphone examples very difficult to use. Testing with the Google Speech backend, after a few seconds of speech, minutes could go by with nothing happening, leaving me to wonder is my mic not working? Or did the package not detect speech and begin recording? Or is it still recording but hasn't detected the end of the speech? Or did it send everything up to Google and it's just taking a while? Is there any way to get debugging output so we know which stage it's at?"},"comment":{"url":"https://api.github.com/repos/Uberi/speech_recognition/issues/comments/266291104","html_url":"https://github.com/Uberi/speech_recognition/issues/181#issuecomment-266291104","issue_url":"https://api.github.com/repos/Uberi/speech_recognition/issues/181","id":266291104,"user":{"login":"chrisspen","id":116631,"avatar_url":"https://avatars.githubusercontent.com/u/116631?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisspen","html_url":"https://github.com/chrisspen","followers_url":"https://api.github.com/users/chrisspen/followers","following_url":"https://api.github.com/users/chrisspen/following{/other_user}","gists_url":"https://api.github.com/users/chrisspen/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisspen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisspen/subscriptions","organizations_url":"https://api.github.com/users/chrisspen/orgs","repos_url":"https://api.github.com/users/chrisspen/repos","events_url":"https://api.github.com/users/chrisspen/events{/privacy}","received_events_url":"https://api.github.com/users/chrisspen/received_events","type":"User","site_admin":false},"created_at":"2016-12-11T16:20:52Z","updated_at":"2016-12-11T16:20:52Z","body":"I seem to have gotten it to work more reliably. I think the problem was with my laptop microphone's amplification. It was set to 100%, which picks up a ton of noise. The \"sound energy\" indicator was registering around 20 bars even when I wasn't speaking. I reduced the amplification to around 20-30%, so when I wasn't speaking, only 1-2 bars where registering, and when I was speaking, around 10-15 bars registered.\r\n\r\nWith that, this script worked for me:\r\n\r\n    import sys\r\n    import time\r\n    import speech_recognition as sr\r\n\r\n    # You may need to change this to suit your hardware. None will work, but may give you ALSA warnings.\r\n    mic_index = 4\r\n\r\n    r = sr.Recognizer()\r\n    m = sr.Microphone(device_index=mic_index)\r\n\r\n    try:\r\n        with m as source:\r\n            r.adjust_for_ambient_noise(source)\r\n        print(\"Set minimum energy threshold to {}\".format(r.energy_threshold))\r\n    except IOError as e:\r\n        print e\r\n        print 'Try different microphone device index:', sr.Microphone.list_microphone_names()\r\n        sys.exit(1)\r\n\r\n    do_prompt = True\r\n    while 1:\r\n        \r\n        try:\r\n            \r\n            if do_prompt:\r\n                print(\"Listening!\")\r\n                do_prompt = False\r\n            \r\n            with sr.Microphone(device_index=mic_index) as source:\r\n                audio = r.listen(source, timeout=0.1)\r\n                do_prompt = True\r\n            \r\n            t0 = time.time()\r\n            print 'Recognizing...'\r\n            text = r.recognize_google(audio)\r\n            td = time.time() - t0\r\n            print 'Response seconds:', td\r\n            \r\n            print(text)\r\n        except sr.UnknownValueError:\r\n            # We heard you, but Google couldn't figure out what you said.\r\n            pass\r\n        except sr.WaitTimeoutError:\r\n            pass\r\n"}}
{"actor":{"display_login":"chrisspen"}}