Fixes discussed during call w/ Mathieu

This commit is contained in:
Koper
2023-08-29 21:22:05 +07:00
parent d379dc2376
commit deb713e776
5 changed files with 49 additions and 39 deletions

View File

@@ -35,6 +35,6 @@ body {
@media (max-width: 768px) { @media (max-width: 768px) {
.audio-source-dropdown .Dropdown-control { .audio-source-dropdown .Dropdown-control {
max-width: 90px; max-width: 200px;
} }
} }

View File

@@ -103,7 +103,11 @@ export function Dashboard({
</div> </div>
))} ))}
{topics.length === 0 && ( {topics.length === 0 && (
<div className="text-center text-gray-500">No topics yet</div> <div className="text-center text-gray-500">
Discussion topics will appear here after you start recording. It
may take up to 5 minutes of conversation for the first topic to
appear.
</div>
)} )}
</div> </div>

View File

@@ -26,7 +26,7 @@ const App = () => {
}, []); }, []);
const api = getApi(); const api = getApi();
const transcript = useTranscript(); const transcript = useTranscript(api);
const webRTC = useWebRTC(stream, transcript.response?.id, api); const webRTC = useWebRTC(stream, transcript.response?.id, api);
const webSockets = useWebSockets(transcript.response?.id); const webSockets = useWebSockets(transcript.response?.id);
const { const {

View File

@@ -58,6 +58,7 @@ export default function Recorder(props: RecorderProps) {
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);
const [isRecording, setIsRecording] = useState<boolean>(false); const [isRecording, setIsRecording] = useState<boolean>(false);
const [hasRecorded, setHasRecorded] = useState<boolean>(false);
const [isPlaying, setIsPlaying] = useState<boolean>(false); const [isPlaying, setIsPlaying] = useState<boolean>(false);
const [deviceId, setDeviceId] = useState<string | null>(null); const [deviceId, setDeviceId] = useState<string | null>(null);
const [currentTime, setCurrentTime] = useState<number>(0); const [currentTime, setCurrentTime] = useState<number>(0);
@@ -210,8 +211,7 @@ export default function Recorder(props: RecorderProps) {
props.onStop(); props.onStop();
record.stopRecording(); record.stopRecording();
setIsRecording(false); setIsRecording(false);
const playBtn = document.getElementById("play-btn"); setHasRecorded(true);
if (playBtn) playBtn.removeAttribute("disabled");
} else { } else {
const stream = await props.getAudioStream(deviceId); const stream = await props.getAudioStream(deviceId);
props.setStream(stream); props.setStream(stream);
@@ -236,6 +236,8 @@ export default function Recorder(props: RecorderProps) {
return ( return (
<div className="relative flex flex-col items-center justify-center max-w-[75vw] w-full"> <div className="relative flex flex-col items-center justify-center max-w-[75vw] w-full">
<div className="flex my-2 mx-auto audio-source-dropdown"> <div className="flex my-2 mx-auto audio-source-dropdown">
{!hasRecorded && (
<>
<AudioInputsDropdown <AudioInputsDropdown
audioDevices={props.audioDevices} audioDevices={props.audioDevices}
setDeviceId={setDeviceId} setDeviceId={setDeviceId}
@@ -251,6 +253,11 @@ export default function Recorder(props: RecorderProps) {
{isRecording ? "Stop" : "Record"} {isRecording ? "Stop" : "Record"}
</button> </button>
&nbsp; &nbsp;
</>
)}
{hasRecorded && (
<>
<button <button
className="w-20" className="w-20"
id="play-btn" id="play-btn"
@@ -266,6 +273,8 @@ export default function Recorder(props: RecorderProps) {
> >
<FontAwesomeIcon icon={faDownload} /> <FontAwesomeIcon icon={faDownload} />
</a> </a>
</>
)}
</div> </div>
<div ref={waveformRef} className="w-full shadow-xl rounded-2xl"></div> <div ref={waveformRef} className="w-full shadow-xl rounded-2xl"></div>
<div className="absolute bottom-0 right-2 text-xs text-black"> <div className="absolute bottom-0 right-2 text-xs text-black">

View File

@@ -1,6 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { DefaultApi, V1TranscriptsCreateRequest } from "../api/apis/DefaultApi"; import { DefaultApi, V1TranscriptsCreateRequest } from "../api/apis/DefaultApi";
import { Configuration } from "../api/runtime";
import { GetTranscript } from "../api"; import { GetTranscript } from "../api";
import getApi from "../lib/getApi"; import getApi from "../lib/getApi";
@@ -11,13 +10,11 @@ type UseTranscript = {
createTranscript: () => void; createTranscript: () => void;
}; };
const useTranscript = (): UseTranscript => { const useTranscript = (api: DefaultApi): UseTranscript => {
const [response, setResponse] = useState<GetTranscript | null>(null); const [response, setResponse] = useState<GetTranscript | null>(null);
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const api = getApi();
const createTranscript = () => { const createTranscript = () => {
setLoading(true); setLoading(true);
const requestParameters: V1TranscriptsCreateRequest = { const requestParameters: V1TranscriptsCreateRequest = {