Skip to content

Commit

Permalink
Simple app to make up words made by free ChatGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
ToonTalk committed Sep 2, 2024
1 parent b10a230 commit 7033cd9
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions apps/new-words-gettysburg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gettysburg Address with Random Words</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}

#speech {
font-size: 1.5em;
margin: 20px 0;
color: #333;
max-width: 800px;
margin-left: auto;
margin-right: auto;
}

button {
padding: 10px 20px;
font-size: 1em;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Gettysburg Address with Random Words</h1>
<div id="speech">Click the button to hear the speech!</div>
<button onclick="saySpeech()">Speak Speech</button>

<script>
function generateWord() {
// Arrays of syllables to combine
const syllables1 = ["na", "ba", "ra", "ki", "mo", "sa", "ta", "fa"];
const syllables2 = ["lo", "ri", "no", "ma", "zu", "pi", "ke", "ya"];
const syllables3 = ["da", "go", "po", "te", "bi", "si", "lu", "mo"];

// Generate a random word by combining random syllables
return syllables1[Math.floor(Math.random() * syllables1.length)] +
syllables2[Math.floor(Math.random() * syllables2.length)] +
syllables3[Math.floor(Math.random() * syllables3.length)];
}

function saySpeech() {
// Original text of the Gettysburg Address (first part)
const originalText = "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.";

// Split the text into words
const words = originalText.split(" ");

// Replace every third word with a randomly generated word
for (let i = 2; i < words.length; i += 3) {
words[i] = generateWord();
}

// Join the modified words into a new string
const modifiedText = words.join(" ");

// Display the modified text
document.getElementById('speech').textContent = modifiedText;

// Use SpeechSynthesis to speak the modified text
const utterance = new SpeechSynthesisUtterance(modifiedText);
utterance.lang = 'en-US';
speechSynthesis.speak(utterance);
}
</script>
</body>
</html>

0 comments on commit 7033cd9

Please sign in to comment.