Skip to content

Commit

Permalink
live mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiroyce1 committed Sep 28, 2024
1 parent 753d3c0 commit aeb62c6
Show file tree
Hide file tree
Showing 5 changed files with 450 additions and 0 deletions.
40 changes: 40 additions & 0 deletions live/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../images/gemini.png" type="image/png">
<meta name="description" content="A demo of Google's latest multimodal AI, gemini-1.5-flash">
<link rel="manifest" href="../manifest.json">
<meta name="keywords"
content="google, gemini, image-analysis, gemini-flash, google-ai, gpt, chatgpt, ai, llm, gemini-demo, chiroyce">
<link rel="stylesheet" href="./live.css">
<script type="importmap">
{
"imports": {
"@google/generative-ai": "https://esm.run/@google/generative-ai"
}
}
</script>

<title>Gemini Vision</title>
</head>

<body>
<canvas id="canvas" width="640" height="480" style="display: none;"></canvas>
<video id="webcam" autoplay></video>
<p id="response"></p>
<div class="settings">
<select id="voiceSelect" class="bottom-right">
<option value="default">Default voice</option>
</select><br>
<button id="speak">Speak</button>
<select id="cameraSelect" class="bottom-left"></select>
</div>

</body>

<script src="./live.js" type="module"></script>

</html>
160 changes: 160 additions & 0 deletions live/live.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
* {
font-weight: 300;
font-family: system-ui;
--primary: #588fec;
--bg: #1b1b1b;
--text: #ffffff;
--thickness: 1px;
margin: 0;
padding: 0;
}

@media (prefers-color-scheme: light) {
* {
--primary: #588fec;
--text: #1b1b1b;
--bg: #ffffff;
}

button:hover,
select:hover {
color: var(--bg);
}

img {
background-color: black;
border-radius: 50%;
}
}

html {
margin: 0;
padding: 0;
background-color: var(--bg);
color: var(--text);
}

.settings {
position: fixed;
left: 8px;
bottom: 8px;
display: flex;
gap: 2px;
width: 95vw;
justify-content: center;
align-items: center;
}

#voiceSelect,
#speak,
#cameraSelect {
width: 33.33333%;
}

select {
background-color: var(--bg);
color: var(--text);
cursor: pointer;
text-align: center;
padding: 1em 2em;
border: 1px solid var(--primary);
border-radius: 4px;
font-size: 1em;
width: 100%;
}

button {
cursor: pointer;
width: 100%;
padding: 1em 2em;
background-color: var(--bg);
color: var(--text);
border: var(--thickness) solid var(--primary);
border-radius: 4px;
font-size: 1em;
}

video {
border-radius: 4px;
margin-bottom: 1em;
margin: auto;
}

#response {
position: fixed;
top: 8px;
left: 8px;
font-size: 1.5em;
font-weight: 300;
}

button:hover,
select:hover {
background-color: var(--primary);
transition: all 200ms;
}

input[type="password"] {
background-color: var(--bg);
color: var(--text);
border: var(--thickness) solid var(--primary);
padding: 0.5em;
margin-bottom: 3px;
border-radius: 3px;
}

@media only screen and (max-width: 1000px) {
.stuff {
width: 90vw;
}

textarea {
height: 50px;
}
}

@media only screen and (max-width: 1000px) {
.flex {
flex-direction: column;
align-items: center;
max-width: 95vw;
}

.left,
.right {
height: auto;
width: 90vw;
margin: 0;
}

.stuff {
max-width: 100vw;
margin: auto;
}

.stuff > h1 {
margin-bottom: 1em;
font-size: 2em;
font-weight: 100;
}

textarea {
height: 50px;
}
}

.speech-checkbox {
margin-top: 0.5em;
display: flex;
gap: 1;
justify-content: space-between;
}

.speech-checkbox > input {
cursor: pointer;
}

img {
height: 50px;
transform: translateY(8px) translateX(-6px);
}
Loading

0 comments on commit aeb62c6

Please sign in to comment.