Blender Jarvis style!!

I thought how can I use my mic in the search bar (space bar). I wanted to create a addons but they are stuck with the code.
This is what I’ve created so far.
this is my forum of reference.
http://www.blender.it/ipb_forum/index.php?/topic/27326-fare-parlare-blender/
In this script python there is a problem. I whant receive of microphone my voice and execute my word in action!
In style of Jarvis ( film of Iron Man) .
I whant implement this code inside blender but there is a problem of microphone!
i can’t use my microphone for use this functions.
import pyaudio
import wave

CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = “output.wav”

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)

print("* recording")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, ‘wb’)
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b’’.join(frames))
wf.close()
pyaudio is not inside blender but is available for any s.o. Windows Macosx Linux.
This code read of microphone. I try this code outside blender.
I try inside the blender but there is a code incomplete.
i try implement Google Search inside blender for speech vocal. This is my code.
#!/usr/bin/python
‘’’
Questo programma usa wm.search_menu

‘’’
import os
import bpy
‘’’
questi moduli qui sotto puoi scaricarli per vostro O.S. presso:
these module you can download for your OS at:
https://pypi.python.org/pypi/PyAudio
‘’’
import pyaudio
import wave

bl_info = {
“name”: “Menu Voice”,
“description”: 'Registra la tua voce e la trasmette su google e ti esegue un operazione ',
“author”: “Lo Bello Paolo”,
“version”: (0, 1, 0),
“blender”: (2, 70, 0),
“location”: “View3D > Header > Search_menu”,
“warning”: “”, # used for warning icon and text in addons panel
“wiki_url”: “”,
“tracker_url”: “”,
“category”: “3D View”}

class MenuVoice(bpy.types.Menu):
bl_label = “Menu Voice”
bl_idname = “Menu spazio con la Voice!”

def parla(frase):
   frase1="say "
   a=frase1+frase
   os.system(" "+ a)
    
def registra():
''' this function is take by 
    http://people.csail.mit.edu/hubert/pyaudio/#docs
    module pyaudio docs
'''
   CHUNK = 1024
   FORMAT = pyaudio.paInt16
   CHANNELS = 2
   RATE = 44100
   RECORD_SECONDS = 5
   WAVE_OUTPUT_FILENAME = "output.wav"
   p = pyaudio.PyAudio()
   stream = p.open(format=FORMAT,
            channels=CHANNELS,
            rate=RATE,
            input=True,
            frames_per_buffer=CHUNK)
   print("* recording")
   frames = []
   for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
       data = stream.read(CHUNK)
       frames.append(data)
   print("* done recording")
   stream.stop_stream()
   stream.close()
   p.terminate()
   wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
   wf.setnchannels(CHANNELS)
   wf.setsampwidth(p.get_sample_size(FORMAT))
   wf.setframerate(RATE)
   wf.writeframes(b''.join(frames))
   wf.close()

def draw(self, context):
    '''
    Questa funzione è usata in blender per creare la gui.
    '''
    layout = self.layout
    layout.label(text="Record your voice!", icon='REC')
    layout.label(text="Registra la tua voce!", icon='REC')
    #layout.buttom(text="Rec",)
    layout.operator("wm.open_mainfile")
    layout.separator()
    row = layout.row(align=True)
    layout.menu("TIME_MT_playback")

#cancellare il commento qui sotto per farlo parlare
#parla("Benvenuto mi chiamo Blenderr! Dimmi cosa vuoi fare?")
# import speech

def SEND_AUDIO_Google(self,url):
    url.self="www.google.it"
    import urllib2
    url = "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US"
    audio = open('rainspain.flac','rb').read()
    headers={'Content-Type': 'audio/x-flac; rate=16000', 'User-Agent':'Mozilla/5.0'}
    request = urllib2.Request(url, data=audio, headers=headers)
    response = urllib2.urlopen(request)
    print response.read()

def register():
bpy.utils.register_class(MenuVoice)

def unregister():
bpy.utils.unregister_class(MenuVoice)

if name == “main”:
register()
bpy.ops.wm.call_menu(name=MenuVoice.bl_idname)
I hope like this idea.

use code tags
[ CODE]

 (without the space between [ and C)
or your code is unusable