Client-sided Javascript for recorder and Socket.IO Client management
- IDENTIFIER
IDENTIFIER class for implementation as patient, healthcare team. Its format can be customized by each hospital. This class is default format for Resume.
- RESUME_DEFAULT_OPTION
RESUME_DEFAULT_OPTION class for implementation as object of Resume Option
- AbstractResume ⇐
RESUME_DEFAULT_OPTION
Abstract class for any Resume
- ResumeChild ⇐
AbstractResume
ResumeChild class - manage the socket.io and session ID
- ResumeRecorder
Class handling microphone and media recorder for Resume
- ResumeOne ⇐
ResumeChild
ResumeOne is a class to manage microphone and sound chunk streaming via socket.io
- EVENT_CLIENT_INIT :
string
when Socket.IO client start to record
- EVENT_SERVER_SESSION_ID :
string
when Socket.IO server response session ID
- STREAM_ERROR :
string
when Socket.IO error occurs in server
- SS_AUDIO_STREAM :
string
when client streams sound to server
- SS_RESP_TRNSCR :
string
when server send transcript result back to client
- REC_PAUSED :
string
REC_PAUSED = "paused";
when recorder is paused.- REC_STOP :
string
REC_STOP = "stopped";
when recorder is stopped.- REC_INACTIVE :
string
REC_INACTIVE = "inactive";
when recorder is inactive.- REC_RECORDING :
string
REC_RECORDING = "recording";
when recorder is recording.- REC_NULL :
string
REC_NULL = null;
when recorder object is null or undefined.
- isFunc(obj) ⇒
Boolean
check if given object is function
- SoundHistory :
Object
History object argument of onRecorderStop
- getIntermediateUserTranscript ⇒
Resume-REST-API-Connect~GroupText
Callback to get intermediate user transcript in object, called when client send sound chunk to server.
- onReceiveTranscript :
function
Callback to recieved intermediate and final result from server.
- onReceiveFinalTranscript :
function
Callback to recieved final result from server.
- onRecorderStop :
function
Callback to received record history when the voice recorder stopped
- onError :
function
Callback to be called when error occurs
IDENTIFIER class for implementation as patient, healthcare team. Its format can be customized by each hospital. This class is default format for Resume.
Param | Type | Description |
---|---|---|
TXN | string | int |
Transaction number of action (e.g. Visit number , Admission number) |
[HN] | string | int |
Hospital number of patient |
[Location] | string | int |
that action is performed (e.g. OPD, IPD, Ward, Room) |
[Practioner] | string | int |
Identification information of main practioner (e.g. doctor, surgeon) |
[extraDetail] | string |
Extra detail of identifier e.g. note. |
RESUME_DEFAULT_OPTION class for implementation as object of Resume Option
new RESUME_DEFAULT_OPTION([sioOnConnectionCallback], [sioOnConnectionCallback], [langSuggest], [multiSpeaker], [defaultSectionID], [defaultDocFormat], [msSoundChuck], [alertError], [getIntermediateUserTranscript], [onReceiveTranscript], [onReceiveFinalTranscript], [onRecorderStop], [onError])
Param | Type | Default | Description |
---|---|---|---|
[sioOnConnectionCallback] | callable |
|
Callback when Socket.IO connects to server successfully. |
[sioOnConnectionCallback] | callable |
|
Callback when Socket.IO disconnects from server. |
[langSuggest] | Array.<string> | string |
['th-TH'] |
list of suggest voice language |
[multiSpeaker] | Boolean |
|
enable multispeaker mode (conversation mode) for API, set to false for dictation mode |
[defaultSectionID] | string | int |
0 |
default section of client's organization for billing and statistics |
[defaultDocFormat] | String |
|
default document format for transcriptor to summary response data |
[msSoundChuck] | float |
8000 |
size of sound chunk for sent to server in millisecond |
[alertError] | Boolean |
false |
alert if error |
[getIntermediateUserTranscript] | getIntermediateUserTranscript |
|
callback get intermediate user transcript in object |
[onReceiveTranscript] | onReceiveTranscript |
|
callback to recieved intermediate (and final) result from server. |
[onReceiveFinalTranscript] | onReceiveFinalTranscript |
|
callback to recieved final result from server. |
[onRecorderStop] | onRecorderStop |
|
callback to received record history when the voice recorder stopped |
[onError] | onError |
|
callback to handle error object or error message string, consist of err argument that can be error object or error message string. |
AbstractResume ⇐ RESUME_DEFAULT_OPTION
Abstract class for any Resume
Kind: global class
Extends: RESUME_DEFAULT_OPTION
ResumeChild ⇐ AbstractResume
ResumeChild class - manage the socket.io and session ID
Kind: global class
Extends: AbstractResume
Properties
Name | Type | Description |
---|---|---|
[tag] | string | int |
for marking the time position (second) of sound chunk which let the API to return the text position. It is important in |
dictation mode - to tell which part of form is correlated with sent sound. | ||
[sentBlobSize] | Array.<float> |
size (byte) of sent sound chunk |
SessionId | string |
ID of active session of sound listening |
sectionId | string | int |
ID of active section |
transcript | Resume-REST-API-Connect~Transcript |
Transcripted result from the API |
isFinalTranscript | Boolean |
true if the transcript response is final (ended). |
- ResumeChild ⇐
AbstractResume
- .getRecordTime() ⇒
float
- .getActiveSessionID() ⇒
string
- .getRecordTime() ⇒
getRecordTime() get recorded time of actual session
Kind: instance method of ResumeChild
Returns: float
- recorded time in seconds
getActiveSessionID() get active session ID
Kind: instance method of ResumeChild
Returns: string
- active session ID
Class handling microphone and media recorder for Resume
Kind: global class Properties
Name | Type | Default | Description |
---|---|---|---|
[recorder] | RecordRTC |
RecordRTC variable | |
[microphone] | MediaStream |
Microphone variable | |
[alertError] | Boolean |
call alert() if error | |
[msSoundChuck] | float |
1000 |
time interval to send sound chunk to Socket.IO |
- ResumeRecorder
- .getStatus() ⇒
string
|null
- .pause()
- .getStatus() ⇒
Get status of recoder can be one of REC_PAUSED = "paused", REC_STOP = "stopped", REC_INACTIVE = "inactive", REC_RECORDING = "recording", REC_NULL = null
Kind: instance method of ResumeRecorder
Summary: get status of recoder
Returns: string
| null
- recorder status null, "recording", "paused", "stopped" or "inactive".
pause the recorder
Kind: instance method of ResumeRecorder
ResumeOne ⇐ ResumeChild
ResumeOne is a class to manage microphone and sound chunk streaming via socket.io
Kind: global class
Extends: ResumeChild
Properties
Name | Type | Description |
---|---|---|
recorder | ResumeRecorder |
object of resume recorder to manage microphone. |
- ResumeOne ⇐
ResumeChild
- new ResumeOne(socket, [resumeOption])
- instance
- static
- .loadSectionList(urlSectionJSON) ⇒
Promise
- .loadSectionList(urlSectionJSON) ⇒
class constructor and set the event listener of socket.io
Param | Type | Description |
---|---|---|
socket | Socket.IO |
Socket.IO client object, e.g. create from io(url,option) |
[resumeOption] | RESUME_DEFAULT_OPTION | Object |
option for ResumeBase Class |
getStatus() get status of recorder
Kind: instance method of ResumeOne
Returns: string
- recorder status as the const REC_PAUSED = "paused", REC_STOP = "stopped", REC_INACTIVE = "inactive", REC_RECORDING = "recording", REC_NULL = null;
newSession - tell the speech API to create new session ID and create recording object. Then the API will response to sessionID property
Kind: instance method of ResumeOne
Summary: create new session ID which will be stored in sessionID property.
Param | Type | Default | Description |
---|---|---|---|
[hint] | Array.<string> | string |
|
hint for the voice-to-text transcripter |
identifier | * |
the object of identification data of patients (Transaction number, Visit number, Admission number, Hospital number) and healthcare workers (for researching or other purposes of each organization). This data will store (in local not sent outside private network. | |
sectionID | string | int |
e.g. department number, section of organization name | |
docFormat | string |
Format of document to let the speech-to-text API to generate returned data - reference the name from "C-CDA 1.1.0 on FHIR" otherwise | |
will be "Default". Please read README.md and http://hl7.org/fhir/us/ccda/artifacts.html | |||
[langSuggest] | Array.<string> | string |
BCP-47 language code in string type or array of string type ordered by highest priority to suggest the speech-to-text API - the default is located in ./public/lang.json . See more detail of BCP-47 |
endSession(userTranscript, callback) - end the listening session, send user-filled form to the speech API (for R&D). Then the API will response to onReceiveFinalTranscript and onReceiveTranscript callable.
Kind: instance method of ResumeOne
Summary: end the session, send form data to the API
Param | Type | Description |
---|---|---|
[userTranscript] | Object |
User-filled form data, should be followed the field name in "C-CDA 1.1.0 on FHIR" otherwise will be "other" - http://hl7.org/fhir/us/ccda/artifacts.html |
[callback] | callable |
to be called when the recorder javascript already stopped (already terminated microphone) and it do not wait for API response. |
pause() - Pause the recording session if allowPause is true.
Kind: instance method of ResumeOne
resume() - Resume the paused session if allowPause is true.
Kind: instance method of ResumeOne
getRecordTime() get recorded time of actual session
Kind: instance method of ResumeOne
Overrides: getRecordTime
Returns: float
- recorded time in seconds
getActiveSessionID() get active session ID
Kind: instance method of ResumeOne
Overrides: getActiveSessionID
Returns: string
- active session ID
static loadSectionList(urlSectionJSON) - load preset section information in json file.
Kind: static method of ResumeOne
Returns: Promise
- Promise(response) from jQuery.get method - containing section information JSON data
Param | Type | Description |
---|---|---|
urlSectionJSON | string | URL |
URL to preset section information |
when Socket.IO client start to record
when Socket.IO server response session ID
when Socket.IO error occurs in server
when client streams sound to server
when server send transcript result back to client
REC_PAUSED = "paused";
when recorder is paused.
REC_STOP = "stopped";
when recorder is stopped.
REC_INACTIVE = "inactive";
when recorder is inactive.
REC_RECORDING = "recording";
when recorder is recording.
REC_NULL = null;
when recorder object is null or undefined.
check if given object is function
Kind: global function
Returns: Boolean
- true if obj is function, otherwise false.
Param | Type | Description |
---|---|---|
obj | * |
object to be check |
History object argument of onRecorderStop
Kind: global typedef Properties
Name | Type | Description |
---|---|---|
session_id | string |
session ID. |
identifier | * |
identification data for location, patients and practitioner |
url | URL |
Blob URL of total sound |
blobsize | int |
size of Blob |
user_transcript | object |
user-filled form data |
Callback to get intermediate user transcript in object, called when client send sound chunk to server.
Kind: global typedef
Returns: Resume-REST-API-Connect~GroupText
- Object of user transcript
Callback to recieved intermediate and final result from server.
Kind: global typedef
Param | Type | Description |
---|---|---|
transcript | Resume-REST-API-Connect~Transcript |
object of transcript text from server in document format that set when client create new session ID. |
isEnd | Boolean |
true if this transcript is final and session close completely. |
Callback to recieved final result from server.
Kind: global typedef
Param | Type | Description |
---|---|---|
transcript | Resume-REST-API-Connect~Transcript |
object of transcript text from server in document format that set when client create new session ID. |
Callback to received record history when the voice recorder stopped
Kind: global typedef
Param | Type | Description |
---|---|---|
history | SoundHistory |
Object of history |
Callback to be called when error occurs
Kind: global typedef
Param | Type | Description |
---|---|---|
error | Object | string |
error object or error message string. |
© 2021 - copyright by Tanapat Kahabodeekanokkul - the founder of RESUME
.