'siri proxy'에 해당되는 글 1건

  1. 2013.02.19 라즈베리 파이에서 Siri 프록시 서버 구동하기 (2)

Siri Proxy 라즈베리 파이에서 구동하기


아이폰에서 동작하는 시리를 시리 프록시 서버를 사용하면 (하드웨어 삽질이 더 필요하지만) 차고의 문을 열거나, 집안의 온도를 바꾸는 등으로 다양하게 활용할 수 있다. 


설치 방법은 아주 간단하다. 리눅스가 익숙하지 않으면 아주 어려울 수도 있다. :-) 

아래 명령어는 라즈베리파이에서 실행을 하고, Ubunto 에서도 똑같이 실행할 수 있다. 어차피 고놈이 고놈이라. 


모든 것은 라즈베리 파이 또는 Ubunto 리눅스가 있다는 가정하에 시작된다. 설치 시간은 약 1시간 정도가 소요된다. 


1. 필요한 모듈들 설치하기

sudo apt-get install dnsmasq ruby build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

'y'를 눌러서 계속 진행하기.


2. dnsmasq 설정 파일 변경하기

sudo vim /etc/dnsmasq.conf

약 60-70라인 부근에서 #address=/double-click.net/127.0.0.1 을 찾는다. 그리고 다음 텍스트를 타이핑한다. 

address=/guzzoni.apple.com/(라즈베리 파이 IP)

(라즈베리 파이 IP)를 라즈베리 파이의 IP로 변경한다. 


3. dnsmasq 재시작하기 

sudo /etc/init.d/dnsmasq restart


4. rvm-installer 실행하기

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)


5. rvm 관련 설정하기

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"


6. .bash_profile에 rvm 관련 추가하기

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile


7. rvm 1.9.3 설치하기 (라즈베리파이에서는 약 30분 걸림)

rvm install 1.9.3

이 커멘드는 실행하는데 오랜시간이 걸린다. 특히 컴파일 부분이라 시간이 더 걸리니 참고 기다리자.


8. 1.9.3을 기본적으로 사용한다.

rvm use 1.9.3 --default


9. github에서 SiriProxy 내려받기

git clone git://github.com/plamoni/SiriProxy.git


10. SiriProxy 디렉토리로 이동하기

cd SiriProxy


11. 홈디렉토리에 .siriproxy 디렉토리 만들기

mkdir ~/.siriproxy


12. 예제 config 값을 siriproxy로 이름 변경하여 이동하기.

cp ./config.example.yml ~/.siriproxy/config.yml


13. siriproxy 설치

rake install


14. 인증서 생성하기

siriproxy gencerts


15. 배포하기(?)..

siriproxy bundle


16. siriproxy 서버 실행하기

rvmsudo siriproxy server

이 커멘드는 시리 프록시 서버를 실행 시킨다. "Starting SiriProxy on port 443.." 문구가 나올 것이다.


* config 값을 수정하면 15, 16번을 다시 실행해야 한다고 한다. 



iPhone 4S(5따위 가지고 있지 않아서 모른척)에서 설정. 


1. iPhone 4S에 ca.pem 인증서 설치하기

14번에서 만들어진 인증서를 iPhone 4S에 설치를 해야한다. 간단한 방법은 scp, ftp, afp 등을 사용해서 자신의 맥으로 옮긴다. 그리고 인증서 파일을 메일로 첨부한뒤, 아이폰에서 메일을 열고 첨부 파일을 터치하면 설치가 된다. 


2. WiFi DNS 주소 변경하기

iPhone 4S의 WiFi 설정으로 이동한뒤, 파란색 화살표 아이콘을 눌러서 WiFi 의 설정화면으로 이동한다. 명심해야 할 것은 라즈베리 파이와 iPhone 4S의 네트워크는 같아야 한다. DNS에 라즈베리 파이의 IP를 입력한다. 


3. Siri 테스트 하기

iPhone 4S의 홈버튼을 꾹~ 눌러서 시리가 나타나게 만든다. 그리고 "테스트 시리 프록시" 라고 말하면, 시리가 "Siri Proxy is up and running!" 이라고 대답하고, 터미널에서는 시리랑 대화 하는 패킷들이 주루룩 오고가고 있는 모습을 볼 수 있다.



이슈 및 해결 방법

