Skip to content

Commit

Permalink
cool
Browse files Browse the repository at this point in the history
  • Loading branch information
adnan wahab committed Oct 23, 2024
1 parent adcab32 commit a7e67b2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 37 deletions.
7 changes: 6 additions & 1 deletion web-ui/my-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Blag = utils.Blag
// });
// }
import { renderToString } from 'react-dom/server'
app.use(logger())
//app.use(logger())
app.all('/odyssey', (c) => {
const content = odyssey()
return c.html(utils.Layout(content))
Expand Down Expand Up @@ -64,6 +64,9 @@ app.all('/iframe/*', (c) => {
let basename = c.req.path.split('/').pop()
console.log('basename', basename)
let html = ''
if (basename == 'livekit_audio.html') {
html = fs.readFileSync('./src/llama-tools/livekit_audio.html', 'utf8')
}
return c.html(html)
})
app.post('/webhook-endpoint', webhook_receiver);
Expand Down Expand Up @@ -120,7 +123,9 @@ app.all('/iframe_observablbehq', async (c) => {
return c.html(data);
})


app.all('/marketing', async (c) => {
//const json = await c.req.parseBody()
return c.json(await send_email())
})

Expand Down
2 changes: 1 addition & 1 deletion web-ui/my-app/src/llama-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const llama_ = `
<!-- Toggle button -->
<button class="mt-4 bg-indigo-600 text-white py-2 px-4 rounded-lg">
Switch to 2 Column Grid
Switch to 2 Column Grid!
</button>
<div class="mt-6 grid grid-cols-1 gap-4">
Expand Down
44 changes: 16 additions & 28 deletions web-ui/my-app/src/llama-tools/livekit_audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
<body>
<h1>Audio Capture with LiveKit</h1>
<button id="startButton">Start Capture</button>
<button id="stopButton" disabled>Stop Capture</button>
<button id="stopButton">Stop Capture</button>
<audio id="audioElm" controls></audio>
<script type="module">
import {
Room,
RemoteParticipant,
LocalAudioTrack,
RoomEvent,
createLocalAudioTrack
} from "https://unpkg.com/livekit-client@latest/dist/livekit-client.esm.mjs?module";

const LiveKit = {
Expand Down Expand Up @@ -69,35 +70,22 @@ <h1>Audio Capture with LiveKit</h1>
console.log('local track published', pub);
});

startButton.addEventListener('click',async () => {
startButton.addEventListener('click', async () => {
console.log('startButton clicked');
const participant = room.localParticipant;

// Since we already have mediaStreamTrack, we can use it directly with LocalAudioTrack
const mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });
const mediaStreamTrack = mediaStream.getAudioTracks()[0];

// Create track from the media stream
const audioTrack = new LocalAudioTrack(mediaStreamTrack, {
echoCancellation: true,
noiseSuppression: true,
});

const participant = room.localParticipant

// Request access to the microphone
const mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });
let mediaStreamTrack = mediaStream.getAudioTracks()[0]; // Get the audio track

const track = new LocalAudioTrack(mediaStreamTrack);

//const pub = await room.localParticipant.publishTrack(mediaStreamTrack)


const audioTrack = await createLocalAudioTrack({
echoCancellation: true,
noiseSuppression: true,
});

//const micPub = parti//cipant.getTrackPublication(audioTrack);
const audioPublication = await room.localParticipant.publishTrack(audioTrack);

// 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);
// Publish the track
const audioPublication = await room.localParticipant.publishTrack(audioTrack);
});

function handleTrackSubscribed(track, publication, participant) {
Expand Down
36 changes: 29 additions & 7 deletions web-ui/my-app/src/marketing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,38 @@ import { Resend } from "resend";
import * as React from "react";


const html = `
i am requesting 6k out of the 7k i lent you. - If it is more easier - you can repay $1000 a month at a time.
const send_email = async () => {
const resend = new Resend();
please fulfill this invoice - i need it for improving manufacturing hardware for robotics for students so that theer can be a dynamic land - which is humane computational medium - effective communication via text is not exactly possible on a large scale like 300 million - the USA only gets 50% approval for its presidents - at most.
A better society is possible - if closer to 90-100% of approval happens on a daily basis - the current system was designed 250 years ago.
Bret Victor and Alan Kay ---- are the ones should lead the future
if you send the funds back today - i will never email you again, and i think thats better for both of us, no hard feelings. Sorry for making mistakes before. Thank you, have a good day.
https://www.paypal.com/invoice/p/#8ZKMMRG5HF8EF2EB
hi this is cool
This is an automated message that will repeat daily until the request has been fufilled
<img src="https://files.hashirama.blog/derp/static_assets/reflect_notion_homage.png" />
<img src="https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2Fdfb574487680e9cea2cd05ca5533a8e5568ec202-1319x1512.gif&w=1920&q=75" />
`;

const send_email = async (json: any) => {
//console.log('json', json)
const _ = 're_gPBiq268_5gRCCNH2bLAwyaXQ6qJ6qLfJ'
const resend = new Resend(_);

return new Response(JSON.stringify(html));
//console.log('resend', json)
const data = await resend.emails.send({
from: "[email protected]",
to: ["[email protected]"],
subject: "Hello from Bun + Resend + React Email 🫓💌",
text: "Hello, Adnan!",
from: "[email protected]",
subject: "Hello - Invoice for $6000/7000 (keep the rest that is fair including interest).",
html: html
});

//console.log('data', data)
return new Response(JSON.stringify(data));
}
export default send_email;
Expand Down

0 comments on commit a7e67b2

Please sign in to comment.