Skip to content

Commit

Permalink
Adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicola committed Nov 4, 2018
1 parent 79e39a4 commit 2af7b16
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 59 deletions.
2 changes: 1 addition & 1 deletion config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import buble from 'rollup-plugin-buble'; // Transpile/polyfill with reasonable b
import uglify from 'rollup-plugin-uglify';

export default {
input: 'src/components/index.js', // Path relative to package.json
input: 'src/lib/index.js', // Path relative to package.json
output: {
name: 'VueVoice',
exports: 'named',
Expand Down
1 change: 1 addition & 0 deletions docs/css/app.6623fd4a.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added docs/favicon.ico
Binary file not shown.
Binary file added docs/img/logo.82b9c7a5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/img/mic.7d7a0432.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/img/stop.56423db7.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>vue-voice</title><link href=/css/app.6623fd4a.css rel=preload as=style><link href=/js/app.717d956a.js rel=preload as=script><link href=/js/chunk-vendors.d73966bc.js rel=preload as=script><link href=/css/app.6623fd4a.css rel=stylesheet></head><body><noscript><strong>We're sorry but vue-voice doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.d73966bc.js></script><script src=/js/app.717d956a.js></script></body></html>
2 changes: 2 additions & 0 deletions docs/js/app.717d956a.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/js/app.717d956a.js.map

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions docs/js/chunk-vendors.d73966bc.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/js/chunk-vendors.d73966bc.js.map

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "vue-cli-service lint",
"test:unit": "vue-cli-service test:unit",
"delete-dist": "rm -rf dist",
"build:lib": "npm run delete-dist & npm run build:umd & npm run build:es & npm run build:unpkg & node packaging/copy-package",
"build:lib": "npm run delete-dist & npm run build:umd & npm run build:es & npm run build:unpkg & node packaging/copy-package & node packaging/copy-assets & npm pack dist/",
"build:umd": "rollup --config config/rollup.config.js --format umd --file dist/vue-voice.umd.js",
"build:es": "rollup --config config/rollup.config.js --format es --file dist/vue-voice.esm.js",
"build:unpkg": "rollup --config config/rollup.config.js --format iife --file dist/vue-voice.min.js",
Expand All @@ -17,7 +17,7 @@
"dependencies": {
"rxjs": "^6.3.3",
"vue": "^2.5.17",
"vue-voice": "file:///C:\\github\\vue-voice\\vue-voice-0.1.1-beta.tgz"
"vue-voice": "file:///C:\\github\\vue-voice\\vue-voice-0.1.4-beta.tgz"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.5",
Expand All @@ -30,6 +30,7 @@
"babel-jest": "^23.6.0",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-0",
"fs-extra": "^5.0.0",
"node-sass": "^4.9.4",
"rollup-plugin-buble": "^0.19.4",
"rollup-plugin-uglify": "^6.0.0",
Expand Down
12 changes: 12 additions & 0 deletions packaging/copy-assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const PATH_SRC = 'src/';
const PATH_DIST = 'dist/';
const fs = require('fs-extra');

fs.copy(`${PATH_SRC}assets`, `${PATH_DIST}assets`)
.then(() => {
console.info('[PACKAGING]::: Copying assets.');
})
.catch((err) => {
if (err) return console.error(err);
return true;
});
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</template>

<script>
// import { CustomButton } from 'vue-voice';
// import { SpeechToText } from 'vue-voice';
import SpeechToText from './lib/components/SpeechToText.vue';
export default {
Expand Down
21 changes: 17 additions & 4 deletions src/lib/components/SpeechToText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,38 @@
<div class="speech-to-text__button-container">
<div @click="onClick()" :class="{ 'speech-to-text__button--speaking': isSpeaking }"
class="speech-to-text__button">
<img v-if="!isSpeaking" src="../../assets/mic.svg">
<img v-if="!isSpeaking" :src="micImage">
<img v-if="isSpeaking"
class="speech-to-text__stop"
src="../../assets/stop.svg">
class="speech-to-text__stop" :src="stopImage">
</div>
</div>
</div>
</template>

<script>
import SpeechToText from '../services/speech-to-text';
import micImage from '../../assets/mic.svg';
import stopImage from '../../assets/stop.svg';
// const micImage = require('../../assets/mic.svg');
// const stopImage = require('../../assets/stop.svg');
/*
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars
*/
export default {
name: 'SpeechToText',
data() {
return {
isSpeaking: false,
speech: '',
speechService: {}
speechService: {},
micImage,
stopImage
};
},
methods: {
Expand Down
1 change: 0 additions & 1 deletion src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ const VueVoice = {
};

module.exports = VueVoice;

2 changes: 1 addition & 1 deletion src/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-voice",
"version": "0.1.1-beta",
"version": "0.1.4-beta",
"main": "./vue-voice.umd.js",
"module": "./vue-voice.esm.js",
"unpkg": "./vue-voice.min.js",
Expand Down
84 changes: 40 additions & 44 deletions src/lib/services/speech-to-text.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
/* eslint-disable no-use-before-define */
/* eslint-disable no-undef */

import { Subject } from 'rxjs';

const SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;

export default class SpeechToText {
recognition;

result;

resultSubject = new Subject();

constructor() {
this.recognition = new SpeechRecognition();
this.result = 'created';

this.recognition.lang = 'en-EN';
this.recognition.interimResults = false;
this.recognition.maxAlternatives = 1;

this.recognition.onresult = (event) => {
console.log('Event', event);

const last = event.results.length - 1;
this.result = event.results[last][0].transcript;

console.log(`Confidence: ${event.results[0][0].confidence}`, this.result);
this.resultSubject.next(this.result);
};

this.recognition.onspeechend = () => {
this.recognition.stop();
console.log('Speech end');
this.resultSubject.next('');
};

this.recognition.onnomatch = () => {
console.log("I didn't recognise that colors.");
};

this.recognition.onerror = (event) => {
console.log(`Error occurred in recognition: ${event.error}`);
this.resultSubject.error(`Error occurred in recognition: ${event.error}`);
};
}

speak() {
this.recognition.start();
return this.resultSubject;
}
constructor() {
this.recognition = new SpeechRecognition();
this.result = 'created';
this.resultSubject = new Subject();

this.recognition.lang = 'en-EN';
this.recognition.interimResults = false;
this.recognition.maxAlternatives = 1;

this.recognition.onresult = (event) => {
console.log('Event', event);

const last = event.results.length - 1;
this.result = event.results[last][0].transcript;

console.log(`Confidence: ${event.results[0][0].confidence}`, this.result);
this.resultSubject.next(this.result);
};

this.recognition.onspeechend = () => {
this.recognition.stop();
console.log('Speech end');
this.resultSubject.next('');
};

this.recognition.onnomatch = () => {
console.log("I didn't recognise that colors.");
};

this.recognition.onerror = (event) => {
console.log(`Error occurred in recognition: ${event.error}`);
this.resultSubject.error(`Error occurred in recognition: ${event.error}`);
};
}

speak() {
this.recognition.start();
return this.resultSubject;
}
}

0 comments on commit 2af7b16

Please sign in to comment.