-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple app to make up words made by free ChatGPT
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |