• Find us on

Speech Recognition Server and Keyword Spotting Specification with Sentiment

Speech Recognition Server Specification

It’s a real-time full-duplex speech recognition server. Communication with the server is based on WebSockets. The client sends speech to the server using small chunks, while the server sends partial and full recognition hypotheses back to the client via the same WebSocket, thus enabling full-duplex communication. The client can be implemented in Javascript, thus enabling browser-based speech recognition, or on mobile or tablets or laptops using a WebSockets library.

Client-server protocol

This document describes the client-server protocol used by the system.

Opening a session

To open a session, connect to the specified server WebSocket address (e.g. wss://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx)

Sending audio

The speech should be sent to the server in raw blocks of data, using the encoding specified when the session was opened or in the header of the connection. It is recommended that a new block is sent at least 4 times per second (less frequent blocks would increase the recognition lag). Blocks do not have to be of equal size.

After the last block of speech data, a special 3-byte ANSI-encoded string “EOS” (“end-of-stream”) needs to be sent to the server. This tells the server that no more speech is coming and the recognition can be finalized.

After sending “EOS”, the client has to keep the WebSocket open to receive recognition results from the server. The server closes the connection itself when all recognition results have been sent to the client. No more audio can be sent via the same WebSocket after an “EOS” has been sent. In order to process a new audio stream, a new WebSocket connection has to be created by the client.

Usage

python client.py –uri “wss://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx” –save-json-filename sample1_transcription.json –rate 4200 sample1.wav

Options

  • –save-json-filename: Save the intermediate JSON to this specified file
  • –rate: Rate in bytes/sec at which audio should be sent to the server
  • –uri: Server WebSocket URI

 

Reading results

The server sends recognition results and other information to the client using the JSON format. The response can contain the following fields:

  • status: response status (integer), see codes below
  • message:(optional) status message
  • result: (optional) recognition result, containing the following fields:
  • hypotheses: recognized words, a list with each item containing the following:
  • transcript: recognized words
  • confidence: (optional) confidence of the hypothesis (float, 0..1)
  • final: true when the hypothesis is final, i.e., doesn’t change anymore

The following status codes are currently in use:

  • 0 — Success. Usually used when recognition results are sent
  • 1 — No speech. Sent when the incoming audio contains a large portion of silence or non-speech
  • 2 — Aborted. Recognition was aborted for some reason.
  • 9 — Not available. Used when all recognizer processes are currently in use and recognition cannot be performed.

Websocket is always closed by the server after sending a non-zero status update.

Examples of server responses

{u’status’: 0, u’segment-start’: 9.487499237060547, u’segment-length’: 5.87999963760376, u’total-length’: 15.735008239746094, ‘sentiment’: u’Positive’, u’result’: {u’hypotheses’: [{u’likelihood’: 0.9973933100700378, u’speaking_rate’: 1.020408272743225, u’transcript’: u’how can I help you today’, u’word-alignment’: [{u’start’: 0.0, u’length’: 4.289999961853027, u’word’: u’how’, u’confidence’: 1.0}, {u’start’: 4.289999961853027, u’length’: 0.08999999612569809, u’word’: u’can’, u’confidence’: 1.0}, {u’start’: 4.380000114440918, u’length’: 0.05999999865889549, u’word’: u’I’, u’confidence’: 0.9843596816062927}, {u’start’: 4.440000057220459, u’length’: 0.26999998092651367, u’word’: u’help’, u’confidence’: 1.0}, {u’start’: 4.739999771118164, u’length’: 0.11999999731779099, u’word’: u’you’, u’confidence’: 1.0}, {u’start’: 4.859999656677246, u’length’: 1.0199999809265137, u’word’: u’today’, u’confidence’: 1.0}], u’formatted_transcript’: u’ How can I help you today,’}], u’final’: True}, u’segment’: 1.0, u’id’: u’03.26.2019_06.49.47_AM_telephony_9_92550624′}

Sentiment can be Neutral, Positive and Negative.

{“status”: 9}

{“status”: 0, “result”: {“hypotheses”: [{“transcript”: “see on”}], “final”: false}}

{“status”: 0, “result”: {“hypotheses”: [{“transcript”: “see on teine lause.”}], “final”: true}}

The server segments incoming audio on the fly. For each segment, many non-final hypotheses, followed by one final hypothesis are sent. Non-final hypotheses are used to present partial recognition hypotheses to the client. A sequence of the non-final hypothesis is always followed by a final hypothesis for that segment. After sending a final hypothesis for a segment, the server starts decoding the next segment or closes the connection, if all audio sent by the client has been processed.

The client is responsible for presenting the results to the user in a way suitable for the application.

For Keyword Spotting and corresponding Intent through HTTP or WS API

Our Speech Recognition API is also used for finding a particular keyword from the ASR transcripts. It will give the phrases that you want, start time and end time in seconds of the phases, score, and Intent if required. You have to enter the phrases as the validation_string in our API. If need particular intent for phrases also gives that by the comma separation of phrases and intent. Your phrases contain space please replace it with %20 in API call. For multiple phrases detection in single API write all phrases with (|) pip separated in the validation_string field. See the below format and example for more information.

Note: This API work on (.wav) (8KHz, 16-bit signed PCM and mono channel ) audio format.

Format:
For HTTP

“https://://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx&validation_string=users_phrases”. For multiple phrases “https:/://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx&validation_string=phrase 1|phrase 2|phrase 3”.

For WebSocket client

“wss://://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx&validation_string=users_phrases”.  For multiple phrases “wss://://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx&validation_string=phrase 1| phrase 2|phrase 3”.

Example

For WebSocket client

python client.py –uri “wss://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx&validation_string=airlines|reservations|check%20status”  –save-json-filename sample1_phrases.json –rate 4200 sample1.wav

For HTTP

curl –request POST –data-binary “@sample1.wav” “https://services.govivace.com:49149/telephony?key=xxxxxxxxxxxxxxx&validation_string=airlines|reservations|check%20status”

Response:

{u’status’: 0, u’segment-start’: 0.0, u’segment-length’: 8.549999237060547, u’total-length’: 9.487499237060547, ‘sentiment’: u’Negative’, u’result’: {u’hypotheses’: [{u’transcript’: u’thank you for calling alaska airlines but ice by noon open doors’, u’speaking_rate’: 1.4035089015960693, u’keywords’: [{u’phrase’: u’airlines’, u’score’: 0.8999999761581421, u’end’: 5.939999580383301, u’start’: 4.230000019073486}], u’formatted_transcript’: u’ Thank you for calling Alaska Airlines, but ice by noon, Open doors,’, u’likelihood’: 0.8808204531669617, u’word-alignment’: [{u’start’: 0.0, u’length’: 2.9700000286102295, u’word’: u’thank’, u’confidence’: 1.0}, {u’start’: 2.9700000286102295, u’length’: 0.11999999731779099, u’word’: u’you’, u’confidence’: 1.0}, {u’start’: 3.0899999141693115, u’length’: 0.14999999105930328, u’word’: u’for’, u’confidence’: 1.0}, {u’start’: 3.240000009536743, u’length’: 0.41999998688697815, u’word’: u’calling’, u’confidence’: 1.0}, {u’start’: 3.68999981880188, u’length’: 0.5099999904632568, u’word’: u’alaska’, u’confidence’: 1.0}, {u’start’: 4.230000019073486, u’length’: 1.709999918937683, u’word’: u’airlines’, u’confidence’: 1.0}, {u’start’: 5.940000057220459, u’length’: 0.08999999612569809, u’word’: u’but’, u’confidence’: 1.0}, {u’start’: 6.029999732971191, u’length’: 0.26999998092651367, u’word’: u’ice’, u’confidence’: 0.5158590078353882}, {u’start’: 6.299999713897705, u’length’: 0.08999999612569809, u’word’: u’by’, u’confidence’: 0.9764412641525269}, {u’start’: 6.420000076293945, u’length’: 0.44999998807907104, u’word’: u’noon’, u’confidence’: 0.9842000007629395}, {u’start’: 6.899999618530273, u’length’: 0.29999998211860657, u’word’: u’open’, u’confidence’: 0.5237200856208801}, {u’start’: 7.230000019073486, u’length’: 1.3199999332427979, u’word’: u’doors’, u’confidence’: 0.5696256756782532}]}], u’final’: True}, u’segment’: 0.0, u’id’: u’03.26.2019_06.49.47_AM_telephony_9_92550624′}

{u’status’: 0, u’segment-start’: 9.487499237060547, u’segment-length’: 5.87999963760376, u’total-length’: 15.735008239746094, ‘sentiment’: u’Positive’, u’result’: {u’hypotheses’: [{u’likelihood’: 0.9973933100700378, u’speaking_rate’: 1.020408272743225, u’transcript’: u’how can I help you today’, u’word-alignment’: [{u’start’: 0.0, u’length’: 4.289999961853027, u’word’: u’how’, u’confidence’: 1.0}, {u’start’: 4.289999961853027, u’length’: 0.08999999612569809, u’word’: u’can’, u’confidence’: 1.0}, {u’start’: 4.380000114440918, u’length’: 0.05999999865889549, u’word’: u’I’, u’confidence’: 0.9843596816062927}, {u’start’: 4.440000057220459, u’length’: 0.26999998092651367, u’word’: u’help’, u’confidence’: 1.0}, {u’start’: 4.739999771118164, u’length’: 0.11999999731779099, u’word’: u’you’, u’confidence’: 1.0}, {u’start’: 4.859999656677246, u’length’: 1.0199999809265137, u’word’: u’today’, u’confidence’: 1.0}], u’formatted_transcript’: u’ How can I help you today,’}], u’final’: True}, u’segment’: 1.0, u’id’: u’03.26.2019_06.49.47_AM_telephony_9_92550624′}

{u’status’: 0, u’segment-start’: 15.735008239746094, u’segment-length’: 13.440000534057617, u’total-length’: 29.447528839111328, ‘sentiment’: u’Negative’, u’result’: {u’hypotheses’: [{u’transcript’: u’I miss that tell me the reason for your call you can say things like reservations award travel or mileage plan account so how can I help you’, u’speaking_rate’: 2.0833332538604736, u’keywords’: [{u’phrase’: u’reservations’, u’score’: 1.0, u’end’: 8.130000114440918, u’start’: 7.739999771118164}], u’formatted_transcript’: u’ I miss that tell me? The reason for your call? You can say things like Reservations award, Travel or Mileage plan account, so how can I help? You’, u’likelihood’: 0.9840845465660095, u’word-alignment’: [{u’start’: 0.0, u’length’: 2.879999876022339, u’word’: u’I’, u’confidence’: 1.0}, {u’start’: 2.879999876022339, u’length’: 0.32999998331069946, u’word’: u’miss’, u’confidence’: 0.8325990438461304}, {u’start’: 3.2100000381469727, u’length’: 0.44999998807907104, u’word’: u’that’, u’confidence’: 1.0}, {u’start’: 3.68999981880188, u’length’: 0.14999999105930328, u’word’: u’tell’, u’confidence’: 0.7438820600509644}, {u’start’: 3.8399999141693115, u’length’: 0.17999999225139618, u’word’: u’me’, u’confidence’: 0.9997416138648987}, {u’start’: 4.049999713897705, u’length’: 0.29999998211860657, u’word’: u’the’, u’confidence’: 1.0}, {u’start’: 4.380000114440918, u’length’: 0.05999999865889549, u’word’: u’reason’, u’confidence’: 1.0}, {u’start’: 4.440000057220459, u’length’: 0.20999999344348907, u’word’: u’for’, u’confidence’: 0.9965186715126038}, {u’start’: 4.650000095367432, u’length’: 0.11999999731779099, u’word’: u’your’, u’confidence’: 0.9965186715126038}, {u’start’: 4.769999980926514, u’length’: 1.0799999237060547, u’word’: u’call’, u’confidence’: 1.0}, {u’start’: 5.87999963760376, u’length’: 0.05999999865889549, u’word’: u’you’, u’confidence’: 1.0}, {u’start’: 5.940000057220459, u’length’: 0.26999998092651367, u’word’: u’can’, u’confidence’: 1.0}, {u’start’: 6.210000038146973, u’length’: 0.14999999105930328, u’word’: u’say’, u’confidence’: 0.9997020363807678}, {u’start’: 6.359999656677246, u’length’: 0.26999998092651367, u’word’: u’things’, u’confidence’: 1.0}, {u’start’: 6.659999847412109, u’length’: 1.0499999523162842, u’word’: u’like’, u’confidence’: 1.0}, {u’start’: 7.739999771118164, u’length’: 0.38999998569488525, u’word’: u’reservations’, u’confidence’: 1.0}, {u’start’: 8.130000114440918, u’length’: 0.6599999666213989, u’word’: u’award’, u’confidence’: 0.9997377395629883}, {u’start’: 8.789999961853027, u’length’: 0.5699999928474426, u’word’: u’travel’, u’confidence’: 0.9999252557754517}, {u’start’: 9.359999656677246, u’length’: 0.26999998092651367, u’word’: u’or’, u’confidence’: 0.9997215270996094}, {u’start’: 9.630000114440918, u’length’: 0.32999998331069946, u’word’: u’mileage’, u’confidence’: 1.0}, {u’start’: 9.960000038146973, u’length’: 0.41999998688697815, u’word’: u’plan’, u’confidence’: 0.9983441829681396}, {u’start’: 10.380000114440918, u’length’: 0.8700000047683716, u’word’: u’account’, u’confidence’: 0.9998006820678711}, {u’start’: 11.25, u’length’: 0.11999999731779099, u’word’: u’so’, u’confidence’: 1.0}, {u’start’: 11.399999618530273, u’length’: 0.08999999612569809, u’word’: u’how’, u’confidence’: 1.0}, {u’start’: 11.489999771118164, u’length’: 0.20999999344348907, u’word’: u’can’, u’confidence’: 1.0}, {u’start’: 11.699999809265137, u’length’: 0.029999999329447746, u’word’: u’I’, u’confidence’: 0.9878733158111572}, {u’start’: 11.729999542236328, u’length’: 0.32999998331069946, u’word’: u’help’, u’confidence’: 1.0}, {u’start’: 12.09000015258789, u’length’: 1.3199999332427979, u’word’: u’you’, u’confidence’: 1.0}]}], u’final’: True}, u’segment’: 2.0, u’id’: u’03.26.2019_06.49.47_AM_telephony_9_92550624′}

{u’status’: 0, u’segment-start’: 29.447528839111328, u’segment-length’: 17.219999313354492, u’total-length’: 47.025054931640625, ‘sentiment’: u’Negative’, u’result’: {u’hypotheses’: [{u’transcript’: u”I still didn’t get that to see if the flights on time say check status for all reservations including award travel save reservations otherwise they mileage plan account or more options”, u’speaking_rate’: 1.8002324104309082, u’keywords’: [{u’phrase’: u’reservations’, u’score’: 0.8999999761581421, u’end’: 9.779999732971191, u’start’: 9.239999771118164}, {u’phrase’: u’reservations’, u’score’: 1.0, u’end’: 12.959999084472656, u’start’: 12.089999198913574}, {u’phrase’: u’check status’, u’score’: 0.8940849900245667, u’end’: 8.130000114440918, u’start’: 6.899999618530273}], u’formatted_transcript’: u” I still didn’t get that to see if the flights on time say check status for all reservations, including award, travel Save Reservations. Otherwise, they mileage plan account, or more options,”, u’likelihood’: 0.9496305584907532, u’word-alignment’: [{u’start’: 0.0, u’length’: 3.0299999713897705, u’word’: u’I’, u’confidence’: 1.0}, {u’start’: 3.0299999713897705, u’length’: 0.41999998688697815, u’word’: u’still’, u’confidence’: 1.0}, {u’start’: 3.4499998092651367, u’length’: 0.11999999731779099, u’word’: u”didn’t”, u’confidence’: 1.0}, {u’start’: 3.569999933242798, u’length’: 0.29999998211860657, u’word’: u’get’, u’confidence’: 1.0}, {u’start’: 3.869999885559082, u’length’: 0.8100000023841858, u’word’: u’that’, u’confidence’: 0.9825912714004517}, {u’start’: 4.679999828338623, u’length’: 0.029999999329447746, u’word’: u’to’, u’confidence’: 0.9998898506164551}, {u’start’: 4.710000038146973, u’length’: 0.20999999344348907, u’word’: u’see’, u’confidence’: 0.999488353729248}, {u’start’: 4.949999809265137, u’length’: 0.05999999865889549, u’word’: u’if’, u’confidence’: 0.9910974502563477}, {u’start’: 5.009999752044678, u’length’: 0.11999999731779099, u’word’: u’the’, u’confidence’: 0.4404817819595337}, {u’start’: 5.159999847412109, u’length’: 0.35999998450279236, u’word’: u’flights’, u’confidence’: 0.7515934109687805}, {u’start’: 5.519999980926514, u’length’: 0.26999998092651367, u’word’: u’on’, u’confidence’: 1.0}, {u’start’: 5.789999961853027, u’length’: 0.8100000023841858, u’word’: u’time’, u’confidence’: 0.9999695420265198}, {u’start’: 6.62999963760376, u’length’: 0.26999998092651367, u’word’: u’say’, u’confidence’: 0.9845640063285828}, {u’start’: 6.899999618530273, u’length’: 0.5399999618530273, u’word’: u’check’, u’confidence’: 0.5181866884231567}, {u’start’: 7.440000057220459, u’length’: 0.6899999976158142, u’word’: u’status’, u’confidence’: 1.0}, {u’start’: 8.130000114440918, u’length’: 0.11999999731779099, u’word’: u’for’, u’confidence’: 0.9965783357620239}, {u’start’: 8.25, u’length’: 0.9599999785423279, u’word’: u’all’, u’confidence’: 0.9965783357620239}, {u’start’: 9.239999771118164, u’length’: 0.5399999618530273, u’word’: u’reservations’, u’confidence’: 1.0}, {u’start’: 9.779999732971191, u’length’: 0.029999999329447746, u’word’: u’including’, u’confidence’: 1.0}, {u’start’: 9.809999465942383, u’length’: 0.5999999642372131, u’word’: u’award’, u’confidence’: 0.9948581457138062}, {u’start’: 10.40999984741211, u’length’: 0.5699999928474426, u’word’: u’travel’, u’confidence’: 0.9992496371269226}, {u’start’: 11.039999961853027, u’length’: 1.0499999523162842, u’word’: u’save’, u’confidence’: 0.8139262199401855}, {u’start’: 12.09000015258789, u’length’: 0.8700000047683716, u’word’: u’reservations’, u’confidence’: 1.0}, {u’start’: 12.960000038146973, u’length’: 0.23999999463558197, u’word’: u’otherwise’, u’confidence’: 1.0}, {u’start’: 13.199999809265137, u’length’: 0.5699999928474426, u’word’: u’they’, u’confidence’: 0.9724165797233582}, {u’start’: 13.769999504089355, u’length’: 0.14999999105930328, u’word’: u’mileage’, u’confidence’: 1.0}, {u’start’: 13.920000076293945, u’length’: 0.5699999928474426, u’word’: u’plan’, u’confidence’: 0.9985790252685547}, {u’start’: 14.489999771118164, u’length’: 0.23999999463558197, u’word’: u’account’, u’confidence’: 0.9999307990074158}, {u’start’: 14.729999542236328, u’length’: 0.6599999666213989, u’word’: u’or’, u’confidence’: 0.9985681176185608}, {u’start’: 15.389999389648438, u’length’: 0.26999998092651367, u’word’: u’more’, u’confidence’: 1.0}, {u’start’: 15.6899995803833, u’length’: 1.5299999713897705, u’word’: u’options’, u’confidence’: 1.0}]}], u’final’: True}, u’segment’: 3.0, u’id’: u’03.26.2019_06.49.47_AM_telephony_9_92550624′}

{u’status’: 0, u’segment-start’: 47.025054931640625, u’segment-length’: 5.639999866485596, u’total-length’: 52.96006393432617, ‘sentiment’: u’Negative’, u’result’: {u’hypotheses’: [{u’likelihood’: 0.9267063140869141, u’speaking_rate’: 2.127659559249878, u’transcript’: u”sorry I don’t think I heard you to see the blinders on”, u’word-alignment’: [{u’start’: 0.0, u’length’: 2.879999876022339, u’word’: u’sorry’, u’confidence’: 1.0}, {u’start’: 2.9099998474121094, u’length’: 0.29999998211860657, u’word’: u’I’, u’confidence’: 1.0}, {u’start’: 3.2100000381469727, u’length’: 0.029999999329447746, u’word’: u”don’t”, u’confidence’: 0.7100933194160461}, {u’start’: 3.240000009536743, u’length’: 0.26999998092651367, u’word’: u’think’, u’confidence’: 1.0}, {u’start’: 3.5399999618530273, u’length’: 0.29999998211860657, u’word’: u’I’, u’confidence’: 1.0}, {u’start’: 3.8399999141693115, u’length’: 0.17999999225139618, u’word’: u’heard’, u’confidence’: 1.0}, {u’start’: 4.019999980926514, u’length’: 0.5399999618530273, u’word’: u’you’, u’confidence’: 0.9999684691429138}, {u’start’: 4.559999942779541, u’length’: 0.23999999463558197, u’word’: u’to’, u’confidence’: 0.999052882194519}, {u’start’: 4.799999713897705, u’length’: 0.0, u’word’: u’see’, u’confidence’: 0.991866946220398}, {u’start’: 4.859999656677246, u’length’: 0.11999999731779099, u’word’: u’the’, u’confidence’: 0.9754995107650757}, {u’start’: 5.009999752044678, u’length’: 0.35999998450279236, u’word’: u’blinders’, u’confidence’: 0.5880283117294312}, {u’start’: 5.460000038146973, u’length’: 0.17999999225139618, u’word’: u’on’, u’confidence’: 0.855966329574585}], u’formatted_transcript’: u” Sorry I don’t think I heard you to see the blinders on”}], u’final’: True}, u’segment’: 4.0, u’id’: u’03.26.2019_06.49.47_AM_telephony_9_92550624′}

See the Bold things in response to the keyword Spotting, transcription and sentiment.