forked from FujiwaraChoki/MoneyPrinter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update environment variables and video generation script
- Loading branch information
1 parent
17b6aab
commit 3945355
Showing
5 changed files
with
129 additions
and
125 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
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
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
# Environment Variables | ||
|
||
## Required | ||
- ASSEMBLY_AI_API_KEY: Your unique AssemblyAI API key is required. You can obtain one [here](https://www.assemblyai.com/app/) This field is optional; if left empty, the subtitle will be created based on the generated script. | ||
|
||
- TIKTOK_SESSION_ID: Your TikTok session ID is required. Obtain it by logging into TikTok in your browser and copying the value of the `sessionid` cookie. | ||
|
||
- IMAGEMAGICK_BINARY: The filepath to the ImageMagick binary (.exe file) is needed. Obtain it [here](https://imagemagick.org/script/download.php) | ||
- IMAGEMAGICK_BINARY: The filepath to the ImageMagick binary (.exe file) is needed. Obtain it [here](https://imagemagick.org/script/download.php). | ||
|
||
- PEXELS_API_KEY: Your unique Pexels API key is required. Obtain yours [here](https://www.pexels.com/api/) | ||
- PEXELS_API_KEY: Your unique Pexels API key is required. Obtain yours [here](https://www.pexels.com/api/). | ||
|
||
Open an issue if you need help with any of these. | ||
## Optional | ||
|
||
- OPENAI_API_KEY: Your unique OpenAI API key is required. Obtain yours [here](https://platform.openai.com/api-keys), only nessecary if you want to use the OpenAI models. | ||
|
||
* ASSEMBLY_AI_API_KEY: Your unique AssemblyAI API key is required. You can obtain one [here](https://www.assemblyai.com/app/). This field is optional; if left empty, the subtitle will be created based on the generated script. Subtitles can also be created locally. | ||
|
||
Join the [Discord](https://dsc.gg/fuji-community) for support and updates. |
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,116 @@ | ||
const videoSubject = document.querySelector("#videoSubject"); | ||
const aiModel = document.querySelector("#aiModel"); | ||
const voice = document.querySelector("#voice"); | ||
const zipUrl = document.querySelector("#zipUrl"); | ||
const paragraphNumber = document.querySelector("#paragraphNumber"); | ||
const youtubeToggle = document.querySelector("#youtubeUploadToggle"); | ||
const useMusicToggle = document.querySelector("#useMusicToggle"); | ||
const generateButton = document.querySelector("#generateButton"); | ||
const cancelButton = document.querySelector("#cancelButton"); | ||
|
||
const cancelGeneration = () => { | ||
console.log("Canceling generation..."); | ||
// Send request to /cancel | ||
fetch("http://localhost:8080/api/cancel", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
}, | ||
}) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
alert(data.message); | ||
console.log(data); | ||
}) | ||
.catch((error) => { | ||
alert("An error occurred. Please try again later."); | ||
console.log(error); | ||
}); | ||
|
||
// Hide cancel button | ||
cancelButton.classList.add("hidden"); | ||
|
||
// Enable generate button | ||
generateButton.disabled = false; | ||
generateButton.classList.remove("hidden"); | ||
}; | ||
|
||
const generateVideo = () => { | ||
console.log("Generating video..."); | ||
// Disable button and change text | ||
generateButton.disabled = true; | ||
generateButton.classList.add("hidden"); | ||
|
||
// Show cancel button | ||
cancelButton.classList.remove("hidden"); | ||
|
||
// Get values from input fields | ||
const videoSubjectValue = videoSubject.value; | ||
const aiModelValue = aiModel.value; | ||
const voiceValue = voice.value; | ||
const paragraphNumberValue = paragraphNumber.value; | ||
const youtubeUpload = youtubeToggle.checked; | ||
const useMusicToggleState = useMusicToggle.checked; | ||
const zipUrlValue = zipUrl.value; | ||
|
||
const url = "http://localhost:8080/api/generate"; | ||
|
||
// Construct data to be sent to the server | ||
const data = { | ||
videoSubject: videoSubjectValue, | ||
aiModel: aiModelValue, | ||
voice: voiceValue, | ||
paragraphNumber: paragraphNumberValue, | ||
automateYoutubeUpload: youtubeUpload, | ||
useMusic: useMusicToggleState, | ||
zipUrl: zipUrlValue, | ||
}; | ||
|
||
// Send the actual request to the server | ||
fetch(url, { | ||
method: "POST", | ||
body: JSON.stringify(data), | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
}, | ||
}) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
console.log(data); | ||
alert(data.message); | ||
// Hide cancel button after generation is complete | ||
generateButton.disabled = false; | ||
generateButton.classList.remove("hidden"); | ||
cancelButton.classList.add("hidden"); | ||
}) | ||
.catch((error) => { | ||
alert("An error occurred. Please try again later."); | ||
console.log(error); | ||
}); | ||
}; | ||
|
||
generateButton.addEventListener("click", generateVideo); | ||
cancelButton.addEventListener("click", cancelGeneration); | ||
|
||
videoSubject.addEventListener("keyup", (event) => { | ||
if (event.key === "Enter") { | ||
generateVideo(); | ||
} | ||
}); | ||
|
||
// Load the data from localStorage on page load | ||
document.addEventListener("DOMContentLoaded", (event) => { | ||
const voiceSelect = document.getElementById("voice"); | ||
const storedVoiceValue = localStorage.getItem("voiceValue"); | ||
|
||
if (storedVoiceValue) { | ||
voiceSelect.value = storedVoiceValue; | ||
} | ||
}); | ||
|
||
// When the voice select field changes, store the new value in localStorage. | ||
document.getElementById("voice").addEventListener("change", (event) => { | ||
localStorage.setItem("voiceValue", event.target.value); | ||
}); |
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