Merge remote-tracking branch 'origin/main'

This commit is contained in:
riqo 2021-02-05 16:47:03 -06:00
commit 9d64ffcb41
31 changed files with 360 additions and 387 deletions

View file

@ -1,12 +0,0 @@
{
"type": "service_account",
"project_id": "crimata",
"private_key_id": "3a324fa3fcca4cea589e4b5007f4142db4b3a84d",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCxFJOjhIkYlyhn\nHjtpFC5EOwzNFZem6k6SS7zcgWbNLe9mcBsiTKCjpxItzkIo0pnT32yqw+AKsqpv\n6+LVyzzjfB7vtEUflvg6KgmYMS4ixOTCEbN3e2qj1t2RnITXZR2VGSGdoKKyqZm0\ntWrmexQvSN20cByL1vfxD3E69oYFGhVraa0zmm94WXHAzofT6DkvGdrbK1s1G9jI\nG3mdQ1jN71tghyloeHL+R/1iKQoZFYTkVe6yWvccSNAZelt/5sciCKRTCArXj89X\nLwU6jGOKIsyqx3BeUyWaSS59xpnGX3meSf5Q9U+j45ePUiqO6TTleF+kWiBwjUpp\nfeYcwEIDAgMBAAECggEAElkN9R7p75zV6F1XDYu0QYiWyncmx/o2Gu1zC6vywWa1\ni/korpSe/mX0ub9J1p3/p1balRUHlUQu6brYvYs56140fGTC1sOXQ7uQU+8glySs\niTk5TbOBeKluOsSrdP/6oTTB6Wm4AegVz4YOpgPxsvaLVkNZidnDxfvyIQhjGYsO\nsvRaw48eEmGOa1uvDhgvPOxiDp5YEdxqSue/7ylzjBdKecDyLgTSDDf/p+FwIx5B\n2d/0uRgQBaAk6D/DNOvN8GrYyakFmlDjE72nrBGAJq50UyV6THOSDk+8cK+2QiS1\nEDCFufj+7Dk1EBfBFUFY8ZBB/pphpEWyLoFl7NzGCQKBgQDaj/KOOcj6BkkTj1WM\nRW3KhOE3nhsCQEgQGCflpycEAZj6J7ktBG2/4teDt9sr+Epx8ymnQCZa9pmysdrD\nU0aWku1qUx0IUKTtZbAEbB+AnrWYDYkIWU8kRUUvNHNTBg43VyuohV9wprPih138\nHWMeNac82/XICz2A3rv+Xkx8KwKBgQDPaaEEGWVs3nIhf/p3M3/xWNKt8fhAERpG\n0YpTjgHW3FQFYjiCTTIcuLO3qsDGmfIAB9tL37s2Y3e2wKBGUj/o69Fr7sWVPdsX\nJtUc0+KiG2Bs0hsyZPdk9UQiQX8y2eq1NZW7vEoxWso1bM64WURB5N8ocWePNJJx\nL2Oe75rtiQKBgQDLfQQOiRxmNF3rOSMkAywyRr9NQgXRdbniSiszNQotP7OHDF7q\n29m2suOGfjIv4O6m4wdf8WkEfd4hsleETc9Ft6wVtyYrrLGxWWCk7WnzHVDjLY7s\n2AHIOjostf+9R8EKoz1BnFN8laibev71EQNMiBWZow1VX6m2hymurWs2mwKBgQCb\nuY3n2v14qOb92e1+U89KsEq1yMd/qpeU9jwqEaO14wS+aglNY5ItWEuuqWhFdE3q\n0ftHUzpnUnUOZD+xrI1JXsyEgegc7i0xi7lUBI3S8kUKTxGWW5IXXcKDCbPrxQtg\ndFPweSUnOyg4xnHKnVMPOjyGS+bZ8TnF+zOLoBAtKQKBgF6hAOIwF1DheXT4p8xS\nlSGhl8dBxjsJDVwbnFWQceGzGnq1e3ncy/UItt42UCDVRWTH4r7pQ9eKyd/3foUD\n6KDIcCrYo2KJh6ZNFJ67XF30U+TuEg5U/9jTbWqDOwYVXcMcnzQE4ZiGBxVHL6xr\nNc8FRW5+7xh4zNfzhGUGt5kt\n-----END PRIVATE KEY-----\n",
"client_email": "crimata-service-account@crimata.iam.gserviceaccount.com",
"client_id": "102914612880037864172",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/crimata-service-account%40crimata.iam.gserviceaccount.com"
}

45
login.svg Normal file
View file

@ -0,0 +1,45 @@
<svg
id="login"
xmlns="http://www.w3.org/2000/svg"
width="350"
height="500"
>
<g transform="translate(-4423 -283)">
<rect
id="background"
width="350"
height="500"
transform="translate(4423 283)"
fill="#ebebeb"
/>
<!-- login Form -->
<g id="loginForm" data-name="Group 540" transform="translate(-7 1)">
<!-- email Box -->
<rect
id="emailBox"
width="161"
height="41"
rx="10"
transform="translate(4525 470)"
fill="#b9b9b9"/>
<!-- password Box -->
<rect id="passwordBox"
width="161"
height="41"
rx="10"
transform="translate(4525 538)"
fill="#b9b9b9"
/>
<text id="Email" transform="translate(4530 523)" font-size="11" font-family="SFCompactDisplay-Bold, SF Compact Display" font-weight="700"><tspan x="0" y="0">Email</tspan></text>
<text id="Password" transform="translate(4530 591)" font-size="11" font-family="SFCompactDisplay-Bold, SF Compact Display" font-weight="700"><tspan x="0" y="0">Password</tspan></text>
</g>
<text id="Login" transform="translate(4518 450)" font-size="20" font-family="SFProText-Bold, SF Pro Text" font-weight="700"><tspan x="0" y="0">Login</tspan></text>
<rect id="Rectangle_1493" data-name="Rectangle 1493" width="120" height="38" rx="19" transform="translate(4538 659)" fill="#58c4fd"/>
<text id="Submit" transform="translate(4571 684)" fill="#fff" font-size="16" font-family="SFCompactDisplay-Bold, SF Compact Display" font-weight="700"><tspan x="0" y="0">Submit</tspan></text>
<text id="Create_account" data-name="Create account" transform="translate(4560 628)" fill="#58c4fd" font-size="11" font-family="SFCompactDisplay-Bold, SF Compact Display" font-weight="700"><tspan x="0" y="0">Create account</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -5,23 +5,22 @@
</template>
<style lang="scss">
html,
body {
margin: 0;
padding: 0;
}
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
width: 100vw;
}
html, body {
margin: 0;
padding: 0;
}
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
width: 100vw;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View file

@ -4,7 +4,6 @@
*/
"use strict";
import { protocol } from "electron";
import { initApp } from './background/initApp';
@ -22,4 +21,4 @@ const isDevelopment = process.env.NODE_ENV !== "production";
console.log('Starting Crimata electron app.');
initApp(isDevelopment);
})();
})();

View file

@ -1,4 +1,3 @@
"use strict";
import { app } from "electron";

View file

@ -12,8 +12,6 @@
</template>
<script lang="ts">
// mock messages
import Messages from "./mockMessages";
// child components
import MessageVisualizer from "./messageVisualizer/index.vue";
@ -23,44 +21,40 @@ import TextAudioInput from "@/components/taInput/index.vue";
import { Mitt } from "@/types/mitt/index";
import { defineComponent, ref, inject } from "vue";
export default defineComponent({
name: "Messenger",
components: { MessageVisualizer, TextAudioInput },
setup() {
const messages = Messages;
const count = ref(0);
// imports mitt Emitter safely
let emitter: Mitt;
const emitterInject: Mitt | undefined = inject("mitt");
if (emitterInject) emitter = emitterInject;
function emittMessage() {
if (count.value < messages.length) {
emitter.emit("renderMessage", messages[count.value]);
count.value++;
return;
}
if (emitterInject) {
emitter = emitterInject;
}
// Render message when render-message event called.
window.ipcRenderer.on("render-message", (event, payload) => {
console.log(payload.message);
emitter.emit("renderMessage", payload.message);
});
return {
emittMessage,
};
},
});
</script>
<style lang="scss" scoped>
#messenger {
width: 350px;
height: 500px;
background-color: #e6e6e6;
box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.3);
// border-radius: 20px;
}
#messenger {
width: 350px;
height: 500px;
background-color: #e6e6e6;
box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.3);
// border-radius: 20px;
}
</style>

View file

@ -0,0 +1,95 @@
<template>
<div id="login">
<!-- login title -->
<div id="loginTitle">Login</div>
<!-- username and password forms -->
<div id="loginBox">
<!-- username -->
<input
class="input"
type="text"
v-model="login.username"
placeholder="username"
/>
<!-- password -->
<input
class="input"
type="password"
v-model="login.password"
placeholder="Password"
/>
</div>
<!-- submit button -->
<button class="button" v-on:click="submitCreds">Submit</button>
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
name: "Login",
data: function() {
return {
login: {
username: "",
password: ""
}
};
}
});
</script>
<style lang="scss" scoped>
#login {
width: 350px;
height: 500px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #e6e6e6;
}
#loginBox {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.input {
background-color: #B9B9B9;
border: none;
color: white;
padding: 16px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
border-radius: 10px;
}
.button {
background-color: #58C4FD;
border: none;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 20px;
font-weight: bold;
}
</style>

View file

@ -1,161 +0,0 @@
import { Message } from "@/types/message/index";
const Messages: Message[] = [
{
content: "Welcome",
context: "ai",
subContext: "",
modifier: "ai",
id: "2",
time: ""
},
{
content:
"add friend",
context: "launch",
subContext: "",
modifier: "sf",
id: "1",
time: ""
},
{
content: "Did you mean to addcontact?",
context: "addcontact",
subContext: "",
modifier: "ai",
id: "5",
time: ""
},
{
content: "yes",
context: "fulfill",
subContext: "",
modifier: "sf",
id: "6",
time: ""
},
{
content: "Hey Anna, did you get the paper done?",
context: "Mesage from Tommy McConville",
subContext: "New Conversation",
modifier: "ai",
id: "3",
time: ""
},
{
content: "Hey do you know Enrique Hernandez?",
context: "Message from Crimata",
subContext: "",
modifier: "ai",
id: "7",
time: ""
},
{
content: "Yes posting it online soon.",
context: "You to Tommy McConville",
subContext: "",
modifier: "sf",
id: "4",
time: ""
},
{
content: "Hey do you know Enrique Hernandez?",
context: "Message from Crimata",
subContext: "",
modifier: "ai",
id: "8",
time: ""
},
{
content: "Hey Anna, did you get the paper done?",
context: "Message from Tommy McConville",
subContext: "",
modifier: "ai",
id: "9",
time: ""
},
{
content: "Hey Anna, did you get the paper done?",
context: "Message from Tommy McConville",
subContext: "",
modifier: "ai",
id: "10",
time: ""
},
{
content: "Yes posting it online soon.",
context: "Message from Tommy McConville",
subContext: "",
modifier: "sf",
id: "11",
time: ""
},
{
content:
"I can be there at 5 pm tomorrow to greet you at a Chick file with my almond and chive salad.",
context: "You to Tommy McConville",
subContext: "",
modifier: "sf",
id: "12",
time: ""
},
{
content: "Hey Anna, did you get the paper done?",
context: "Message from Tommy McConville",
subContext: "",
modifier: "ai",
id: "13",
time: ""
},
{
content: "Hey Anna, did you get the paper done?",
context: "Message from Tommy McConville",
subContext: "",
modifier: "ai",
id: "14",
time: ""
},
{
content: "Yes posting it online soon.",
context: "You to Tommy McConville",
subContext: "",
modifier: "sf",
id: "15",
time: ""
},
{
content: "Sweet, thanks!",
context: "Message from Tommy McConville",
subContext: "",
modifier: "ai",
id: "16",
time: ""
},
{
content: "Hey do you know Enrique Hernandez?",
context: "Message from Crimata AI",
subContext: "",
modifier: "ai",
id: "17",
time: ""
},
{
content: "Yes posting it online soon.",
context: "You to Tommy McConville",
subContext: "",
modifier: "sf",
id: "18",
time: ""
},
{
content: "Sweet, thanks!",
context: "Message from Tommy McConville",
subContext: "",
modifier: "ai",
id: "19",
time: ""
},
];
export default Messages;

View file

@ -0,0 +1,73 @@
<template>
<div id="splash">
<svg
xmlns="http://www.w3.org/2000/svg"
width="57.046"
height="52.759"
viewBox="0 0 57.046 52.759"
>
<g transform="translate(-4127 -507)">
<g transform="translate(3949 332.206)">
<g transform="translate(178 174.794)">
<g transform="translate(0 27.405)">
<circle
cx="12.677"
cy="12.677"
r="12.677"
transform="translate(0 0)"
fill="#383838"
/>
<circle
cx="12.677"
cy="12.677"
r="12.677"
transform="translate(31.692 0)"
fill="#383838"
/>
</g>
<circle
cx="12.677"
cy="12.677"
r="12.677"
transform="translate(15.822 0)"
fill="#383838"
/>
<path
d="M36.27,83.67"
transform="translate(-23.569 -43.588)"
fill="#ff0"
/>
</g>
</g>
</g>
</svg>
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
name: "Splash",
});
</script>
<style lang="scss" scoped>
#splash {
width: 350px;
height: 500px;
display: flex;
align-items: center;
justify-content: center;
background-color: #EBEBEB;
box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.3);
// border-radius: 20px;
}
</style>

