mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Merge branch 'main' into jose/ui
This commit is contained in:
@@ -225,7 +225,7 @@ From the reflector root folder,
|
|||||||
|
|
||||||
run `python3 whisjax_realtime.py`
|
run `python3 whisjax_realtime.py`
|
||||||
|
|
||||||
The transcription text should be written to `real_time_transcription_<timestamp>.txt`.
|
The transcription text should be written to `real_time_transcription_<timestamp>.txt`
|
||||||
|
|
||||||
NEXT STEPS:
|
NEXT STEPS:
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ This data is then returned from the `useWebRTC` hook and can be used in your com
|
|||||||
|
|
||||||
To generate the TypeScript files from the openapi.json file, make sure the python server is running, then run:
|
To generate the TypeScript files from the openapi.json file, make sure the python server is running, then run:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
yarn openapi
|
yarn openapi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
18
www/app/lib/custom-plugins/regions.ts
Normal file
18
www/app/lib/custom-plugins/regions.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Source code: https://github.com/katspaugh/wavesurfer.js/blob/fa2bcfe/src/plugins/regions.ts
|
||||||
|
|
||||||
|
import RegionsPlugin, {
|
||||||
|
RegionsPluginOptions,
|
||||||
|
} from "wavesurfer.js/dist/plugins/regions";
|
||||||
|
|
||||||
|
class CustomRegionsPlugin extends RegionsPlugin {
|
||||||
|
public static create(options?: RegionsPluginOptions) {
|
||||||
|
return new CustomRegionsPlugin(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(options?: RegionsPluginOptions) {
|
||||||
|
super(options);
|
||||||
|
this["avoidOverlapping"] = () => {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CustomRegionsPlugin;
|
||||||
@@ -16,6 +16,10 @@ type DashboardProps = {
|
|||||||
finalSummary: FinalSummaryType;
|
finalSummary: FinalSummaryType;
|
||||||
topics: Topic[];
|
topics: Topic[];
|
||||||
disconnected: boolean;
|
disconnected: boolean;
|
||||||
|
useActiveTopic: [
|
||||||
|
Topic | null,
|
||||||
|
React.Dispatch<React.SetStateAction<Topic | null>>,
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function Dashboard({
|
export function Dashboard({
|
||||||
@@ -23,8 +27,9 @@ export function Dashboard({
|
|||||||
finalSummary,
|
finalSummary,
|
||||||
topics,
|
topics,
|
||||||
disconnected,
|
disconnected,
|
||||||
|
useActiveTopic,
|
||||||
}: DashboardProps) {
|
}: DashboardProps) {
|
||||||
const [openIndex, setOpenIndex] = useState<number | null>(null);
|
const [activeTopic, setActiveTopic] = useActiveTopic;
|
||||||
const [autoscrollEnabled, setAutoscrollEnabled] = useState<boolean>(true);
|
const [autoscrollEnabled, setAutoscrollEnabled] = useState<boolean>(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -51,7 +56,7 @@ export function Dashboard({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="relative h-[60svh] w-3/4 flex flex-col">
|
<div className="relative h-[64svh] w-3/4 flex flex-col">
|
||||||
<div className="text-center pb-1 pt-4">
|
<div className="text-center pb-1 pt-4">
|
||||||
<h1 className="text-2xl font-bold text-blue-500">Meeting Notes</h1>
|
<h1 className="text-2xl font-bold text-blue-500">Meeting Notes</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,18 +80,24 @@ export function Dashboard({
|
|||||||
<div key={index} className="border-b-2 py-2 hover:bg-[#8ec5fc30]">
|
<div key={index} className="border-b-2 py-2 hover:bg-[#8ec5fc30]">
|
||||||
<div
|
<div
|
||||||
className="flex justify-between items-center cursor-pointer px-4"
|
className="flex justify-between items-center cursor-pointer px-4"
|
||||||
onClick={() => setOpenIndex(openIndex === index ? null : index)}
|
onClick={() =>
|
||||||
|
setActiveTopic(activeTopic?.id == item.id ? null : item)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className="w-1/4">{formatTime(item.timestamp)}</div>
|
<div className="w-1/4">{formatTime(item.timestamp)}</div>
|
||||||
<div className="w-3/4 flex justify-between items-center">
|
<div className="w-3/4 flex justify-between items-center">
|
||||||
{item.title}
|
{item.title}
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
className={`transform transition-transform duration-200`}
|
className={`transform transition-transform duration-200`}
|
||||||
icon={openIndex === index ? faChevronDown : faChevronRight}
|
icon={
|
||||||
|
activeTopic?.id == item.id
|
||||||
|
? faChevronDown
|
||||||
|
: faChevronRight
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{openIndex === index && (
|
{activeTopic?.id == item.id && (
|
||||||
<div className="p-2 mt-2 -mb-2 bg-slate-50 rounded">
|
<div className="p-2 mt-2 -mb-2 bg-slate-50 rounded">
|
||||||
{item.transcript}
|
{item.transcript}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ import useTranscript from "../useTranscript";
|
|||||||
import { useWebSockets } from "../useWebSockets";
|
import { useWebSockets } from "../useWebSockets";
|
||||||
import useAudioDevice from "../useAudioDevice";
|
import useAudioDevice from "../useAudioDevice";
|
||||||
import "../../styles/button.css";
|
import "../../styles/button.css";
|
||||||
|
import { Topic } from "../webSocketTypes";
|
||||||
import getApi from "../../lib/getApi";
|
import getApi from "../../lib/getApi";
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [stream, setStream] = useState<MediaStream | null>(null);
|
const [stream, setStream] = useState<MediaStream | null>(null);
|
||||||
const [disconnected, setDisconnected] = useState<boolean>(false);
|
const [disconnected, setDisconnected] = useState<boolean>(false);
|
||||||
|
const useActiveTopic = useState<Topic | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (process.env.NEXT_PUBLIC_ENV === "development") {
|
if (process.env.NEXT_PUBLIC_ENV === "development") {
|
||||||
@@ -48,6 +50,7 @@ const App = () => {
|
|||||||
}}
|
}}
|
||||||
getAudioStream={getAudioStream}
|
getAudioStream={getAudioStream}
|
||||||
audioDevices={audioDevices}
|
audioDevices={audioDevices}
|
||||||
|
topics={webSockets.topics}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Dashboard
|
<Dashboard
|
||||||
@@ -55,6 +58,7 @@ const App = () => {
|
|||||||
finalSummary={webSockets.finalSummary}
|
finalSummary={webSockets.finalSummary}
|
||||||
topics={webSockets.topics}
|
topics={webSockets.topics}
|
||||||
disconnected={disconnected}
|
disconnected={disconnected}
|
||||||
|
useActiveTopic={useActiveTopic}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useRef, useEffect, useState } from "react";
|
|||||||
|
|
||||||
import WaveSurfer from "wavesurfer.js";
|
import WaveSurfer from "wavesurfer.js";
|
||||||
import RecordPlugin from "../lib/custom-plugins/record";
|
import RecordPlugin from "../lib/custom-plugins/record";
|
||||||
|
import CustomRegionsPlugin from "../lib/custom-plugins/regions";
|
||||||
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faDownload } from "@fortawesome/free-solid-svg-icons";
|
import { faDownload } from "@fortawesome/free-solid-svg-icons";
|
||||||
@@ -11,11 +12,11 @@ import "react-dropdown/style.css";
|
|||||||
|
|
||||||
import { formatTime } from "../lib/time";
|
import { formatTime } from "../lib/time";
|
||||||
|
|
||||||
const AudioInputsDropdown = (props: {
|
const AudioInputsDropdown: React.FC<{
|
||||||
audioDevices: Option[];
|
audioDevices: Option[];
|
||||||
setDeviceId: React.Dispatch<React.SetStateAction<string | null>>;
|
setDeviceId: React.Dispatch<React.SetStateAction<string | null>>;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
}) => {
|
}> = (props) => {
|
||||||
const [ddOptions, setDdOptions] = useState<Option[]>([]);
|
const [ddOptions, setDdOptions] = useState<Option[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -39,7 +40,7 @@ const AudioInputsDropdown = (props: {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Recorder(props) {
|
export default function Recorder(props: any) {
|
||||||
const waveformRef = useRef<HTMLDivElement>(null);
|
const waveformRef = useRef<HTMLDivElement>(null);
|
||||||
const [wavesurfer, setWavesurfer] = useState<WaveSurfer | null>(null);
|
const [wavesurfer, setWavesurfer] = useState<WaveSurfer | null>(null);
|
||||||
const [record, setRecord] = useState<RecordPlugin | null>(null);
|
const [record, setRecord] = useState<RecordPlugin | null>(null);
|
||||||
@@ -49,6 +50,13 @@ export default function Recorder(props) {
|
|||||||
const [currentTime, setCurrentTime] = useState<number>(0);
|
const [currentTime, setCurrentTime] = useState<number>(0);
|
||||||
const [timeInterval, setTimeInterval] = useState<number | null>(null);
|
const [timeInterval, setTimeInterval] = useState<number | null>(null);
|
||||||
const [duration, setDuration] = useState<number>(0);
|
const [duration, setDuration] = useState<number>(0);
|
||||||
|
const [waveRegions, setWaveRegions] = useState<CustomRegionsPlugin | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
const [activeTopic, setActiveTopic] = props.useActiveTopic;
|
||||||
|
|
||||||
|
const topicsRef = useRef(props.topics);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const playBtn = document.getElementById("play-btn");
|
const playBtn = document.getElementById("play-btn");
|
||||||
@@ -63,6 +71,7 @@ export default function Recorder(props) {
|
|||||||
hideScrollbar: true,
|
hideScrollbar: true,
|
||||||
autoCenter: true,
|
autoCenter: true,
|
||||||
barWidth: 2,
|
barWidth: 2,
|
||||||
|
height: 90,
|
||||||
});
|
});
|
||||||
const wsWrapper = _wavesurfer.getWrapper();
|
const wsWrapper = _wavesurfer.getWrapper();
|
||||||
wsWrapper.style.cursor = "pointer";
|
wsWrapper.style.cursor = "pointer";
|
||||||
@@ -78,15 +87,73 @@ export default function Recorder(props) {
|
|||||||
_wavesurfer.on("timeupdate", setCurrentTime);
|
_wavesurfer.on("timeupdate", setCurrentTime);
|
||||||
|
|
||||||
setRecord(_wavesurfer.registerPlugin(RecordPlugin.create()));
|
setRecord(_wavesurfer.registerPlugin(RecordPlugin.create()));
|
||||||
|
setWaveRegions(_wavesurfer.registerPlugin(CustomRegionsPlugin.create()));
|
||||||
|
|
||||||
setWavesurfer(_wavesurfer);
|
setWavesurfer(_wavesurfer);
|
||||||
return () => {
|
return () => {
|
||||||
_wavesurfer.destroy();
|
_wavesurfer.destroy();
|
||||||
setIsRecording(false);
|
setIsRecording(false);
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
|
setCurrentTime(0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
topicsRef.current = props.topics;
|
||||||
|
if (!isRecording) renderMarkers();
|
||||||
|
}, [props.topics]);
|
||||||
|
|
||||||
|
const renderMarkers = () => {
|
||||||
|
if (!waveRegions) return;
|
||||||
|
|
||||||
|
waveRegions.clearRegions();
|
||||||
|
for (let topic of topicsRef.current) {
|
||||||
|
const content = document.createElement("div");
|
||||||
|
content.setAttribute(
|
||||||
|
"style",
|
||||||
|
`
|
||||||
|
position: absolute;
|
||||||
|
border-left: solid 1px orange;
|
||||||
|
padding: 0 2px 0 5px;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
width: 100px;
|
||||||
|
max-width: fit-content;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 0 3px 3px 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
transition: width 100ms linear;
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
content.onmouseover = () => {
|
||||||
|
content.style.backgroundColor = "orange";
|
||||||
|
content.style.zIndex = "999";
|
||||||
|
content.style.width = "300px";
|
||||||
|
};
|
||||||
|
content.onmouseout = () => {
|
||||||
|
content.style.backgroundColor = "white";
|
||||||
|
content.style.zIndex = "0";
|
||||||
|
content.style.width = "100px";
|
||||||
|
};
|
||||||
|
content.textContent = topic.title;
|
||||||
|
|
||||||
|
const region = waveRegions.addRegion({
|
||||||
|
start: topic.timestamp,
|
||||||
|
content,
|
||||||
|
color: "f00",
|
||||||
|
drag: false,
|
||||||
|
});
|
||||||
|
region.on("click", (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setActiveTopic(topic);
|
||||||
|
wavesurfer?.setTime(region.start);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (record) {
|
if (record) {
|
||||||
return record.on("stopRecording", () => {
|
return record.on("stopRecording", () => {
|
||||||
@@ -96,6 +163,7 @@ export default function Recorder(props) {
|
|||||||
link.setAttribute("href", record.getRecordedUrl());
|
link.setAttribute("href", record.getRecordedUrl());
|
||||||
link.setAttribute("download", "reflector-recording.webm");
|
link.setAttribute("download", "reflector-recording.webm");
|
||||||
link.style.visibility = "visible";
|
link.style.visibility = "visible";
|
||||||
|
renderMarkers();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [record]);
|
}, [record]);
|
||||||
@@ -116,6 +184,12 @@ export default function Recorder(props) {
|
|||||||
}
|
}
|
||||||
}, [isRecording]);
|
}, [isRecording]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (activeTopic) {
|
||||||
|
wavesurfer?.setTime(activeTopic.timestamp);
|
||||||
|
}
|
||||||
|
}, [activeTopic]);
|
||||||
|
|
||||||
const handleRecClick = async () => {
|
const handleRecClick = async () => {
|
||||||
if (!record) return console.log("no record");
|
if (!record) return console.log("no record");
|
||||||
|
|
||||||
@@ -128,6 +202,7 @@ export default function Recorder(props) {
|
|||||||
} else {
|
} else {
|
||||||
const stream = await props.getAudioStream(deviceId);
|
const stream = await props.getAudioStream(deviceId);
|
||||||
props.setStream(stream);
|
props.setStream(stream);
|
||||||
|
waveRegions?.clearRegions();
|
||||||
if (stream) {
|
if (stream) {
|
||||||
await record.startRecording(stream);
|
await record.startRecording(stream);
|
||||||
setIsRecording(true);
|
setIsRecording(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user