forked from xenova/whisper-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft: add envoy OK page at / + list notes UI + timestamp in proto struct
- Loading branch information
1 parent
299d601
commit 63700c5
Showing
8 changed files
with
176 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { AudioManager } from "../components/AudioManager"; | ||
import Transcript from "../components/Transcript"; | ||
import { useTranscriber } from "../hooks/useTranscriber"; | ||
|
||
const CreateNote = () => { | ||
const transcriber = useTranscriber(); | ||
|
||
return ( | ||
<div> | ||
<h2 className='mt-3 mb-5 px-4 text-center text-1xl font-semibold tracking-tight text-slate-900 sm:text-2xl'> | ||
Write Notes on the Go! <br /> | ||
ML-powered speech recognition directly in your browser. | ||
</h2> | ||
<AudioManager transcriber={transcriber} /> | ||
<Transcript transcribedData={transcriber.output} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateNote; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useEffect, useState } from "react"; | ||
import { NoteServiceClient } from "../generated/notes.client"; | ||
import { GrpcTransport } from "../services"; | ||
import { Note } from "../generated/notes"; | ||
|
||
const noteClient = new NoteServiceClient(GrpcTransport); | ||
|
||
const ListNotes = () => { | ||
const [groupedNotes, setGroupedNotes] = useState<{ [date: string]: Note[] }>({}); | ||
|
||
useEffect(() => { | ||
const fetchNotes = async () => { | ||
try { | ||
const call = await noteClient.listNotes({}); | ||
if (call.status.code !== 'OK') { | ||
console.warn(call); | ||
return; | ||
} | ||
const sortedNotes = call.response.notes.sort((a, b) => parseInt(b.createdAt) - parseInt(a.createdAt)); | ||
const grouped = sortedNotes.reduce((acc: {[date: string]: Note[]}, note: Note) => { | ||
const date = new Date(parseInt(note.createdAt)).toLocaleDateString(); | ||
if (!acc[date]) { | ||
acc[date] = []; | ||
} | ||
acc[date].push(note); | ||
return acc; | ||
}, {}); | ||
setGroupedNotes(grouped); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
fetchNotes(); | ||
}, []); | ||
|
||
return ( | ||
<div className="p-4"> | ||
<h2 className="text-2xl font-bold mb-4">List of Notes</h2> | ||
{Object.keys(groupedNotes).map(date => ( | ||
<div key={date} className="mb-6"> | ||
<h3 className="text-xl font-bold mb-2">{date}</h3> | ||
<ul className="space-y-4"> | ||
{groupedNotes[date].map(note => ( | ||
<li key={note.id} className="p-4 border rounded shadow"> | ||
<p className="text-lg font-semibold text-gray-600">{new Date(parseInt(note.createdAt)).toLocaleTimeString()}</p> | ||
<p>{note.transcription}</p> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ListNotes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters