diff --git a/Script_Speech_recognition/stranka.html b/Script_Speech_recognition/stranka.html index b024b14..2d00b54 100644 --- a/Script_Speech_recognition/stranka.html +++ b/Script_Speech_recognition/stranka.html @@ -45,9 +45,12 @@ + + + diff --git a/Script_Speech_recognition/video/adresa.mp4 b/Script_Speech_recognition/video/adresa.mp4 deleted file mode 100644 index 220a302..0000000 Binary files a/Script_Speech_recognition/video/adresa.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/alkohol.mp4 b/Script_Speech_recognition/video/alkohol.mp4 deleted file mode 100644 index 90585b9..0000000 Binary files a/Script_Speech_recognition/video/alkohol.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/ambulancia.mp4 b/Script_Speech_recognition/video/ambulancia.mp4 deleted file mode 100644 index 2773b3c..0000000 Binary files a/Script_Speech_recognition/video/ambulancia.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/a.mp4 b/Script_Speech_recognition/video/pismena/a.mp4 deleted file mode 100644 index 676ddd2..0000000 Binary files a/Script_Speech_recognition/video/pismena/a.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/b.mp4 b/Script_Speech_recognition/video/pismena/b.mp4 deleted file mode 100644 index 5edbd20..0000000 Binary files a/Script_Speech_recognition/video/pismena/b.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/c.mp4 b/Script_Speech_recognition/video/pismena/c.mp4 deleted file mode 100644 index 184abfb..0000000 Binary files a/Script_Speech_recognition/video/pismena/c.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ch.mp4 b/Script_Speech_recognition/video/pismena/ch.mp4 deleted file mode 100644 index 106b8c0..0000000 Binary files a/Script_Speech_recognition/video/pismena/ch.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/d.mp4 b/Script_Speech_recognition/video/pismena/d.mp4 deleted file mode 100644 index 78ac55e..0000000 Binary files a/Script_Speech_recognition/video/pismena/d.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/e.mp4 b/Script_Speech_recognition/video/pismena/e.mp4 deleted file mode 100644 index 35d9b5d..0000000 Binary files a/Script_Speech_recognition/video/pismena/e.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/f.mp4 b/Script_Speech_recognition/video/pismena/f.mp4 deleted file mode 100644 index 76486d0..0000000 Binary files a/Script_Speech_recognition/video/pismena/f.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/g.mp4 b/Script_Speech_recognition/video/pismena/g.mp4 deleted file mode 100644 index 5971102..0000000 Binary files a/Script_Speech_recognition/video/pismena/g.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/h.mp4 b/Script_Speech_recognition/video/pismena/h.mp4 deleted file mode 100644 index ff76d2d..0000000 Binary files a/Script_Speech_recognition/video/pismena/h.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/i.mp4 b/Script_Speech_recognition/video/pismena/i.mp4 deleted file mode 100644 index caaff8d..0000000 Binary files a/Script_Speech_recognition/video/pismena/i.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/j.mp4 b/Script_Speech_recognition/video/pismena/j.mp4 deleted file mode 100644 index a3636a5..0000000 Binary files a/Script_Speech_recognition/video/pismena/j.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/k.mp4 b/Script_Speech_recognition/video/pismena/k.mp4 deleted file mode 100644 index fe8049b..0000000 Binary files a/Script_Speech_recognition/video/pismena/k.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/l.mp4 b/Script_Speech_recognition/video/pismena/l.mp4 deleted file mode 100644 index e68c9e7..0000000 Binary files a/Script_Speech_recognition/video/pismena/l.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/m.mp4 b/Script_Speech_recognition/video/pismena/m.mp4 deleted file mode 100644 index 2b5063e..0000000 Binary files a/Script_Speech_recognition/video/pismena/m.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/n.mp4 b/Script_Speech_recognition/video/pismena/n.mp4 deleted file mode 100644 index ea04671..0000000 Binary files a/Script_Speech_recognition/video/pismena/n.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/o.mp4 b/Script_Speech_recognition/video/pismena/o.mp4 deleted file mode 100644 index 3ac4d4d..0000000 Binary files a/Script_Speech_recognition/video/pismena/o.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/p.mp4 b/Script_Speech_recognition/video/pismena/p.mp4 deleted file mode 100644 index 44ea50a..0000000 Binary files a/Script_Speech_recognition/video/pismena/p.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/q.mp4 b/Script_Speech_recognition/video/pismena/q.mp4 deleted file mode 100644 index 083b9a4..0000000 Binary files a/Script_Speech_recognition/video/pismena/q.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/r.mp4 b/Script_Speech_recognition/video/pismena/r.mp4 deleted file mode 100644 index 4d02039..0000000 Binary files a/Script_Speech_recognition/video/pismena/r.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/s.mp4 b/Script_Speech_recognition/video/pismena/s.mp4 deleted file mode 100644 index c36d649..0000000 Binary files a/Script_Speech_recognition/video/pismena/s.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/t.mp4 b/Script_Speech_recognition/video/pismena/t.mp4 deleted file mode 100644 index 4a0cb83..0000000 Binary files a/Script_Speech_recognition/video/pismena/t.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/u.mp4 b/Script_Speech_recognition/video/pismena/u.mp4 deleted file mode 100644 index e48274d..0000000 Binary files a/Script_Speech_recognition/video/pismena/u.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/v.mp4 b/Script_Speech_recognition/video/pismena/v.mp4 deleted file mode 100644 index 0e3464f..0000000 Binary files a/Script_Speech_recognition/video/pismena/v.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/w.mp4 b/Script_Speech_recognition/video/pismena/w.mp4 deleted file mode 100644 index 32f5214..0000000 Binary files a/Script_Speech_recognition/video/pismena/w.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/x.mp4 b/Script_Speech_recognition/video/pismena/x.mp4 deleted file mode 100644 index c8cd276..0000000 Binary files a/Script_Speech_recognition/video/pismena/x.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/y.mp4 b/Script_Speech_recognition/video/pismena/y.mp4 deleted file mode 100644 index 07bdfaa..0000000 Binary files a/Script_Speech_recognition/video/pismena/y.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/z.mp4 b/Script_Speech_recognition/video/pismena/z.mp4 deleted file mode 100644 index 9258f63..0000000 Binary files a/Script_Speech_recognition/video/pismena/z.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/á.mp4 b/Script_Speech_recognition/video/pismena/á.mp4 deleted file mode 100644 index 4fcd40d..0000000 Binary files a/Script_Speech_recognition/video/pismena/á.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ä.mp4 b/Script_Speech_recognition/video/pismena/ä.mp4 deleted file mode 100644 index f665414..0000000 Binary files a/Script_Speech_recognition/video/pismena/ä.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/é.mp4 b/Script_Speech_recognition/video/pismena/é.mp4 deleted file mode 100644 index c100c00..0000000 Binary files a/Script_Speech_recognition/video/pismena/é.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/í.mp4 b/Script_Speech_recognition/video/pismena/í.mp4 deleted file mode 100644 index 3558767..0000000 Binary files a/Script_Speech_recognition/video/pismena/í.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ó.mp4 b/Script_Speech_recognition/video/pismena/ó.mp4 deleted file mode 100644 index e7b6ddd..0000000 Binary files a/Script_Speech_recognition/video/pismena/ó.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ô.mp4 b/Script_Speech_recognition/video/pismena/ô.mp4 deleted file mode 100644 index 9ec77cf..0000000 Binary files a/Script_Speech_recognition/video/pismena/ô.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ú.mp4 b/Script_Speech_recognition/video/pismena/ú.mp4 deleted file mode 100644 index c65ebe0..0000000 Binary files a/Script_Speech_recognition/video/pismena/ú.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ý.mp4 b/Script_Speech_recognition/video/pismena/ý.mp4 deleted file mode 100644 index 6989fa3..0000000 Binary files a/Script_Speech_recognition/video/pismena/ý.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/č.mp4 b/Script_Speech_recognition/video/pismena/č.mp4 deleted file mode 100644 index ba33542..0000000 Binary files a/Script_Speech_recognition/video/pismena/č.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ď.mp4 b/Script_Speech_recognition/video/pismena/ď.mp4 deleted file mode 100644 index 08546a5..0000000 Binary files a/Script_Speech_recognition/video/pismena/ď.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ĺ.mp4 b/Script_Speech_recognition/video/pismena/ĺ.mp4 deleted file mode 100644 index 796218b..0000000 Binary files a/Script_Speech_recognition/video/pismena/ĺ.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ľ.mp4 b/Script_Speech_recognition/video/pismena/ľ.mp4 deleted file mode 100644 index 20b487b..0000000 Binary files a/Script_Speech_recognition/video/pismena/ľ.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ň.mp4 b/Script_Speech_recognition/video/pismena/ň.mp4 deleted file mode 100644 index 5d8ad5f..0000000 Binary files a/Script_Speech_recognition/video/pismena/ň.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ŕ.mp4 b/Script_Speech_recognition/video/pismena/ŕ.mp4 deleted file mode 100644 index 92e94c4..0000000 Binary files a/Script_Speech_recognition/video/pismena/ŕ.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/š.mp4 b/Script_Speech_recognition/video/pismena/š.mp4 deleted file mode 100644 index ca6b0e9..0000000 Binary files a/Script_Speech_recognition/video/pismena/š.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ť.mp4 b/Script_Speech_recognition/video/pismena/ť.mp4 deleted file mode 100644 index b8a46e6..0000000 Binary files a/Script_Speech_recognition/video/pismena/ť.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/video/pismena/ž.mp4 b/Script_Speech_recognition/video/pismena/ž.mp4 deleted file mode 100644 index 7fe8575..0000000 Binary files a/Script_Speech_recognition/video/pismena/ž.mp4 and /dev/null differ diff --git a/Script_Speech_recognition/videoplayer.js b/Script_Speech_recognition/videoplayer.js index ae35e14..addddba 100644 --- a/Script_Speech_recognition/videoplayer.js +++ b/Script_Speech_recognition/videoplayer.js @@ -1,3 +1,9 @@ +import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm'; +const supabaseUrl = 'https://manesldshonpegglmyan.supabase.co' +const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1hbmVzbGRzaG9ucGVnZ2xteWFuIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTczMDcxNzQ2NCwiZXhwIjoyMDQ2MjkzNDY0fQ.saaJeTtwYZCS3YKJYmQsAOSAEFzUVUJnoJSD8-lgLHo' +const supabase = createClient(supabaseUrl, supabaseKey) + +// Select DOM elements const inputText = document.getElementById('inputText'); const videoPlayer = document.getElementById('translationVideo'); const translateWordsBtn = document.getElementById('translateWordsBtn'); @@ -5,15 +11,15 @@ const translateLettersBtn = document.getElementById('translateLettersBtn'); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); const translateBtn = document.getElementById('translateBtn'); // Prelož button +const statusText = document.getElementById('statusText'); +// Translation state variables let videoSequence = []; let currentIndex = 0; let autoPlayEnabled = true; - -// Variable to track the current translation method let currentTranslationMode = 'words'; // Default mode -// Function to check if video exists +// Function to check if video exists (for local testing) async function videoExists(src) { return new Promise(resolve => { const video = document.createElement('video'); @@ -23,30 +29,72 @@ async function videoExists(src) { }); } -// Function to load video sequence by words +// Function to fetch video URL from Supabase by label (for word translation) +async function fetchVideoUrl(word) { + const { data, error } = await supabase + .from('Videa') + .select('video_url') + .eq('label', word) + .maybeSingle(); // Use maybeSingle() instead of single() + + if (error) { + console.error('Error fetching video:', error); + return null; + } + + if (!data) { + console.warn(`No video found for word: ${word}`); + return null; + } + + return data.video_url; +} + + +// Function to load video sequence by words using Supabase async function loadVideoSequenceByWords() { - const words = inputText.value.trim().split(' '); + const words = inputText.value.trim().split(' '); videoSequence = []; for (const word of words) { - const videoSrc = `video/${word.toLowerCase()}.mp4`; - if (await videoExists(videoSrc)) { - videoSequence.push(videoSrc); + const videoUrl = await fetchVideoUrl(word.toLowerCase()); + if (videoUrl) { + videoSequence.push(videoUrl); } } currentIndex = 0; } -// Function to load video sequence by letters +async function fetchLetterVideoUrl(letter) { + const { data, error } = await supabase + .from('Videa') + .select('video_url') + .eq('label', letter) + .maybeSingle(); // Use maybeSingle() for letters + + if (error) { + console.error('Error fetching video for letter:', letter, error); + return null; + } + + if (!data) { + console.warn(`No video found for letter: ${letter}`); + return null; + } + + return data.video_url; +} + +// Function to load video sequence by letters using Supabase async function loadVideoSequenceByLetters() { const characters = inputText.value.trim().split(''); videoSequence = []; for (const char of characters) { if (/[a-zA-Z]/.test(char)) { - const videoSrc = `video/pismena/${char.toLowerCase()}.mp4`; - if (await videoExists(videoSrc)) { - videoSequence.push(videoSrc); + const videoUrl = await fetchLetterVideoUrl(char.toLowerCase()); + if (videoUrl) { + videoSequence.push(videoUrl); } } } @@ -61,9 +109,9 @@ function playVideoAtIndex(index) { videoPlayer.play(); currentIndex = index; - // Update the title with the current letter or word - const currentChar = videoSequence[index].split('/').pop().split('.')[0]; - document.getElementById('currentLetter').innerText = currentChar.toUpperCase(); + // Update the title with the current word or letter + const currentLabel = videoSequence[index].split('/').pop().split('.')[0]; + document.getElementById('currentLetter').innerText = currentLabel.toUpperCase(); if (autoPlayEnabled) { videoPlayer.onended = () => { @@ -83,7 +131,7 @@ function playVideoAtIndex(index) { translateBtn.addEventListener('click', async () => { autoPlayEnabled = true; - // Based on current mode, load the correct video sequence + // Load the video sequence based on the current translation mode if (currentTranslationMode === 'words') { await loadVideoSequenceByWords(); } else if (currentTranslationMode === 'letters') { @@ -92,20 +140,22 @@ translateBtn.addEventListener('click', async () => { if (videoSequence.length > 0) { playVideoAtIndex(currentIndex); + } else { + statusText.innerText = 'No videos found for the entered text.'; } }); // Event listener for "Preložiť po slovách" button translateWordsBtn.addEventListener('click', () => { currentTranslationMode = 'words'; // Set to words mode - translateWordsBtn.classList.add('active'); // Optionally add active class + translateWordsBtn.classList.add('active'); translateLettersBtn.classList.remove('active'); }); // Event listener for "Preložiť po písmenách" button translateLettersBtn.addEventListener('click', () => { currentTranslationMode = 'letters'; // Set to letters mode - translateLettersBtn.classList.add('active'); // Optionally add active class + translateLettersBtn.classList.add('active'); translateWordsBtn.classList.remove('active'); });