Skip to content

Commit

Permalink
added text clear after silence, added customizeable intro-message.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlb committed May 18, 2020
1 parent 059d295 commit 8d7f8e2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/subtitles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +34,7 @@ function askchannel() {
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Introduction Text
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
setTimeout( e => candidate('Start talking.'), 10 );
setTimeout( e => candidate(introText), 10 );

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// UI Elements
Expand Down Expand Up @@ -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;
}

Expand Down
27 changes: 27 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8d7f8e2

Please sign in to comment.