#!/usr/bin/python2

from __future__ import print_function

import os
import sys
from sys import platform
import audfprint
import tempfile
import subprocess

if platform == "linux" or platform == "linux2":
    FFMPEG_BIN = "ffmpeg"     # on Linux
    FFMPEG_AUDIO_DEVICE = "pulse"
elif platform == "win32":
    FFMPEG_BIN = "ffmpeg.exe" # on Windows
    FFMPEG_AUDIO_DEVICE = "dsound"
elif platform == "darwin":
    FFMPEG_BIN = "ffmpeg"     # on OSX
    FFMPEG_AUDIO_DEVICE = "dsound"

def main(argv):
    database_file_path = argv[1] if len(argv)>1 else os.path.join(os.path.dirname(os.path.abspath(__file__)),'fpdbase.pklz')
    if os.path.isfile(database_file_path) and os.access(database_file_path, os.R_OK):
        with tempfile.NamedTemporaryFile(suffix='.mp3') as recording_file:
            command = [FFMPEG_BIN,
                    '-f', FFMPEG_AUDIO_DEVICE,
                    '-i', 'default',
                    '-y',
                    '-t', '00:30',
                    recording_file.name]
            recording_process = subprocess.Popen(command,
                    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            print('recording, please wait...')
            recording_process.wait()
            audfprint.main(['audfprint.py', 'match',
                '--dbase',
                database_file_path,
                recording_file.name])
            raw_input('Press Enter to exit')
    else:
        print('The database file is missing or is not readable')

if __name__ == "__main__":
    main(sys.argv)

@@ -487,200 +487,22 @@
 def 
-main(argv):%0A    database_file_path = argv%5B1%5D if len(argv)%3E1 else os.path.join(os.path.dirname(os.path.abspath(__file__)),'fpdbase.pklz')%0A    if os.path.isfile(database_file_path) and os.access
+recordAndMatch
 (dat
@@ -520,24 +520,11 @@
 path
-, os.R_OK):%0A    
+):%0A
     
@@ -598,20 +598,16 @@
         
-   
- 
 command 
@@ -621,20 +621,16 @@
 EG_BIN,%0A
-    
         
@@ -680,19 +680,48 @@
         
-   
+'-i', 'pulse',%0A                #
  '-i', '
@@ -746,20 +746,16 @@
         
-    
 '-y',%0A  
@@ -768,20 +768,16 @@
         
-   
- 
 '-t', '0
@@ -783,20 +783,16 @@
 00:30',%0A
-    
         
@@ -820,36 +820,32 @@
 e.name%5D%0A        
- 
-   
 recording_proces
@@ -890,20 +890,16 @@
         
-  
-  
 stdout=s
@@ -942,59 +942,8 @@
 PE)%0A
-            print('recording, please wait...')%0A    
     
@@ -971,20 +971,16 @@
 .wait()%0A
-    
         
@@ -1032,20 +1032,16 @@
         
-   
- 
 '--dbase
@@ -1039,28 +1039,24 @@
  '--dbase',%0A
-    
             
@@ -1079,36 +1079,32 @@
 th,%0A            
-    
 recording_file.n
@@ -1113,51 +1113,320 @@
 e%5D)%0A
-            raw_input('Press Enter to exit'
+%0Adef main(argv):%0A    database_file_path = argv%5B1%5D if len(argv)%3E1 else os.path.join(os.path.dirname(os.path.abspath(__file__)),'fpdbase.pklz')%0A    if os.path.isfile(database_file_path) and os.access(database_file_path, os.R_OK):%0A        print('Recording, please wait...')%0A        recordAndMatch(database_file_path
 )%0A  
@@ -1498,16 +1498,54 @@
 dable')%0A
+    raw_input('Press Enter to exit')%0A%0A
 %0Aif __na

Reorganize the microphone for external reuse