Exemple #1
0
def online_decoding_single_verbose(lan='ENGLISH'):

    lattice  = None

    arkf = request.files['ark']
    scpf = request.files['scp']
    wavef = request.files['wave']

    arkfm = FileManager(arkf)
    scpfm = FileManager(scpf)
    wavefm = FileManager(wavef)

    ext = ', '.join(FileManager.ALLOWED_EXTENSIONS)
    fileNames = ', '.join([arkf.filename, scpf.filename, wavef.filename])

    arkfm.save_tmp_file()
    scpfm.save_tmp_file()
    wavefm.save_tmp_tarfile()

    print '\ndecoding in progress\n'

    if not arkfm.isValid or not scpfm.isValid or not wavefm.isValid:
        return ( 'Invalid file extension error. \n' \
        + 'Only the following extensions are valid: [ {0} ] \n' \
        + 'File names = [ {1} ] \n' \
        + 'language = [ {2} ]' ).format(ext, fileNames, lan)

    '''Here we youd recive a file that will be sent back to the user'''
    lattice = onlineDecoding(arkfm, scpfm, wavefm, lan)

    print lattice

    return getFile(lattice)
Exemple #2
0
def online_decoding_single(lan='ENGLISH'):
    
    lattice  = None    

    # get File from the request list
    wavef = request.files['wave']
    wavefm = FileManager(wavef)

    ext = ', '.join(FileManager.ALLOWED_EXTENSIONS)
    fileNames = wavef.filename

    #save file in local app/tmp directory
    wavefm.save_tmp_tarfile()

    print '\ndecoding in progress\n'

    if not wavefm.isValid:
        return ( 'Invalid file extension error. \n' \
        + 'Only the following extensions are valid: [ {0} ] \n' \
        + 'File names = [ {1} ] \n' \
        + 'language = [ {2} ]' ).format(ext, fileNames, lan)

    '''Here we youd recive a file that will be sent back to the user'''
    lattice = onlineDecoding( [wavefm] , lan )

    print 'File ready at dir: ' + lattice + '\n'
    
    

    return  getFile(lattice)
Exemple #3
0
def online_decode_bulk(lan='ENGLISH'):
    
    wavef = request.files['wave']
    wavefm = FileManager(wavef)
   
    ext = ', '.join(FileManager.ALLOWED_EXTENSIONS)
    fileNames = ', '.join([wavef.filename])

    '''Save tar file and uncompress=True'''
    files =  wavefm.save_tmp_tarfile(True)

    print '\ndecoding in progress\n'

    if not wavefm.isValid:
        return ( 'Invalid file extension error. \n' \
        + 'Only the following extensions are valid: [ {0} ] \n' \
        + 'File names = [ {1} ] \n' \
        + 'language = [ {2} ]' ).format(ext, fileNames, lan)      
        
    '''Here we youd recive a file that will be sent back to the user'''    
    tarfile = onlineDecoding( files, lan)    
       
    return getFile(tarfile)