View file

@ -1,127 +0,0 @@
<template>
<defs>
<radialGradient
id="radial-gradient"
cx="0.5"
cy="0.7"
:r="radius"
gradientTransform="translate(-1.489 1.5) rotate(-90) scale(1 1.989)"
gradientUnits="objectBoundingBox"
>
<stop offset="0" stop-color="#fff" />
<stop id="sound" offset="1" stop-color="rgb(230, 230, 230)" />
</radialGradient>
<filter id="Rectangle_410" x="0" y="0" width="380" height="530" filterUnits="userSpaceOnUse">
<feOffset dy="3" input="SourceAlpha" />
<feGaussianBlur stdDeviation="5" result="blur" />
<feFlood flood-opacity="0.129" />
<feComposite operator="in" in2="blur" />
<feComposite in="SourceGraphic" />
</filter>
</defs>
<g transform="matrix(1, 0, 0, 1, 0, 0)" filter="url(#Rectangle_410)">
<rect
id="Rectangle_410-2"
data-name="Rectangle 410"
width="350"
height="500"
fill="url(#radial-gradient)"
/>
</g>
</template>
<script>
import { defineComponent, onMounted, ref, inject, watch } from "vue";
export default defineComponent({
name: "voiceBackground",
setup() {
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const analyzer = audioCtx.createAnalyser();
analyzer.fftSize = 2048;
const xInitial = 24;
const xFinal = 640;
// analyzer.minDecibels = -90;
analyzer.smoothingTimeConstant = 0.85;
const dataArray = new Uint8Array(analyzer.frequencyBinCount);
const sampleRate = 16000;
let gradient;
const radius = ref(0);
const think = ref(false);
const aiOffset = ref(0.7);
const anime = inject("animejs");
let thinkAnimation;
onMounted(() => {
gradient = document.getElementById("radial-gradient");
thinkAnimation = anime({
targets: gradient,
loop: true,
cy: "1.3",
direction: "alternate",
easing: "easeInOutCirc",
});
});
function convertBlock(buffer) {
// incoming data is an ArrayBuffer
const incomingData = new Uint8Array(buffer); // create a uint8 view on the ArrayBuffer
const l = incomingData.length; // length, we need this for the loop
const outputData = new Float32Array(incomingData.length); // create the Float32Array for output
for (let i = 0; i < l; i++) {
outputData[i] = (incomingData[i] - 128) / 128.0; // convert audio to float
}
return outputData; // return the Float32Array
}
window.ipcRenderer.on("render-audio", (event, payload) => {
const floatArray = convertBlock(payload.audio.buffer);
const buffer = audioCtx.createBuffer(1, floatArray.length, sampleRate);
buffer.copyToChannel(floatArray, 0, 0);
const source = audioCtx.createBufferSource();
source.buffer = buffer;
source.connect(analyzer);
source.start();
analyzer.getByteFrequencyData(dataArray);
const dataView = dataArray.slice(xInitial, xFinal);
const sum = dataView.reduce((a, b) => a + b);
const average = sum / dataView.length;
const scaled = average / 255;
const zeroed = scaled - 0.6;
if (zeroed > 0) {
radius.value = zeroed;
}
if (payload.speech === think.value) {
return;
} else {
think.value = payload.speech;
}
});
// watch(think, async (think, prevThink) => {
// if (think) {
// anime({
// targets: gradient,
// cy: "0.7",
// });
// thinkAnimation.play();
// } else {
// thinkAnimation.pause();
// // thinkAnimation.reset();
// anime({
// targets: gradient,
// cy: "1",
// });
//
// // thinkAnimation.reset();
// }
// });
return {
radius,
aiOffset,
};
},
});
</script>

View file

