Skip to content

Commit 8213a32

Browse files
committed
(feat:JS): create createTextToSpeech()
1 parent 5e5d27f commit 8213a32

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

public/index.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,9 @@ recipeButtons.forEach((button) => {
203203

204204
///
205205

206-
const audio_data = createAudio(data.audio);
207-
await cacheData(audio_data, CACHE_NAME_AUDIO, "audio");
208-
displayElementsFlex([recording]);
209-
displayElements([sendRecipeToUserInboxBtn, userWantAnotherRecipe]);
210-
const speechBtns = Array.from(document.querySelectorAll(".fa-solid"));
211-
const speedBtn = document.querySelector("#speed");
212-
audioElement.src = createAudio(data.audio);
213-
audioElement.stop = function () {
214-
this.pause();
215-
this.currentTime = 0;
216-
};
206+
// const audio_data = createAudio(data.audio);
207+
// await cacheData(audio_data, CACHE_NAME_AUDIO, "audio");
208+
const { speedBtn, speechBtns } = createTextToSpeech(data);
217209

218210
userWantAnotherRecipe.addEventListener("click", () => {
219211
displayElements([headline, allergies, ...recipeButtons, mainElement]);
@@ -246,6 +238,19 @@ recipeButtons.forEach((button) => {
246238
});
247239
});
248240

241+
function createTextToSpeech(param) {
242+
displayElementsFlex([recording]);
243+
displayElements([sendRecipeToUserInboxBtn, userWantAnotherRecipe]);
244+
const speechBtns = Array.from(document.querySelectorAll(".fa-solid"));
245+
const speedBtn = document.querySelector("#speed");
246+
audioElement.src = createAudio(param.audio);
247+
audioElement.stop = function () {
248+
this.pause();
249+
this.currentTime = 0;
250+
};
251+
return { speedBtn, speechBtns };
252+
}
253+
249254
// Picture section
250255
async function getVideoDevices() {
251256
const devices = await navigator.mediaDevices.enumerateDevices();

public/url_folder.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://oaidalleapiprodscus.blob.core.windows.net/private/org-nYbqgo3O0LNnYYAoKAmApBfx/user-58Je7efi0iy880e2UYCdYpBm/img-FbhNg7YkuHaFXSQuJv6vvc62.png?st=2024-08-02T13%3A27%3A00Z&se=2024-08-02T15%3A27%3A00Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-08-02T07%3A44%3A05Z&ske=2024-08-03T07%3A44%3A05Z&sks=b&skv=2023-11-03&sig=j8PT8RgqGZ9hqT7/zkt1TtdR%2BW4OOsjiW4sd84k3hv8%3D
1+
https://oaidalleapiprodscus.blob.core.windows.net/private/org-nYbqgo3O0LNnYYAoKAmApBfx/user-58Je7efi0iy880e2UYCdYpBm/img-v4eTdg1soovxNTLukfLAet4U.png?st=2024-08-03T12%3A48%3A57Z&se=2024-08-03T14%3A48%3A57Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-08-03T09%3A29%3A53Z&ske=2024-08-04T09%3A29%3A53Z&sks=b&skv=2023-11-03&sig=NOzBmZWL4td4uKehhQo3lpiX8ageP%2BgXh3pp%2BNpLiAg%3D

speech.mp3

502 KB
Binary file not shown.

0 commit comments

Comments
 (0)