title: JARVIS type program that will not accept dicated text from speech recognition software
body: <p>A while back I wrote a program a bit like (movie) Iron Man's JARVIS that takes commands like "open a program" or "read text" and then does the appropriate actions. I've written it so that commands can be entered either via keyboard or speech recognition. The problem I'm having is that the program will not accept my dictated commands. If I type "Read text" it will follow the command. If I use speech recognition to enter "Read text" it calls "I DON'T UNDERSTAND". Keep in mind that the exact same text is being entered. Any help with this confounding issue is welcome and appreciated. Also, please forgive my old, messy code. </p>
  
  <p>Here's code for the beginning up until the command portion:</p>
  
  <pre><code>import random
  import time
  from win32com.client import constants
  import win32com.client
  import pythoncom
  import webbrowser
  import os
  import sys
  from sys import exit
  
  speaker = win32com.client.Dispatch("SAPI.SpVoice")
  POSITIVE_RESPONSES = ('good', 'great', 'fantastic', 'decent', 'fine', 'ok', 'okay')
  NEGATIVE_RESPONSES = ('bad', 'terrible', 'sad', 'grumpy', 'angry', 'irritated', 'tired')
  CONFIRMATION = ('yes', 'yeah', 'yep', 'yesh', 'sure', 'yeppers', 'yup')
  DECLINATION = ('no', 'nope', 'too bad', 'nothing')
  QUESTIONS = ('what', 'largest', 'ocean')
  BROWSER = ('browser')
  PROGRAM = ('program')
  URL = ('url')
  list1 = ['ccleaner', 'c++','minecraft','VLC', 'steam', 'guitar pro', 'dropbox', 'cbr reader', 'avast', 'paint.net' ]
  list2 = ['Read text', 'Open a program', 'Open a browser', 'Open a URL', 'Converse']
  NUM_SET_ONE = (1, 2, 3, 4, 5)
  NUM_SET_TWO = (6, 7, 8, 9, 10)
  NUM_SET_THREE = (11, 12, 13, 14, 15)
  NUM_SET_FOUR = (16, 17, 18, 19, 20)
  NUM_SET_FIVE = (21, 22, 23, 24, 25)
  NUM_SET_SIX = (26, 27, 28, 29, 30)
  
  def opening():
      speaker.Speak('HELLO USER. WELCOME TO D UNDER MIFF LIN. I AM COMP YOO TRON, YOUR ANSWER TO EVERYTHING.')
      print('HELLO, USER. WELCOME TO DUNDER MIFFLIN. I AM COMPUTRON, YOUR ANSWER TO EVERYTHING.')
  
  def reOpening():
      speaker.Speak('GOOD! THEN RE-START THE COVERSATION.')
      varResponse = str(input('GOOD! THEN RE-START THE COVERSATION.'))
      if varResponse in CONFIRMATION: ambiguousResponses()
      elif varResponse in DECLINATION: finalResponses()
      else: ambiguousResponses()
  
  def browser():
      speaker.Speak('OPENING FIREFOX...')
      print('OPENING FIREFOX...')
      handle = webbrowser.get()
      handle.open('http://youtube.com')
      askAgain()
  
  def url():
      speaker.Speak('ENTER YOUR U R L:')
      response = str(input('ENTER YOUR URL:'))
      handle = webbrowser.get()
      handle.open(response)
      askAgain()
  
  def programs():
      speaker.Speak('ENTER THE PROGRAM\'S NAME:')
      response = str(input('ENTER THE PROGRAM\'S NAME:'))
      if response == list1[0]:
          speaker.Speak('OPENING C CLEANER...')
          print('OPENING CCLEANER...')
          os.startfile("C:\Program Files\CCleaner\CCleaner64.exe")
          askAgain()
      elif response == list1[1]:
          speaker.Speak('OPENING C PLUS PLUS...')
          print('OPENING C++...')
          os.startfile("C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe")
          askAgain()
      elif response == list1[2]:
          #speaker.Speak('OPENING WHY GEE OH PRO...')
          print('OPENING YGOPRO...')
          #os.startfile("C:\Users\Rj\Desktop\ygopro-1.030.0-V4-Percy-full")
          #askAgain()
  
      elif response == list1[3]:
          speaker.Speak('OPENING VLC...')
          print('OPENING VLC...')
          os.startfile('C:\Program Files (x86)\VideoLAN\VLC\vlc.exe')
          askAgain()
      elif response == list1[4]:
          speaker.Speak('OPENING STEAM...')
          print('OPENING STEAM...')
          os.startfile('C:\Program Files (x86)\Steam\Steam.exe')
          askAgain()
      elif response == list1[5]:
          speaker.Speak('OPENING GUITAR PRO...')
          print('OPENING GUITAR PRO...')
          os.startfile('C:\Program Files (x86)\Guitar Pro 6\GuitarPro.exe')
          askAgain()
      elif response == list1[6]:
          speaker.Speak('OPENING DROP BOX...')
          print('OPENING DROP BOX...')
          # os.startfile()
          askAgain()
      elif response == list1[7]:
          speaker.Speak('OPENING CBR READER...')
          print('OPENING CBR READER...')
          os.startfile('C:\Program Files (x86)\CBR Reader\CBRReader.exe')
          askAgain()
      elif response == list1[8]:
          speaker.Speak('OPENING AVAST...')
          print('OPENING AVAST...')
          os.startfile('C:\Program Files\AVAST Software\Avast\AvastUI.exe')
          askAgain()
      elif response == list1[9]:
          speaker.Speak('OPENING PAINT.NET...')
          print('OPENING PAINT.NET...')
          # os.startfile()
          askAgain()
      else:
          speaker.Speak('I DON\'T UNDERSTAND')
          print('I DONT\'T UNDERSTAND')
          askAgain()
  
  def askForQuestions():
      speaker.Speak('WHAT WOULD YOU LIKE ME TO DO? ENTER A COMMAND.')
      print('WHAT WOULD YOU LIKE ME TO DO? ENTER A COMMAND.')
      varResponse = str(input())
      if varResponse == list2[0]:
          readText()
      elif varResponse ==  list2[1]:
          programs()
      elif varResponse == list2[2]:
          browser()
      elif varResponse == list2[3]:
          url()
      elif varResponse == list2[4]:
          responseType()
      elif varResponse not in list2:
          misunderstanding()
  
  def readText():
          print('ENTER YOUR TEXT: ')
          text = input()
          speaker.Speak(text)
          response = str(input('WOULD YOU LIKE TO ENTER MORE TEXT?'))
          if response == 'yes':
              readText()
          elif response == 'no':
              askAgain()
          else:
              print('I DON\'T UNDERSTAND, TRY AGAIN')
              readText()
  </code></pre>
  
  <p>Second test with smaller program:</p>
  
  <pre><code>import random
  import time
  from win32com.client import constants
  import win32com.client
  import pythoncom
  import webbrowser
  import os
  import sys
  from sys import exit
  
  speaker = win32com.client.Dispatch("SAPI.SpVoice")
  
  var1 = "Read text"
  var2 = str(input("say something."))
  if var2 == var1:
      print("Sucess!")
  else:
      print("FAIL!!!")
  </code></pre>
  
  <p>Result with dictation: </p>
  
  <pre><code>&gt;&gt;&gt; 
  say something.Read text 
  FAIL!!!
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Result with keyboard:</p>
  
  <pre><code>&gt;&gt;&gt; 
  say something.Read text
  Sucess!
  &gt;&gt;&gt; 
  </code></pre>