Skip to content
Om Puter

Om Puter

Berbagi Tutorial Coding dan Pemrograman Komputer

Menu
  • Channel YouTube ThirteeNov
  • Channel YouTube Om Puter
Menu

Contoh sederhana banget dan keren program JavaScript Text To Speech (teks menjadi suara bacaan)

Posted on 2 November 20242 November 2024 by OmPuter

Di bawah ini Om Puter share contoh kode HTML dan JavaScript untuk membuat program Text To Speech sederhana dan sederhananya pake banget.

Ini dia kodenya… Buat file index.html kosong dan copy paste kode di bawah ini:

<!DOCTYPE html>
<html>
	<head>
		<title>Percobaan Text To Speech</title>
		<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
	</head>
	<body>
		
		<input id="bacaini" placeholder="Teks yang dibaca">
		<button onclick="BacaTeks()">Baca Sekarang</button>
		
		<script>
			
			
			
			function BacaTeks(){
				const synth = window.speechSynthesis;
				let text = $("#bacaini").val();
				const utterThis = new SpeechSynthesisUtterance(text);
				utterThis.lang = 'id-ID';
				synth.speak(utterThis);
			}
			
		</script>
		
	</body>
</html>

Source aslinya dari website ini yah, guys: https://www.juannicolas.eu/convert-text-to-speech-with-javascript/

Post Views: 465

Kategori

  • 3D Max
  • Adobe Animate
  • Android
  • c#
  • Cordova
  • HTML5, CSS & JavaScript
  • iOS
  • Lain-lain
  • Photoshop
  • PHP
  • Python
  • Roblox
  • Tak Berkategori
  • Unity
  • WordPress
ciihuy2020
© 2026 Om Puter | Powered by Superbs Personal Blog theme