Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.66 KB

README.rdoc

File metadata and controls

56 lines (39 loc) · 1.66 KB

Introduction

Using pocketsphinx, Gst, ruby 1.8.7 (gst not working with ruby 1.9). For required gems using bundler.

gem install bundler
bundle install

To start the server go to the project root and type in terminal:

ruby recognizer_api.rb

Requests

Create session and get id

curl -X POST  http://localhost:4567/recognizer

Send data

curl -X PUT --data-binary @/home/user/test/data/speech.raw http://localhost:4567/recognizer/ <session_id>

End feed to get the final result

curl -X PUT http://localhost:4567/recognizer/ <session_id> /end

Get result and session data

curl  http://localhost:4567/recognizer/ <session_id>

Response

  • Response is by default xml. If you want json response set your request Accept headers to “application/json”

curl -X POST  http://localhost:4567/recognizer  -H "Accept:application/json"
  • For all requests, the successful response containing session data looks like this:

  • in xml:

<?xml version="1.0" encoding="UTF-8"?>
<recognizer_session>
  <closed_at></closed_at>
  <final_result_created_at></final_result_created_at>
  <created_at>2011-04-26 16:13:25</created_at>
  <result></result>
  <id>54374c7294</id>
  <system_message></system_message>
</recognizer_session>

* in json:

{"closed_at":null,"final_result_created_at":null,"system_message":null,"result":null,"id":"a1d80929c4","created_at":"2011-04-28 12:41:39"}
  • If an error occurs, the response looks like this:

  • in xml:

<?xml version="1.0" encoding="UTF-8"?>
<error>
  <message>X-Recognizer-Request-Type must be present and set to 'data' or 'data_end'</message>
</error>

* in json:

{"error":{"message":"Session with id b8e7524749 not found"}}