Skip to content

Commit

Permalink
feat: generate missing audio in bulk
Browse files Browse the repository at this point in the history
  • Loading branch information
NagariaHussain committed Dec 5, 2024
1 parent 344cb17 commit dee09f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// Copyright (c) 2024, BWH and contributors
// For license information, please see license.txt

// frappe.ui.form.on("ElevenLabs Settings", {
// refresh(frm) {

// },
// });
frappe.ui.form.on("ElevenLabs Settings", {
refresh(frm) {
frm.add_custom_button("Generate Missing Audio Files", () => {
frappe.call("listen_to_blog.utils.generate_missing_audio_files").then(() => {
frappe.show_alert({
message: "Successfully generated!",
indicator: "green"
})
})
})
},
});
7 changes: 7 additions & 0 deletions listen_to_blog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ def delete_old_file_if_exists(blog_post):

if exists:
frappe.get_doc("File", {"file_name": file_name}).delete()

@frappe.whitelist()
def generate_missing_audio_files():
posts_with_no_audio = frappe.get_all("Blog Post", filters={"custom_audio": ("is", "not set")}, pluck="name")

for post in posts_with_no_audio:
generate_audio_file_for_blog_post(frappe.get_doc("Blog Post", post))

0 comments on commit dee09f8

Please sign in to comment.