import socket import re host = "localhost" port = 10500 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) print "Connection to Julius succeeded" # clear the log file handle = open("julius_out.txt", "w") handle.close() word = {} angle = {} parsed = [] currentID = None line = "" while True: # build a valid line tmpline = sock.recv(1024).replace(".\n", "").rstrip() line += tmpline if not tmpline[-1] == ">": continue # parse it. res = re.search( '