Skip to content

Commit

Permalink
fix transcription
Browse files Browse the repository at this point in the history
  • Loading branch information
kyr0 committed Oct 22, 2024
1 parent c676c60 commit 91a50c2
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 9 deletions.
Binary file not shown.
8 changes: 4 additions & 4 deletions src/components/scratchpad/community/CommunityModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export const CommunityModule: FC<GenericPersistentModuleWrapperProps> = memo(({
<div className="ab-grid ab-grid-cols-2 ab-items-center ab-justify-between ab-mx-auto ab-m-2 ab-ml-3">
<div className="ab-flex ab-items-center ab-justify-start ab-space-x-2">
<PlusIcon className="ab-flex ab-shrink-0 ab-w-8 ab-h-8"/>
<h2 className="ab-text-sm ab-font-bold">Built-in tools</h2>
<h2 className="ab-text-sm ab-font-bold">{t("header_builtin_tools")}</h2>
</div>
<div className="ab-mb-2 ab-flex ab-justify-center ab-items-center ab-gap-2">
<MagnifyingGlassIcon className="ab-flex ab-shrink-0 ab-opacity-50 ab-w-6 ab-h-6" />
<Input
type="text"
placeholder="Type to filter tools..."
placeholder={t("type_to_fitler_tools")}
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="ab-w-full"
Expand Down Expand Up @@ -91,7 +91,7 @@ export const CommunityModule: FC<GenericPersistentModuleWrapperProps> = memo(({
<div className="ab-grid ab-grid-cols-2 ab-items-center ab-justify-between ab-mx-auto ab-m-2 ab-mt-4 ab-ml-3">
<div className="ab-flex ab-items-center ab-justify-start ab-space-x-2">
<BlocksIcon className="ab-flex ab-shrink-0 ab-w-8 ab-h-8"/>
<h2 className="ab-text-sm ab-font-bold">Community tools</h2>
<h2 className="ab-text-sm ab-font-bold">{t("header_community_tools")}</h2>
</div>
<div className="ab-mb-2 ab-flex ab-justify-center ab-items-center ab-gap-2">
<MagnifyingGlassIcon className="ab-flex ab-shrink-0 ab-opacity-50 ab-w-6 ab-h-6" />
Expand Down Expand Up @@ -131,7 +131,7 @@ export const CommunityModule: FC<GenericPersistentModuleWrapperProps> = memo(({
</Card>
))
) : (
<p className="ab-text-center ab-text-gray-500 ab-mt-10">No community tools found.</p>
<p className="ab-text-center ab-text-gray-500 ab-mt-10">{t("no_community_tools_found")}</p>
)}
</div>
</>
Expand Down
50 changes: 45 additions & 5 deletions src/components/transcription/TranscriptionLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { Badge } from "../../ui/badge";
import { filterForVisibleElements } from "../../lib/content-script/element";
import { prefPerPage } from "../../lib/content-script/prefs";
import { formatDuration } from "../../lib/content-script/format";
import { Mic2Icon, PauseCircleIcon } from "lucide-react";
import { Mic2Icon, PauseCircleIcon, PlayIcon } from "lucide-react";
import type { InferenceProviderType, SlicedAudioWavs } from "../../shared";
import { transcribeInWorker } from "../../lib/content-script/transcribe";
import { AiModelDropdown, type ModelPreference } from "../AiModelDropdown";
Expand Down Expand Up @@ -136,6 +136,17 @@ export const TranscriptionLayout = () => {
// New state to track the status of each wavBlob
const [transcriptionStatuses, setTranscriptionStatuses] = useState<Array<'not_started' | 'transcribing' | 'done' | 'error'>>([]);

// New state to track the start time for recording
const [startTime, setStartTime] = useState<number>(0);
const [muted, setMuted] = useState<boolean>(false);

const onToggleMute = useCallback((isMuted: boolean) => {
setMuted(isMuted);
if (selectedMediaElement) {
selectedMediaElement.muted = isMuted
}
}, [selectedMediaElement]);

useEffect(() => {
console.log("supportedCodecs", supportedCodecs);
(async () => {
Expand Down Expand Up @@ -472,7 +483,8 @@ export const TranscriptionLayout = () => {
}

if (!isPlaying) {
selectedMediaElement.currentTime = 0;
selectedMediaElement.muted = muted;
selectedMediaElement.currentTime = startTime * 60; // Use the selected start time
selectedMediaElement.play();
}

Expand Down Expand Up @@ -588,7 +600,7 @@ export const TranscriptionLayout = () => {
}
})();
}
}, [selectedMediaElement]);
}, [selectedMediaElement, startTime, muted]);

const onClearBlobs = useCallback(() => {
setAudioBufferBlobs([]);
Expand Down Expand Up @@ -695,6 +707,32 @@ export const TranscriptionLayout = () => {
</div>
</div>

<div className="ab-flex ab-items-center ab-space-x-2 ab-mt-2">
<input
type="checkbox"
id="muteCheckbox"
className="ab-form-checkbox ab-h-4 ab-w-4"
onChange={(evt) => onToggleMute(evt.target.checked)}
/>
<label htmlFor="muteCheckbox" className="ab-text-sm">
{t("mute_audio")}
</label>
</div>

<div className="ab-flex ab-items-center ab-space-x-2 ab-mt-2">
<label htmlFor="startTimeInput" className="ab-text-sm">
Startzeit (Minute):
</label>
<input
type="number"
id="startTimeInput"
className="ab-form-input ab-h-8 ab-w-16"
value={startTime}
onChange={(e) => setStartTime(Number(e.target.value))}
min="0"
/>
</div>

<CardDescription className="ab-mt-2">
Am Ende der Aufnahme oder wenn Sie die Aufnahme stoppen,
wird die Aufnahme Analysiert und geschnitten.
Expand Down Expand Up @@ -795,7 +833,8 @@ export const TranscriptionLayout = () => {
<AudioPlayer className="w-[100%]" audioBlob={audioBlob!} />
</div>
*/}
<div className="ab-ftr-bg ab-flex ab-flex-row ab-ml-1 ab-justify-between ab-items-center">

<div className="ab-ftr-bg ab-flex ab-flex-row ab-ml-1 ab-justify-between ab-items-center ab-pr-1">
<h5 className="ab-font-bold ab-p-1 ab-px-2 !ab-text-[12px]">
Audio-Abschnitte
</h5>
Expand All @@ -804,8 +843,9 @@ export const TranscriptionLayout = () => {
size={"sm"}
onClick={onTranscribeAll}
disabled={isTranscriptionRunning || audioBufferBlobs.length === 0}
className=""
className="!ab-h-6 ab-m-1 ab-mr-2"
>
<PlayIcon className="ab-mr-2 ab-h-4 ab-w-4" />
Alle Transkribieren
</Button>
)}
Expand Down
12 changes: 12 additions & 0 deletions src/i18n/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@
"module_settings": "Einstellungen",
"module_interview": "Interview",
"module_prose": "Prosa",
"module_rewrite_description": "Lektorieren Sie den Text und verbessern Sie ihn.",
"module_titles_description": "Erhalten Sie Vorschläge für Titel und Untertitel.",
"module_interview_description": "Führen Sie ein Interview und transkribieren Sie es.",
"module_coach_description": "Erhalten Sie Vorschläge für Titel und Untertitel.",
"module_source_description": "Analysieren Sie den Text und erhalten Sie Informationen zu den Quellen.",
"module_translation_description": "Übersetzen Sie den Text in eine andere Sprache.",
"module_prose_description": "Erstellen Sie einen beliebigen Text.",
"mute_audio": "Still",
"type_to_fitler_tools": "Suchen...",
"summaryModule.audiencePromptPlaceholder": "Zielgruppe eingeben",
"summaryModule.audiencePromptLabel": "Zielgruppe",
"summaryModule.tonePromptPlaceholder": "Tonalität eingeben",
"summaryModule.tonePromptLabel": "Tonalität",
"summaryModule.topicCountPromptPlaceholder": "three",
"summaryModule.topicCountPromptLabel": "Anzahl Themen (max)",
"header_builtin_tools": "Integrierte Werkzeuge",
"header_community_tools": "Community-Werkzeuge",
"no_community_tools_found": "Keine Community-Werkzeuge gefunden.",
"feedback.buttonTitle": "💬 Feedback",
"feedback.modalTitle": "💬 Feedback",
"feedback.modalDescription": "Haben Sie Fragen, Ideen oder konstruktive Kritik? Ich freue mich von Ihnen zu hören.",
Expand Down
12 changes: 12 additions & 0 deletions src/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@
"module_titles": "Titele suggestions",
"module_interview": "Interview",
"module_prose": "Prose",
"module_rewrite_description": "Copy edit the text and improve it.",
"module_titles_description": "Get suggestions for titles and subtitles.",
"module_interview_description": "Conduct an interview and transcribe it.",
"module_coach_description": "Get suggestions for titles and subtitles.",
"module_source_description": "Analyze the text and get information about the sources.",
"module_translation_description": "Translate the text into another language.",
"module_prose_description": "Create any text.",
"mute_audio": "Mute",
"type_to_fitler_tools": "Type to filter...",
"no_community_tools_found": "No community tools found.",
"summaryModule.audiencePromptPlaceholder": "Enter the audience",
"summaryModule.audiencePromptLabel": "Audience",
"summaryModule.tonePromptPlaceholder": "Enter the tone",
"summaryModule.tonePromptLabel": "Tone",
"summaryModule.topicCountPromptPlaceholder": "three",
"summaryModule.topicCountPromptLabel": "Topic count (max)",
"header_builtin_tools": "Built-in text tools",
"header_community_tools": "Community text tools",
"feedback.buttonTitle": "💬 Feedback",
"feedback.modalTitle": "💬 Feedback",
"feedback.modalDescription": "Have questions, ideas or constructive critique? I'm eager to hear from you. Just drop me a line, and I'll get back to you personally shortly.",
Expand Down

0 comments on commit 91a50c2

Please sign in to comment.