설치 및 테스트를 하면서  4가지 이슈가 추가적으로 발생하였고 해결 방법을 공유 하도록 한다. 


1. No such file or directory - /root/.siriproxy/config.yml 이슈.


아래와 같이 siriproxy 서버를 실행을 하면 뭔가 파일을 찾을 수 없다는 메세지가 주루룩 뜬다. 

pi@raspberrypi:~/SiriProxy$ rvmsudo siriproxy server

Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. export rvmsudo_secure_path=1 to avoid the warning./home/pi/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/psych.rb:297:in `initialize': No such file or directory - /root/.siriproxy/config.yml (Errno::ENOENT)

from /home/pi/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/psych.rb:297:in `open'

from /home/pi/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/psych.rb:297:in `load_file'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:143:in `parse_options'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:33:in `initialize'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/bin/siriproxy:6:in `new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/bin/siriproxy:6:in `<top (required)>'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/bin/siriproxy:23:in `load'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/bin/siriproxy:23:in `<main>'


해결방법 : 

pi@raspberrypi:~/SiriProxy$ sudo mkdir /root/.siriproxy/

pi@raspberrypi:~/SiriProxy$ sudo cp config.example.yml /root/.siriproxy/config.yml


2. 443 포트를 사용하고 있다고 메세지(port is in use)가 뜨면서 종료. 

pi@raspberrypi:~/SiriProxy$ rvmsudo siriproxy server

Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. export rvmsudo_secure_path=1 to avoid the warning.

Starting SiriProxy on 0.0.0.0:443..

/home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_server'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy.rb:20:in `block in initialize'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `call'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy.rb:16:in `initialize'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:96:in `new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:96:in `start_server'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:85:in `run_server'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:37:in `initialize'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/bin/siriproxy:6:in `new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/bin/siriproxy:6:in `<top (required)>'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/bin/siriproxy:23:in `load'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/bin/siriproxy:23:in `<main>'


해결방법:

nginx에서 ssl 443 포트를 사용하고 있었는데, nginx (잠시) 종료

pi@raspberrypi:~/SiriProxy$ sudo service nginx stop 

Stopping nginx: nginx.

pi@raspberrypi:~/SiriProxy$ rvmsudo siriproxy server

Starting SiriProxy on 0.0.0.0:443..

SiriProxy up and running.


3. Warning: 메세지 

서버를 시작하면 아래와 같이 Warning: 메세지가 뜬다. 

pi@raspberrypi:~/SiriProxy$ rvmsudo siriproxy server

Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. export rvmsudo_secure_path=1 to avoid the warning.

Starting SiriProxy on 0.0.0.0:443..


해결방법:

pi@raspberrypi:~/SiriProxy$ export rvmsudo_secure_path=1


4. iPhone 4S에서 시리를 실행할 때 server.passless.key를 찾을 수 없다고 시리서버에서 에러

Create server for iPhone connection

/home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/em/connection.rb:411:in `block in start_tls': Could not find /root/.siriproxy/server.passless.key for start_tls (EventMachine::FileNotFoundException)

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/em/connection.rb:409:in `each'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/em/connection.rb:409:in `start_tls'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/connection/iphone.rb:15:in `post_init'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/em/connection.rb:58:in `block in new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/em/connection.rb:49:in `instance_eval'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/em/connection.rb:49:in `new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:1462:in `event_callback'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy.rb:16:in `initialize'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:96:in `new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:96:in `start_server'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:85:in `run_server'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/lib/siriproxy/command_line.rb:37:in `initialize'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/bin/siriproxy:6:in `new'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/gems/siriproxy-0.4.0/bin/siriproxy:6:in `<top (required)>'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/bin/siriproxy:23:in `load'

