Skip to content

Commit

Permalink
yay
Browse files Browse the repository at this point in the history
  • Loading branch information
adnan wahab committed Oct 22, 2024
1 parent 2539a98 commit e0297a6
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 247 deletions.
23 changes: 22 additions & 1 deletion web-ui/my-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ app.all('/odyssey', (c) => {
return c.html(Layout(odyssey()))
})

app.all('/llama-tools', (c) => {
//Layout(odyssey())
return c.html(Layout(grid()))
})

app.all('/iframe/*', (c) => {
//Layout(odyssey())
let basename = c.req.path.split('/').pop()
console.log('basename', basename)
// fs.readdirSync('./src').forEach(file => {
// console.log(file)
// })
const html = fs.readFileSync('./src/llama-tools/'+ basename, 'utf8')
//let html = 'yay'
return c.html(html)
})
//after 1k signups - lower price to course by 10% by 1k till $5 for life.
//only need 20k per year - (20k / 100) = (goal: 200per year) - rest -> reinveest to hardware
//1 buy per day = all beings (awaken + flourish)
//1000 users is 1000/20 = 50 years of free service.

app.all('/_/TeleGuidance.tsx', async (c) => {
console.log('htmx render ', c.req.path)

Expand Down Expand Up @@ -109,7 +130,7 @@ const Layout = (content: any) => html`
</head>
<body>
<div class="p-4">
<h1 class="text-4xl font-bold mb-4"><a href="/">Robotics Odyssey</a></h1>
<h1 class="text-4xl font-bold mb-4"><a href="/">Robotics Odyssey</a> <a class="float-right" href="https://buy.stripe.com/test_28o6oZelUe8g2HubII">pay via stripe </a></h1>
${content}
</div>
</body>
Expand Down
21 changes: 13 additions & 8 deletions web-ui/my-app/src/llama-tools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export default function Example() {
src="https://tailwindui.com/plus/img/component-images/bento-02-releases.png"
className="h-80 object-cover object-left"
/> */}
<iframe src="/iframe/lama-tools/livekit_audio.html" />
<div className="p-10" hx-get="/-odyssey" hx-trigger="load">
<h3 className="text-sm/4 font-semibold text-gray-400">Releases</h3>
<p className="mt-2 text-lg/7 font-medium tracking-tight text-white">Push to deploy</p>
<p className="mt-2 max-w-lg text-sm/6 text-gray-400">
<h3 className="text-sm/4 font-semibold text-gray-400">livekit audio</h3>
<p className="mt-2 text-lg/7 font-medium tracking-tight text-white">livekit audio</p>
{/* <p className="mt-2 max-w-lg text-sm/6 text-gray-400">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In gravida justo et nulla efficitur, maximus
egestas sem pellentesque.
</p>
</p> */}
</div>
</div>
</div>
Expand All @@ -31,11 +32,13 @@ export default function Example() {
src="https://tailwindui.com/plus/img/component-images/bento-02-integrations.png"
className="h-80 object-cover object-center"
/> */}
<div className="p-10" hx-get="/view/livekit_screen_share.html">
<h3 className="text-sm/4 font-semibold text-gray-400">Integrations</h3>
<p className="mt-2 text-lg/7 font-medium tracking-tight text-white">Connect your favorite tools</p>
<iframe src="/iframe/lama-tools/livekit_share.html" />

<div className="p-10">
{/* <h3 className="text-sm/4 font-semibold text-gray-400"></h3> */}
<p className="mt-2 text-lg/7 font-medium tracking-tight text-white">livekit share</p>
<p className="mt-2 max-w-lg text-sm/6 text-gray-400">
Curabitur auctor, ex quis auctor venenatis, eros arcu rhoncus massa.
{/* Curabitur auctor, ex quis auctor venenatis, eros arcu rhoncus massa. */}
</p>
</div>
</div>
Expand All @@ -47,6 +50,8 @@ export default function Example() {
src="https://tailwindui.com/plus/img/component-images/bento-02-security.png"
className="h-80 object-cover object-center"
/> */}
<iframe src="/iframe/lama-tools/livekit_view_all.html" />

<div className="p-10" hx-get="/view/replay_analyzer.html">
<h3 className="text-sm/4 font-semibold text-gray-400">Security</h3>
<p className="mt-2 text-lg/7 font-medium tracking-tight text-white">Advanced access control</p>
Expand Down
File renamed without changes.
146 changes: 146 additions & 0 deletions web-ui/my-app/src/llama-tools/livekit_audio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!-- web-ui/my-app/src/llama-tools/livekit_audio.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Audio Capture with LiveKit</title>
</head>
<body>
<h1>Audio Capture with LiveKit</h1>
<button id="startButton">Start Capture</button>
<button id="stopButton" disabled>Stop Capture</button>
<audio id="audioElm" controls></audio>
<script type="module">
import {
Room,
RemoteParticipant,
RoomEvent,
} from "https://unpkg.com/livekit-client@latest/dist/livekit-client.esm.mjs?module";
const LiveKit = {
Room,
RemoteParticipant,
RoomEvent,
}

const startButton = document.getElementById('startButton');
const stopButton = document.getElementById('stopButton');
console.log('startButton', startButton)
let room;

async function postLivekitConnect() {
const response = await fetch('/livekit_connect', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ identity: 'screenshare-view-all' }),
});

if (!response.ok) {
console.error('Failed to connect to Livekit:', response.statusText);
return;
}

const data = await response.json();
//console.log('Connected to Livekit:', data);
return data
}
const liveKit_data = await postLivekitConnect();
room = new LiveKit.Room()
room
.on(RoomEvent.TrackSubscribed, handleTrackSubscribed)
.on(RoomEvent.TrackUnsubscribed, handleTrackUnsubscribed)
.on(RoomEvent.ActiveSpeakersChanged, handleActiveSpeakerChange)
.on(RoomEvent.Disconnected, handleDisconnect)
.on(RoomEvent.LocalTrackUnpublished, handleLocalTrackUnpublished);

// connect to room
await room.prepareConnection(liveKit_data.wsUrl, liveKit_data.token);
await room.connect(liveKit_data.wsUrl, liveKit_data.token);
console.log('connected to room', room.name);

// publish local camera and mic tracks
await room.localParticipant.enableCameraAndMicrophone();

room .on(RoomEvent.LocalTrackPublished, (pub) => {
console.log('local track published', pub);
})


startButton.addEventListener('click', () => {
const micPub = participant.getTrackPublication(Track.Source.Microphone);
audioELm.onloadeddata = () => {
if (participant.joinedAt && participant.joinedAt.getTime() < startTime) {
const fromJoin = Date.now() - startTime;
appendLog(`RemoteAudioTrack ${micPub?.trackSid} played ${fromJoin}ms from start`);
}
};
micPub?.audioTrack?.attach(audioElm);


//visual proof






















})


function handleTrackSubscribed(
track,
publication,
participant,
) {
if (track.kind === Track.Kind.Video || track.kind === Track.Kind.Audio) {
// attach it to a new HTMLVideoElement or HTMLAudioElement
const element = track.attach();
parentElement.appendChild(element);
}
}

function handleTrackUnsubscribed(
track,
publication,
participant,
) {
// remove tracks from all attached elements
track.detach();
}

function handleLocalTrackUnpublished(
publication,
participant,
) {
// when local tracks are ended, update UI to remove them from rendering
publication.track.detach();
}

function handleActiveSpeakerChange(speakers) {
// show UI indicators when participant is speaking
}

function handleDisconnect() {
console.log('disconnected from room');
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}

const liveKit_data = await postLivekitConnect();

console.log('liveKit_data', liveKit_data)
async function startLiveKit() {
const url = "wss://omnissiah-university-kmuz0plz.livekit.cloud";
// const data = { identity: "happydream" + Math.random() };
Expand All @@ -145,7 +145,36 @@

// Log local participant
console.log("Local Participant:", room.localParticipant.identity);
document.getElementById('startButton').addEventListener('click', () => {
console.log('startButton clicked')
screeenshare()
})

room.on(RoomEvent.LocalTrackPublished, (pub) => {
console.log('local track published', pub);
renderScreenShare(room);
})



function screeenshare() {
navigator.mediaDevices.getDisplayMedia({ video: true })
.then((stream) => {
// Publish the screen track to the room
const screenTrack = stream.getVideoTracks()[0];
const publication = room.localParticipant.publishTrack(screenTrack);
console.log('Screen sharing started:', publication.trackSid);

// Optionally, you can stop sharing after some time or on a button click
screenTrack.onended = () => {
console.log('Screen sharing stopped');
room.localParticipant.unpublishTrack(screenTrack);
};
})
.catch((error) => {
console.error('Error accessing display media:', error);
});
}
// room.localParticipant.tracks.forEach(publication => {
// console.log(`- Track: ${publication.trackSid}, Kind: ${publication.kind}, Name: ${publication.trackName}`);
// });
Expand Down
1 change: 0 additions & 1 deletion web-ui/my-app/src/views/livekit_audio_voice_agent.html

This file was deleted.

Loading

0 comments on commit e0297a6

Please sign in to comment.