Skip to content

Commit

Permalink
Starting with vocal commands
Browse files Browse the repository at this point in the history
  • Loading branch information
MooseSaeed committed Apr 2, 2022
1 parent e0deafa commit 712f66e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
40 changes: 38 additions & 2 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17624,7 +17624,10 @@ __webpack_require__.r(__webpack_exports__);
recording: false,
lang: "",
socket: null,
stream: null
stream: null,
transcript: [""],
magicKeys: ["apply bold", "apply link", "apply heading"],
keyIncluded: false
};
},
methods: {
Expand All @@ -17646,6 +17649,24 @@ __webpack_require__.r(__webpack_exports__);
track.stop();
});
},
makeItBold: function makeItBold() {
document.querySelector("md-bold").click();
},
makeItLink: function makeItLink() {
document.querySelector("md-link").click();
},
makeItHeading: function makeItHeading() {
document.querySelector("md-header").click();
},
vocalCommands: function vocalCommands() {
if (this.transcript.includes("apply bold")) {
this.makeItBold();
} else if (this.transcript.includes("apply link")) {
this.makeItLink();
} else if (this.transcript.includes("apply heading")) {
this.makeItHeading();
}
},
startTranscript: function startTranscript() {
var _this = this;

Expand Down Expand Up @@ -17674,7 +17695,22 @@ __webpack_require__.r(__webpack_exports__);

if (transcript && received.is_final) {
var textarea = document.getElementById("myTextArea");
textarea.value += transcript + " ";
var magicKeys = _this.magicKeys;
magicKeys.forEach(function (key) {
if (transcript.includes(key)) {
_this.keyIncluded = true;
}
});

if (!_this.keyIncluded) {
textarea.value += transcript + " ";
} else {
_this.transcript = transcript;

_this.vocalCommands();

_this.keyIncluded = false;
}
}
};
});
Expand Down
40 changes: 39 additions & 1 deletion resources/js/components/Markdowntoolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
<script>
import Microphone from "../components/SVGs/Microphone.vue";
import Stoprecroding from "../components/SVGs/Stoprecroding.vue";
export default {
components: {
Microphone,
Expand All @@ -216,6 +217,9 @@ export default {
lang: "",
socket: null,
stream: null,
transcript: [""],
magicKeys: ["apply bold", "apply link", "apply heading"],
keyIncluded: false,
};
},
methods: {
Expand All @@ -238,6 +242,25 @@ export default {
track.stop();
});
},
makeItBold() {
document.querySelector("md-bold").click();
},
makeItLink() {
document.querySelector("md-link").click();
},
makeItHeading() {
document.querySelector("md-header").click();
},
vocalCommands() {
if (this.transcript.includes("apply bold")) {
this.makeItBold();
} else if (this.transcript.includes("apply link")) {
this.makeItLink();
} else if (this.transcript.includes("apply heading")) {
this.makeItHeading();
}
},
startTranscript() {
navigator.mediaDevices
Expand Down Expand Up @@ -275,7 +298,22 @@ export default {
if (transcript && received.is_final) {
const textarea =
document.getElementById("myTextArea");
textarea.value += transcript + " ";
const magicKeys = this.magicKeys;
magicKeys.forEach((key) => {
if (transcript.includes(key)) {
this.keyIncluded = true;
}
});
if (!this.keyIncluded) {
textarea.value += transcript + " ";
} else {
this.transcript = transcript;
this.vocalCommands();
this.keyIncluded = false;
}
}
};
});
Expand Down

0 comments on commit 712f66e

Please sign in to comment.