diff --git a/js/subtitles.js b/js/subtitles.js index 25dcdd0..54d25b2 100644 --- a/js/subtitles.js +++ b/js/subtitles.js @@ -8,6 +8,8 @@ const defaultPubkey = 'pub-c-fd9b97a4-7b78-4ae1-a21e-3614f2b6debe'; const defaultChannel = uuid(); const defaultMaxWords = 250; const defaultStyle = ''; +const clearTime = +uripart('cleartime') || 4; // Seconds +const introText = uripart('introtext') || 'Start talking.'; const continuous = uripart('continuous') || 'on'; const mic = uripart('mic') || 'on'; const language = uripart('language') || uripart('lang') || null; @@ -32,7 +34,7 @@ function askchannel() { // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Introduction Text // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -setTimeout( e => candidate('Start talking.'), 10 ); +setTimeout( e => candidate(introText), 10 ); // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // UI Elements @@ -91,6 +93,15 @@ function updateSubtitles(speech) { updateSubtitleStyle(subtitleStyle); speech.style = subtitleStyle; subtitles.innerHTML = getMaxWords(speech.phrase); + + // Clear Text after moments of silence. + clearTimeout(updateSubtitles.ival); + updateSubtitles.ival = setTimeout( async ival => { + subtitles.innerHTML = ' '; + spoken.listen.stop(); + listen(); + }, (+clearTime) * 1000 ); + return subtitles.innerHTML; } diff --git a/readme.md b/readme.md index de7d359..15ba15e 100644 --- a/readme.md +++ b/readme.md @@ -94,6 +94,33 @@ Here are some pre-built options to try: Sky is the limit! Enjoy. +## Clear Text on Screen after you stop talking + +We've added a new feature to allow the text to clear from the screen after a +moment of silence. +The default is set to `4 seconds`. +You can change this by setting the following: + +> Don't go lower than 2 seconds. It will cause unexpected problems for you. + + - Clear Text after 2 Seconds: https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?cleartime=2 + - Clear Text after 5 Seconds: https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?cleartime=5 + - Clear Text after 10 Seconds: https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?cleartime=10 + - Clear Text after 100 Seconds: https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?cleartime=100 + +And so on, you can change the value to any valid number. +Just don't go lower than 2 seconds. +Using the default of 4 seconds is recommended. + +## Change Intro Text + +By default the intro text is set to "Start talking." +You can change this value to anything you'd like: + + - Intro Text BLANK: https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?introtext=%20 + - Intro Text "Hello!": https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?introtext=Hello! + - Intro Text "Whatup": https://stephenlb.github.io/twitch-tv-obs-subtitles/subtitles.html?introtext=Whatup + ## Display Last Two Lines Sometimes you don't want a wall of text.