from /home/pi/.rvm/gems/ruby-1.9.3-p385/bin/siriproxy:23:in `<main>'


해결방법:

pi@raspberrypi:~/SiriProxy$ sudo cp ~/.siriproxy/server.passless.* /root/.siriproxy


제대로 서버가 시작되고 시리랑 통신이 되면 아래로그 처럼 패킷이 오고가고, 음성을 인식 하는 것을 확인 할 수가 있다. 

pi@raspberrypi:~/SiriProxy$ rvmsudo siriproxy server

Starting SiriProxy on 0.0.0.0:443..

SiriProxy up and running.

Create server for iPhone connection


start conn #<SiriProxy::Connection::Iphone:0x24d76a0 @signature=3, @processed_headers=false, @output_buffer="", @input_buffer="", @unzipped_input="", @unzipped_output="", @unzip_stream=#<Zlib::Inflate:0x24d75b0>, @zip_stream=#<Zlib::Deflate:0x22750e0>, @consumed_ace=false, @name="iPhone", @ssled=false>

[Info - Plugin Manager] Plugins loaded: [#<SiriProxy::Plugin::Example:0x265e960 @manager=#<SiriProxy::PluginManager:0x2274c18 @plugins=[...]>>]

[Info - iPhone] Received Object: LoadAssistant

[Info - iPhone] Received Object: SetRestrictions

[Info - iPhone] Received Object: ClearContext

[Info - iPhone] Received Object: SetBackgroundContext

[Info - iPhone] Received Object: StartSpeechRequest

[Info - iPhone] Received Object: SetRequestOrigin

[Info - User Location] lat: 37.33265096028488, long: 127.1206755237427

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - Guzzoni] Received Object: AssistantLoaded

[Info - Guzzoni] Received Object: SetConnectionHeader

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: FinishSpeech

[Info - Guzzoni] Received Object: SpeechRecognized

[Info - Plugin Manager] Processing '연습실을 폭식 '

[Info - Plugin Manager] Processing plugin #<SiriProxy::Plugin::Example:0x265e960>

[Info - Plugin Manager] No matches for '연습실을 폭식 '

[Info - Guzzoni] Received Object: AddViews

[Info - Guzzoni] Received Object: RequestCompleted

[Info - iPhone] Received Object: Metrics

[Info - iPhone] Received Object: ClearContext

Create server for iPhone connection

start conn #<SiriProxy::Connection::Iphone:0x296f0b8 @signature=5, @processed_headers=false, @output_buffer="", @input_buffer="", @unzipped_input="", @unzipped_output="", @unzip_stream=#<Zlib::Inflate:0x296efe0>, @zip_stream=#<Zlib::Deflate:0x296efc8>, @consumed_ace=false, @name="iPhone", @ssled=false>

[Info - Plugin Manager] Plugins loaded: [#<SiriProxy::Plugin::Example:0x2976a50 @manager=#<SiriProxy::PluginManager:0x296ed88 @plugins=[...]>>]

[Info - iPhone] Received Object: LoadAssistant

[Info - iPhone] Received Object: SetBackgroundContext

[Info - Guzzoni] Received Object: AssistantLoaded

[Info - iPhone] Received Object: SetRestrictions

[Info - iPhone] Received Object: ClearContext

[Info - iPhone] Received Object: StartSpeechRequest

[Info - iPhone] Received Object: SetRequestOrigin

[Info - User Location] lat: 37.33246262930172, long: 127.12103997179449

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - Guzzoni] Received Object: SetConnectionHeader

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: SpeechPacket

[Info - iPhone] Received Object: FinishSpeech

[Info - Guzzoni] Received Object: SpeechRecognized

[Info - Plugin Manager] Processing 'Test city Prokesh '

[Info - Plugin Manager] Processing plugin #<SiriProxy::Plugin::Example:0x2976a50>

[Info - Plugin Manager] No matches for 'Test city Prokesh '

[Info - Guzzoni] Received Object: AddViews

[Info - Guzzoni] Received Object: RequestCompleted

[Info - iPhone] Received Object: Metrics


참조 했던 싸이트 및 참고 할만 한 싸이트

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=9545&sid=f540e172fea915ee123c00d4b379722c&start=25

http://www.idownloadblog.com/2011/12/09/how-to-install-siri-proxy-tutorial-video/

http://www.raspberrypi.org/archives/tag/siriproxy

https://github.com/plamoni/SiriProxy

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=25118&p=231345

http://unleashthephones.com/2012/12/27/video-siri-proxy-raspberry-pi-get-siri-to-open-your-garage-door/

http://www.redmondpie.com/opening-garage-door-using-siri-and-a-raspberry-pi-video/


https://github.com/wayneeseguin/rvm/issues/1329

https://github.com/elvisimprsntr


저작자 표시 비영리
신고
Posted by KraZYeom