prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Too many false positives when detecting wake word
  
  
  </issue>
  <code>
  [start of mycroft/client/speech/local_recognizer.py]
  1 # Copyright 2016 Mycroft AI, Inc.
  2 #
  3 # This file is part of Mycroft Core.
  4 #
  5 # Mycroft Core is free software: you can redistribute it and/or modify
  6 # it under the terms of the GNU General Public License as published by
  7 # the Free Software Foundation, either version 3 of the License, or
  8 # (at your option) any later version.
  9 #
  10 # Mycroft Core is distributed in the hope that it will be useful,
  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 # GNU General Public License for more details.
  14 #
  15 # You should have received a copy of the GNU General Public License
  16 # along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.
  17 
  18 
  19 import time
  20 
  21 import os
  22 from pocketsphinx.pocketsphinx import Decoder
  23 
  24 __author__ = 'seanfitz, jdorleans'
  25 
  26 BASEDIR = os.path.dirname(os.path.abspath(__file__))
  27 
  28 
  29 class LocalRecognizer(object):
  30     def __init__(self, sample_rate=16000, lang="en-us", key_phrase="mycroft"):
  31         self.lang = lang
  32         self.key_phrase = key_phrase
  33         self.sample_rate = sample_rate
  34         self.configure()
  35 
  36     def configure(self):
  37         config = Decoder.default_config()
  38         config.set_string('-hmm', os.path.join(BASEDIR, 'model', self.lang,
  39                                                'hmm'))
  40         config.set_string('-dict', os.path.join(BASEDIR, 'model', self.lang,
  41                                                 'mycroft-en-us.dict'))
  42         config.set_string('-keyphrase', self.key_phrase)
  43         config.set_float('-kws_threshold', float('1e-45'))
  44         config.set_float('-samprate', self.sample_rate)
  45         config.set_int('-nfft', 2048)
  46         config.set_string('-logfn', '/dev/null')
  47         self.decoder = Decoder(config)
  48 
  49     def transcribe(self, byte_data, metrics=None):
  50         start = time.time()
  51         self.decoder.start_utt()
  52         self.decoder.process_raw(byte_data, False, False)
  53         self.decoder.end_utt()
  54         if metrics:
  55             metrics.timer("mycroft.stt.local.time_s", time.time() - start)
  56         return self.decoder.hyp()
  57 
  58     def is_recognized(self, byte_data, metrics):
  59         hyp = self.transcribe(byte_data, metrics)
  60         return hyp and self.key_phrase in hyp.hypstr.lower()
  61 
  62     def found_wake_word(self, hypothesis):
  63         return hypothesis and self.key_phrase in hypothesis.hypstr.lower()
  64
  [end of mycroft/client/speech/local_recognizer.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mycroft/client/speech/local_recognizer.py b/mycroft/client/speech/local_recognizer.py
  --- a/mycroft/client/speech/local_recognizer.py
  +++ b/mycroft/client/speech/local_recognizer.py
  @@ -27,7 +27,8 @@
   
   
   class LocalRecognizer(object):
  -    def __init__(self, sample_rate=16000, lang="en-us", key_phrase="mycroft"):
  +    def __init__(self, sample_rate=16000, lang="en-us",
  +                 key_phrase="hey mycroft"):
           self.lang = lang
           self.key_phrase = key_phrase
           self.sample_rate = sample_rate
  @@ -40,7 +41,7 @@
           config.set_string('-dict', os.path.join(BASEDIR, 'model', self.lang,
                                                   'mycroft-en-us.dict'))
           config.set_string('-keyphrase', self.key_phrase)
  -        config.set_float('-kws_threshold', float('1e-45'))
  +        config.set_float('-kws_threshold', float('1e-90'))
           config.set_float('-samprate', self.sample_rate)
           config.set_int('-nfft', 2048)
           config.set_string('-logfn', '/dev/null')
  
verification_info: {"golden_diff": "diff --git a/mycroft/client/speech/local_recognizer.py b/mycroft/client/speech/local_recognizer.py\n--- a/mycroft/client/speech/local_recognizer.py\n+++ b/mycroft/client/speech/local_recognizer.py\n@@ -27,7 +27,8 @@\n \n \n class LocalRecognizer(object):\n-    def __init__(self, sample_rate=16000, lang=\"en-us\", key_phrase=\"mycroft\"):\n+    def __init__(self, sample_rate=16000, lang=\"en-us\",\n+                 key_phrase=\"hey mycroft\"):\n         self.lang = lang\n         self.key_phrase = key_phrase\n         self.sample_rate = sample_rate\n@@ -40,7 +41,7 @@\n         config.set_string('-dict', os.path.join(BASEDIR, 'model', self.lang,\n                                                 'mycroft-en-us.dict'))\n         config.set_string('-keyphrase', self.key_phrase)\n-        config.set_float('-kws_threshold', float('1e-45'))\n+        config.set_float('-kws_threshold', float('1e-90'))\n         config.set_float('-samprate', self.sample_rate)\n         config.set_int('-nfft', 2048)\n         config.set_string('-logfn', '/dev/null')\n", "issue": "Too many false positives when detecting wake word\n\n", "before_files": [{"content": "# Copyright 2016 Mycroft AI, Inc.\n#\n# This file is part of Mycroft Core.\n#\n# Mycroft Core is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Mycroft Core is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.\n\n\nimport time\n\nimport os\nfrom pocketsphinx.pocketsphinx import Decoder\n\n__author__ = 'seanfitz, jdorleans'\n\nBASEDIR = os.path.dirname(os.path.abspath(__file__))\n\n\nclass LocalRecognizer(object):\n    def __init__(self, sample_rate=16000, lang=\"en-us\", key_phrase=\"mycroft\"):\n        self.lang = lang\n        self.key_phrase = key_phrase\n        self.sample_rate = sample_rate\n        self.configure()\n\n    def configure(self):\n        config = Decoder.default_config()\n        config.set_string('-hmm', os.path.join(BASEDIR, 'model', self.lang,\n                                               'hmm'))\n        config.set_string('-dict', os.path.join(BASEDIR, 'model', self.lang,\n                                                'mycroft-en-us.dict'))\n        config.set_string('-keyphrase', self.key_phrase)\n        config.set_float('-kws_threshold', float('1e-45'))\n        config.set_float('-samprate', self.sample_rate)\n        config.set_int('-nfft', 2048)\n        config.set_string('-logfn', '/dev/null')\n        self.decoder = Decoder(config)\n\n    def transcribe(self, byte_data, metrics=None):\n        start = time.time()\n        self.decoder.start_utt()\n        self.decoder.process_raw(byte_data, False, False)\n        self.decoder.end_utt()\n        if metrics:\n            metrics.timer(\"mycroft.stt.local.time_s\", time.time() - start)\n        return self.decoder.hyp()\n\n    def is_recognized(self, byte_data, metrics):\n        hyp = self.transcribe(byte_data, metrics)\n        return hyp and self.key_phrase in hyp.hypstr.lower()\n\n    def found_wake_word(self, hypothesis):\n        return hypothesis and self.key_phrase in hypothesis.hypstr.lower()\n", "path": "mycroft/client/speech/local_recognizer.py"}]}