@ -1,16 +1,18 @@
import { createApp } from "vue";
// src/main.ts
import App from "./App.vue";
import router from "./router";
// animation library
import anime from "animejs";
// event handler library
import mitt from "mitt";
import anime from "animejs";
import { createApp } from "vue";
// Handle events.
const emitter = mitt();
createApp(App)
.use(router)
.provide("animejs", anime)
.provide("mitt", emitter)
.mount("#app");
const app = createApp(App)
app.use(router)
app.provide("animejs", anime)
app.provide("mitt", emitter)
app.mount("#app");

View file

@ -7,10 +7,13 @@ declare global {
ipcRenderer: typeof ipcRenderer;
}
}
window.ipcRenderer = ipcRenderer;
process.once("loaded", () => {
window.addEventListener("message", event => {
// do something with custom event
const message = event.data;
@ -25,6 +28,11 @@ process.once("loaded", () => {
if (message.myTypeField === "update-recorder") {
ipcRenderer.send("update-recorder", message.record);
}
});
});
if (message.myTypeField === "submit-creds") {
ipcRenderer.send("submit-creds", message)
}
});
});

40
src/router.ts Normal file
View file

@ -0,0 +1,40 @@
import {
createRouter,
createWebHistory,
createWebHashHistory,
RouteRecordRaw
} from "vue-router";
import Home from "./views/home.vue";
import Login from "./views/login.vue";
import Splash from "./views/splash.vue";
// Define the routes (/*) for the app here.
const routes: Array<RouteRecordRaw> = [
{
path: "/sdf",
name: "Splash",
component: Splash
},
{
path: "/sdf",
name: "Home",
component: Home
},
{
path: "/",
name: "Login",
component: Login
},
];
const router = createRouter({
history: process.env.IS_ELECTRON ? createWebHashHistory() : createWebHistory(process.env.BASE_URL),
routes
});
export default router;

View file

@ -1,17 +0,0 @@
import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from "vue-router";
import HomeIndex from "../views/home/index.vue";
const routes: Array<RouteRecordRaw> = [
{
path: "/",
name: "Home",
component: HomeIndex
},
];
const router = createRouter({
history: process.env.IS_ELECTRON ? createWebHashHistory() : createWebHistory(process.env.BASE_URL),
routes
});
export default router;

17
src/views/home.vue Normal file
View file

@ -0,0 +1,17 @@
<template>
<HomeComponent />
</template>
<script lang="ts">
import { defineComponent } from "vue";
import HomeComponent from "@/components/home/index.vue";
export default defineComponent({
name: "Home",
components: { HomeComponent },
});
</script>

View file

@ -1,12 +0,0 @@
<template>
<Messenger />
</template>
<script lang="ts">
import { defineComponent } from "vue";
import Messenger from "@/components/messenger/index.vue";
export default defineComponent({
name: "HomeIndex",
components: { Messenger },
});
</script>

17
src/views/login.vue Normal file
View file

@ -0,0 +1,17 @@
<template>
<LoginComponent />
</template>
<script lang="ts">
import { defineComponent } from "vue";
import LoginComponent from "@/components/login/index.vue";
export default defineComponent({
name: "Login",
components: { LoginComponent },
});
</script>

17
src/views/splash.vue Normal file
View file

@ -0,0 +1,17 @@
<template>
<SplashComponent />
</template>
<script lang="ts">
import { defineComponent } from "vue";
import SplashComponent from "@/components/splash/index.vue"
export default defineComponent({
name: "Splash",
components: { SplashComponent },
});
</script>

View file

@ -2,15 +2,13 @@
const fs = require('fs');
const speech = require('@google-cloud/speech');
const portAudio = require('naudiodon');
// const rs = fs.createReadStream('rawAudio.wav');
const WebSocket = require("ws")
const {Writable} = require('stream');
// Creates a client
const client = new speech.SpeechClient();
// connect to test server
// const ws = new WebSocket("ws://localhost:8080");
// Creates a client const client = new speech.SpeechClient();
const encoding = 'LINEAR16';
const sampleRateHertz = 16000;
const languageCode = 'en-US';
@ -46,11 +44,9 @@ async function transcribeSpeech (audio) {
console.log(`Transcription: ${transcription}`);
}
const audioChunks = [];
let audioInput = [];
// Create an instance of AudioIO with inOptions (defaults are as below), which will return a ReadableStream
let ia = new portAudio.AudioIO({
const ia = new portAudio.AudioIO({
inOptions: {
channelCount: 1,
sampleFormat: 16,

View file

@ -32,6 +32,7 @@
]
},
"include": [
"src/*.ts",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",