mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Merge pull request #97 from Monadical-SAS/yarn-format-experimentation
Installed pre-commit
This commit is contained in:
31
.pre-commit-config.yaml
Normal file
31
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# See https://pre-commit.com for more information
|
||||||
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
repos:
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: yarn-format
|
||||||
|
name: run yarn format
|
||||||
|
language: system
|
||||||
|
entry: bash -c 'cd www && yarn format'
|
||||||
|
pass_filenames: false
|
||||||
|
files: ^www/
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: debug-statements
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: detect-private-key
|
||||||
|
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 5.12.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
args: ["--profile", "black"]
|
||||||
|
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 23.1.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
args: ["--line-length", "120"]
|
||||||
@@ -18,81 +18,81 @@ class CustomRecordPlugin extends RecordPlugin {
|
|||||||
return new CustomRecordPlugin(options || {});
|
return new CustomRecordPlugin(options || {});
|
||||||
}
|
}
|
||||||
render(stream) {
|
render(stream) {
|
||||||
if (!this.wavesurfer) return () => undefined
|
if (!this.wavesurfer) return () => undefined;
|
||||||
|
|
||||||
const container = this.wavesurfer.getWrapper()
|
const container = this.wavesurfer.getWrapper();
|
||||||
const canvas = document.createElement('canvas')
|
const canvas = document.createElement("canvas");
|
||||||
canvas.width = container.clientWidth
|
canvas.width = container.clientWidth;
|
||||||
canvas.height = container.clientHeight
|
canvas.height = container.clientHeight;
|
||||||
canvas.style.zIndex = '10'
|
canvas.style.zIndex = "10";
|
||||||
container.appendChild(canvas)
|
container.appendChild(canvas);
|
||||||
|
|
||||||
const canvasCtx = canvas.getContext('2d')
|
const canvasCtx = canvas.getContext("2d");
|
||||||
const audioContext = new AudioContext()
|
const audioContext = new AudioContext();
|
||||||
const source = audioContext.createMediaStreamSource(stream)
|
const source = audioContext.createMediaStreamSource(stream);
|
||||||
const analyser = audioContext.createAnalyser()
|
const analyser = audioContext.createAnalyser();
|
||||||
analyser.fftSize = 2 ** 5
|
analyser.fftSize = 2 ** 5;
|
||||||
source.connect(analyser)
|
source.connect(analyser);
|
||||||
const bufferLength = analyser.frequencyBinCount
|
const bufferLength = analyser.frequencyBinCount;
|
||||||
const dataArray = new Uint8Array(bufferLength)
|
const dataArray = new Uint8Array(bufferLength);
|
||||||
|
|
||||||
let animationId, previousTimeStamp;
|
let animationId, previousTimeStamp;
|
||||||
const BUFFER_SIZE = 2 ** 8
|
const BUFFER_SIZE = 2 ** 8;
|
||||||
const dataBuffer = new Array(BUFFER_SIZE).fill(canvas.height)
|
const dataBuffer = new Array(BUFFER_SIZE).fill(canvas.height);
|
||||||
|
|
||||||
const drawWaveform = (timeStamp) => {
|
const drawWaveform = (timeStamp) => {
|
||||||
if (!canvasCtx) return
|
if (!canvasCtx) return;
|
||||||
|
|
||||||
analyser.getByteTimeDomainData(dataArray)
|
analyser.getByteTimeDomainData(dataArray);
|
||||||
canvasCtx.clearRect(0, 0, canvas.width, canvas.height)
|
canvasCtx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
canvasCtx.fillStyle = '#cc3347'
|
canvasCtx.fillStyle = "#cc3347";
|
||||||
|
|
||||||
if (previousTimeStamp === undefined) {
|
if (previousTimeStamp === undefined) {
|
||||||
previousTimeStamp = timeStamp
|
previousTimeStamp = timeStamp;
|
||||||
dataBuffer.push(Math.min(...dataArray))
|
dataBuffer.push(Math.min(...dataArray));
|
||||||
dataBuffer.splice(0, 1)
|
dataBuffer.splice(0, 1);
|
||||||
}
|
}
|
||||||
const elapsed = timeStamp - previousTimeStamp;
|
const elapsed = timeStamp - previousTimeStamp;
|
||||||
if (elapsed > 10) {
|
if (elapsed > 10) {
|
||||||
previousTimeStamp = timeStamp
|
previousTimeStamp = timeStamp;
|
||||||
dataBuffer.push(Math.min(...dataArray))
|
dataBuffer.push(Math.min(...dataArray));
|
||||||
dataBuffer.splice(0, 1)
|
dataBuffer.splice(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
const sliceWidth = canvas.width / dataBuffer.length
|
const sliceWidth = canvas.width / dataBuffer.length;
|
||||||
let x = 0
|
let x = 0;
|
||||||
|
|
||||||
for (let i = 0; i < dataBuffer.length; i++) {
|
for (let i = 0; i < dataBuffer.length; i++) {
|
||||||
const valueNormalized = dataBuffer[i] / canvas.height
|
const valueNormalized = dataBuffer[i] / canvas.height;
|
||||||
const y = valueNormalized * canvas.height / 2
|
const y = (valueNormalized * canvas.height) / 2;
|
||||||
const sliceHeight = canvas.height + 1 - y * 2
|
const sliceHeight = canvas.height + 1 - y * 2;
|
||||||
|
|
||||||
canvasCtx.fillRect(x, y, sliceWidth * 2 / 3, sliceHeight)
|
canvasCtx.fillRect(x, y, (sliceWidth * 2) / 3, sliceHeight);
|
||||||
x += sliceWidth
|
x += sliceWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
animationId = requestAnimationFrame(drawWaveform)
|
animationId = requestAnimationFrame(drawWaveform);
|
||||||
}
|
};
|
||||||
|
|
||||||
drawWaveform()
|
drawWaveform();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (animationId) {
|
if (animationId) {
|
||||||
cancelAnimationFrame(animationId)
|
cancelAnimationFrame(animationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
source.disconnect()
|
source.disconnect();
|
||||||
source.mediaStream.getTracks().forEach((track) => track.stop())
|
source.mediaStream.getTracks().forEach((track) => track.stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audioContext) {
|
if (audioContext) {
|
||||||
audioContext.close()
|
audioContext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas?.remove()
|
canvas?.remove();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
startRecording(stream) {
|
startRecording(stream) {
|
||||||
this.preventInteraction();
|
this.preventInteraction();
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import { Mulberry32 } from "../utils.js";
|
import { Mulberry32 } from "../utils.js";
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faChevronRight, faChevronDown } from '@fortawesome/free-solid-svg-icons'
|
import {
|
||||||
|
faChevronRight,
|
||||||
|
faChevronDown,
|
||||||
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
|
|
||||||
export function Dashboard({
|
export function Dashboard({
|
||||||
isRecording,
|
isRecording,
|
||||||
@@ -47,7 +50,6 @@ export function Dashboard({
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
||||||
{finalSummary && (
|
{finalSummary && (
|
||||||
<div className="mt-2 p-2 bg-white temp-transcription rounded">
|
<div className="mt-2 p-2 bg-white temp-transcription rounded">
|
||||||
<h2>Final Summary</h2>
|
<h2>Final Summary</h2>
|
||||||
|
|||||||
@@ -7,27 +7,28 @@ import "react-dropdown/style.css";
|
|||||||
|
|
||||||
import CustomRecordPlugin from "./CustomRecordPlugin";
|
import CustomRecordPlugin from "./CustomRecordPlugin";
|
||||||
|
|
||||||
|
|
||||||
const AudioInputsDropdown = (props) => {
|
const AudioInputsDropdown = (props) => {
|
||||||
const [ddOptions, setDdOptions] = useState([]);
|
const [ddOptions, setDdOptions] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
// Request permission to use audio inputs
|
// Request permission to use audio inputs
|
||||||
await navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => stream.getTracks().forEach((t) => t.stop()))
|
await navigator.mediaDevices
|
||||||
|
.getUserMedia({ audio: true })
|
||||||
|
.then((stream) => stream.getTracks().forEach((t) => t.stop()));
|
||||||
|
|
||||||
const devices = await navigator.mediaDevices.enumerateDevices()
|
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||||
const audioDevices = devices
|
const audioDevices = devices
|
||||||
.filter((d) => d.kind === "audioinput" && d.deviceId != "")
|
.filter((d) => d.kind === "audioinput" && d.deviceId != "")
|
||||||
.map((d) => ({ value: d.deviceId, label: d.label }))
|
.map((d) => ({ value: d.deviceId, label: d.label }));
|
||||||
|
|
||||||
if (audioDevices.length < 1) return console.log("no audio input devices")
|
if (audioDevices.length < 1) return console.log("no audio input devices");
|
||||||
|
|
||||||
setDdOptions(audioDevices)
|
setDdOptions(audioDevices);
|
||||||
props.setDeviceId(audioDevices[0].value)
|
props.setDeviceId(audioDevices[0].value);
|
||||||
}
|
};
|
||||||
init()
|
init();
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
const handleDropdownChange = (e) => {
|
const handleDropdownChange = (e) => {
|
||||||
props.setDeviceId(e.value);
|
props.setDeviceId(e.value);
|
||||||
@@ -40,8 +41,8 @@ const AudioInputsDropdown = (props) => {
|
|||||||
value={ddOptions[0]}
|
value={ddOptions[0]}
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
/>
|
/>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default function Recorder(props) {
|
export default function Recorder(props) {
|
||||||
const waveformRef = useRef();
|
const waveformRef = useRef();
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ const useWebRTC = (stream) => {
|
|||||||
duration: serverData.duration,
|
duration: serverData.duration,
|
||||||
summary: serverData.summary,
|
summary: serverData.summary,
|
||||||
},
|
},
|
||||||
text: ''
|
text: "",
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -17,9 +17,8 @@ export default function RootLayout({ children }) {
|
|||||||
<title>Test</title>
|
<title>Test</title>
|
||||||
</Head>
|
</Head>
|
||||||
<body className={roboto.className + " flex flex-col min-h-screen"}>
|
<body className={roboto.className + " flex flex-col min-h-screen"}>
|
||||||
{children}
|
{children}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ const App = () => {
|
|||||||
// transcription, summary, etc
|
// transcription, summary, etc
|
||||||
const serverData = useWebRTC(stream);
|
const serverData = useWebRTC(stream);
|
||||||
|
|
||||||
const sendStopCmd = () => serverData?.peer?.send(JSON.stringify({ cmd: "STOP" }))
|
const sendStopCmd = () =>
|
||||||
|
serverData?.peer?.send(JSON.stringify({ cmd: "STOP" }));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center h-[100svh]">
|
<div className="flex flex-col items-center h-[100svh]">
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: 'standalone',
|
output: "standalone",
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|
||||||
|
|
||||||
// Sentry content below
|
// Sentry content below
|
||||||
|
|
||||||
const { withSentryConfig } = require("@sentry/nextjs");
|
const { withSentryConfig } = require("@sentry/nextjs");
|
||||||
@@ -40,5 +39,5 @@ module.exports = withSentryConfig(
|
|||||||
|
|
||||||
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
||||||
disableLogger: true,
|
disableLogger: true,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "https://github.com/Monadical-SAS/reflector-ui.git",
|
"repository": "https://github.com/Monadical-SAS/reflector-ui.git",
|
||||||
"author": "Koper <andreas@monadical.com>",
|
"author": "Andreas <andreas@monadical.com>",
|
||||||
"license": "MIT",
|
"license": "All Rights Reserved",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.0.0"
|
"prettier": "^3.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ export default function Home() {
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Next, look for the error on the{" "}
|
Next, look for the error on the{" "}
|
||||||
<a href="https://monadical.sentry.io/issues/?project=4505634666577920">Issues Page</a>.
|
<a href="https://monadical.sentry.io/issues/?project=4505634666577920">
|
||||||
|
Issues Page
|
||||||
|
</a>
|
||||||
|
.
|
||||||
</p>
|
</p>
|
||||||
<p style={{ marginTop: "24px" }}>
|
<p style={{ marginTop: "24px" }}>
|
||||||
For more information, see{" "}
|
For more information, see{" "}
|
||||||
|
|||||||
Reference in New Issue
Block a user