generated from nhcarrigan/template
feat: template
This commit is contained in:
+26
-19
@@ -165,7 +165,7 @@ function App() {
|
||||
|
||||
const stopRecording = async () => {
|
||||
try {
|
||||
// Stop the timers
|
||||
// Stop the timers first
|
||||
if (recordingTimer.current) {
|
||||
clearInterval(recordingTimer.current);
|
||||
recordingTimer.current = null;
|
||||
@@ -178,36 +178,43 @@ function App() {
|
||||
setAppState("transcribing");
|
||||
setStatusMessage("Processing final audio...");
|
||||
|
||||
// Process any remaining audio
|
||||
const finalChunk = await invoke<number[]>("get_remaining_audio", {
|
||||
lastOffset: audioOffset.current
|
||||
});
|
||||
|
||||
if (finalChunk.length > 0) {
|
||||
const finalSegments = await invoke<TranscriptSegment[]>("transcribe_chunk", {
|
||||
audioData: finalChunk
|
||||
// First, process any audio that hasn't been processed yet
|
||||
try {
|
||||
const finalChunk = await invoke<number[]>("get_remaining_audio", {
|
||||
lastOffset: audioOffset.current
|
||||
});
|
||||
|
||||
if (finalSegments.length > 0) {
|
||||
const baseTime = totalProcessedSamples.current / 16000;
|
||||
const adjustedSegments = finalSegments.map(seg => ({
|
||||
...seg,
|
||||
start: seg.start + baseTime,
|
||||
end: seg.end + baseTime,
|
||||
}));
|
||||
if (finalChunk.length > 0) {
|
||||
console.log(`Processing final chunk of ${finalChunk.length} samples`);
|
||||
const finalSegments = await invoke<TranscriptSegment[]>("transcribe_chunk", {
|
||||
audioData: finalChunk
|
||||
});
|
||||
|
||||
setTranscriptSegments(prev => [...prev, ...adjustedSegments]);
|
||||
if (finalSegments.length > 0) {
|
||||
const baseTime = totalProcessedSamples.current / 16000;
|
||||
const adjustedSegments = finalSegments.map(seg => ({
|
||||
...seg,
|
||||
start: seg.start + baseTime,
|
||||
end: seg.end + baseTime,
|
||||
}));
|
||||
|
||||
setTranscriptSegments(prev => [...prev, ...adjustedSegments]);
|
||||
}
|
||||
}
|
||||
} catch (chunkError) {
|
||||
console.error("Error processing final chunk:", chunkError);
|
||||
// Continue with stopping even if final chunk fails
|
||||
}
|
||||
|
||||
// Stop the recording
|
||||
await invoke("stop_recording");
|
||||
// Now stop the recording
|
||||
await invoke<string>("stop_recording");
|
||||
|
||||
setAppState("ready");
|
||||
setStatusMessage("");
|
||||
} catch (error) {
|
||||
console.error("Failed to stop recording:", error);
|
||||
setAppState("ready");
|
||||
setStatusMessage("");
|
||||
setErrorMessage(String(error));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user