Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env ruby
- # -*- coding: utf-8 -*-
- require "socket"
- s = nil
- until s
- begin
- s = TCPSocket.open("localhost", 10500)
- rescue
- STDERR.puts "Julius に接続失敗しました\n再接続を試みます"
- sleep 10
- retry
- end
- end
- puts "Julius に接続しました"
- source = ""
- while true
- ret = IO::select([s])
- begin
- # !!! ここでpythonプログラム叩く !!!
- puts system('pwd')
- puts "プログラムを実行しました"
- # !!! ここでpythonプログラム叩く !!!
- ret[0].each do |sock|
- source += sock.recv(65535)
- if source[-2..source.size] == ".\n"
- #puts source
- source.gsub!(/\.\n/, "")
- words = (xml/"RECOGOUT"/"SHYPO"/"WHYPO").inject("") {|ws, w| ws + w["WORD"] }
- unless words == ""
- #puts "INPUT: #{words}"
- end
- source = ""
- end
- end
- rescue StandardError => e
- puts "Error!!!!"
- STDERR.puts e.backtrace.join("\n")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement