# Transcord
A simple recording and transcription module.

## Summary

  - [Getting started](#getting-started)
  - [Options](#options)
  - [Methods](#methods)
  - [Browser support](#browser-support)
  - [License](#license)


## Getting started

### Quick Start

Multiples start options are available :

- Using [NPM](https://www.npmjs.com/) : `npm install transcord`
- Using [Bower](https://bower.io/) : `bower install transcord`
- Clone the repository : `git clone https://github.com/SoTrxII/Transcord`
- [Download the latest release](https://github.com/SoTrxii/Transcord/archive/master.zip)


### Installation

Include the file :
```html
<script src="path/to/transcord.js"></script>
```

### Usage

```html
<!-- Create a textarea element -->
<textarea id="transcord"></textarea>
```

```js
('#transcord').transcord({options});
```

## Options

### record
- Type : Boolean
- Default : true

Define wether to record the user audio input.


### transcript
- Type : Boolean
- Default : true

Define wether to transcript the user audio input into text.


### transcriptLanguage
- Type : Enum
- Default : 'en-US'

Which language the user is using.


### transcriptLanguage
- Type : Enum
- Default : 'en-US'

Which language the user is using.


### isTranscriptPersistent
- Type : Boolean
- Default : true

Define if the old text must be kept when updating transcription.


### transcriptgrammar
- Type : SpeechGrammarList
- Default : undefined

Restrict instance grammar with the given SpeechGrammarList.


### recordNumber
- Type : Integer
- Default : 1

Number of blob than can be displayed at the same time.

### showMicIconNode
- Type : Boolean || jQuery Node
- Default : true

If the value is set to false, the mic icons aren't displayed.
If the value is set to true, the mic icons are appended into the parent of target element.
A jQuery node can be passed, thus appending the mics into this node.


### imgMicIdle
- Type : url
- Default : base64 img (assets/mic.gif in b64)

Mic icon when not recording.

### imgMicRecording
- Type : url
- Default : base64 img (assets/mic-animate.gif in b64)


Mic icon when recording.


### onInit
- Type : function
- Default : null

Things to do on initialization.

### onStart
- Type : function
- Default : null

Things to do when record/transcript starts.


### onStop
- Type : function
- Default : null

Things to do when record/transcript stops.


### onBlob
- Type : function
- Default : null

Things to do with the Blob object containing the recording.
Example :
```js
onBlob : function(event, blob){
  $(this).transcord('downloadBlob', blob, 'record');
}
```


## Methods

The following methods can be called like this :
```js
$().transcord('method');
```
### startRecording
Start to record/transcript.


### stopRecording
Stop to record/transcript.


### toogleRecord
Start/Stop to record/transcript.


### displayBlob
```js
$('elm').transcord('displayBlob', blob, [$node]);
```
Display the blob in a audio tag added to $node. If node is not specified, the audio tag will be added after elm.


### destroyBlob
```js
$().transcord('displayBlob',index);
```
Remove the audio tag in the DOM and destroy the blob url corresponding the the index parameter.
The index can be a number, an array of number and also a string. "first" will destroy the first blob recorded. "last" will destroy the last blob recorded. "all" will destroy all blobsURL.


### downloadBlob
```js
$('elm').transcord('downloadBlob', blob, [filename]);
```
Download the blob on client navigator. A filename can be specified.

### getBlobs

Returns all the blobs of records.
### trigger
Trigger event manually

##Browser support

To record the user audio input, the browser must [support getUserMedia()](http://caniuse.com/#feat=stream)

To transcript, the browser must [support the Speech Recognition API] (http://caniuse.com/#feat=speech-recognition)

##License
[MIT](http://opensource.org/licenses/MIT)

[⬆ back to top](#summary)
