npm package: @martinkondor/harmonia
Description: Instant speech translator.
Author: Martin Kondor
Latest version: 1.0.8

# Harmonia [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Take%20a%20look%20at%20this%20repository%20https://github.com/MartinKondor/harmonia/)
[![Build Status](https://travis-ci.org/MartinKondor/harmonia.svg?branch=master)](https://travis-ci.org/MartinKondor/harmonia)

Instant speech translator, with instant speaking.

## Getting Started

This is the public repository for Harmonia (@martinkondor/harmonia), where issues can be tracked and development is executed.

[HarmoniaApp](https://github.com/MartinKondor/harmonia-app) is where harmonia is used.

Take a look at the ```CONTRIBUTING.md``` before starting to work.

## Usage

Install: ```npm i @martinkondor/harmonia/@1.0.8```.

Before using it you should define a ```ha-config.json``` file with this content:

```
{
    "engine": {
        "name": "<ENINGE_NAME_IN_LOWERCASE>",
        "key": "<ENGINE_KEY>"
    },
    "detector": {
        "name": "<DETECTOR_NAME_IN_LOWERCASE>",
        "key": "<DETECTOR_KEY>"
    }
}
```

If you are working on Harmonia you can create this file with the same content in the ```pids/``` folder.

### Simple translation

```
const harmonia = require('@martinkondor/harmonia');

harmonia.translate('Perro.', 'english') // Language can be defined with 2 characters also, 'english' is 'en'
.then((result) => {
  console.log(result); // Logs out 'Dog'
});
```

### Speaking

```
const harmonia = require('@martinkondor/harmonia');
const assistant = harmonia.Speech;

harmonia.translate('Perro.', 'english')
.then((result) => {
  assistant.say(result); // She will tell you 'Dog'
});
```

## For Developers

### Prerequisites

For development you will need an api key from [Yandex](https://tech.yandex.com/translate/) or [Google](https://cloud.google.com/compute/) for the translation engine, and [Detector](https://detectlanguage.com/) key for language detection.

### Notes

Translatable languages and their ISO code is in ```lib/ISOlanguage```.

### Steps

Fork, clone your repository, and set up the packages.

```
npm i
```

Make your changes. Write tests for it. Make sure tests pass.

```
npm test
```

Then, compile TypeScript files.

```
gulp build
```

Run JavaScript.

```
npm start
```

Or use nodemon.

```
nodemon harmonia
```

## Running the tests

We use jasmine for testing, tests should go to ```spec``` directory.
Write your test inside any file called ```<Filename>.spec.ts```.

Run your tests.
```
npm test
```

## Built With

* [TypeScript](https://www.typescriptlang.org/) - JavaScript compiler
* [Gulp](https://gulpjs.com/) - Task runner
* [Travis CI](https://travis-ci.org/) - Continuous integration
* [Jasmine](https://jasmine.github.io/) - Development framework for testing
* [NodeJS](https://nodejs.org/en/) - JavaScript runtime framework
* [NPM](https://www.npmjs.com/) - Software system

## Contributing

Please read the ```CONTRIBUTING.md``` for details on our code of conduct, and the process for submitting pull requests to us.

## License

Copyright (C) 2018 Martin Kondor

Code licensed under the MIT license, see the [LICENSE](https://github.com/MartinKondor/harmonia/blob/master/LICENSE) file for details.

## Contact

Email here: ```martinkondor@gmail.com```.