Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <button class="btns" id="play-btn">play</button>
<button class="btns" id="pause-btn">pause</button>
<button class="btns" id="resume-btn">resume</button>
<hr>
<p><a href="https://1-notes.com/javascript-speechsynthesisutterance-pause-and-resume/" target="_blank" rel="noopener">JavaScript | SpeechSynthesisUtteranceで一時停止と再開機能の実装方法 | ONE NOTES</a></p>
              
            
!

CSS

              
                body{
	paddhing:0;
	margin:0;
}

.btns{
	margin: 10px 6px;
	height: 70px;
	width: 70px;
	color: #FFF;
	font-size: 16px;
	background-color: #9E9E9E;
	border: none;
	border-radius: 50%;
	outline: none;
}

              
            
!

JS

              
                //btn
const play_btn = document.querySelector('#play-btn');
const pause_btn = document.querySelector('#pause-btn');
const resume_btn = document.querySelector('#resume-btn');


//play
play_btn.addEventListener( 'click' , play );

function play(){
	
	speechSynthesis.cancel();

	let play_option = new SpeechSynthesisUtterance();
	play_option.text = `吾輩は猫である。名前はまだない。
どこで生れたか頓と見当がつかぬ。何でも薄暗いじめじめした所でニャーニャー泣いていた事だけは記憶している。
吾輩はここで始めて人間というものを見た。しかもあとで聞くとそれは書生という人間中で一番獰悪な種族であったそうだ。この書生というのは時々我々を捕えて煮て食うという話である。
しかしその当時は何という考えもなかったから別段恐しいとも思わなかった。ただ彼の掌に載せられてスーと持ち上げられた時何だかフワフワした感じがあったばかりである。掌の上で少し落ち付いて書生の顔を見たのがいわゆる人間というものの見始めであろう。`;
	play_option.lang = 'ja-JP';
	speechSynthesis.speak(play_option);
};

//pause
pause_btn.addEventListener( 'click' , pause );

function pause(){
	speechSynthesis.pause();
};

//pause
resume_btn.addEventListener( 'click' , resume );

function resume(){
	speechSynthesis.resume();
};
              
            
!
999px

Console