Skip to content

Instantly share code, notes, and snippets.

@jasalt
Last active December 3, 2023 22:41
Show Gist options
  • Save jasalt/8174773ffc8abc8c98b328155c4dfc83 to your computer and use it in GitHub Desktop.
Save jasalt/8174773ffc8abc8c98b328155c4dfc83 to your computer and use it in GitHub Desktop.
Selenium audiocraft_plus batch process
# pip install selene
from selene import browser, by, be
from time import sleep
browser.config.base_url = 'http://127.0.0.1:7860'
browser.config.driver_name = 'firefox'
browser.open('/')
def init_settings():
browser.element(by.text('Settings')).click()
els_m = browser.all(by.name('radio-component-118'))
els_m.element(0).click() # Model: melody
els_bm = browser.all(by.name('radio-component-122'))
els_bm.element(2).click() # Base Model: melody (third)
browser.element(by.text('Audio')).click()
# upload file by typing to hidden field
browser.element('input.svelte-izfbkb').send_keys('/Users/user/Documents/Bitwig Studio/Projects/dnb/TODO Banger/cool-dist-arp/cool-dist-arp.wav')
browser.element(by.text('Generation')).click()
browser.element(by.text('Structure Prompts')).click()
browser.element(by.text('Enable')).click()
browser.element('[aria-label="BPM"]').set_value('172') # main text area
browser.element('#component-13 input.svelte-tq78c3').set_value('Major') # main text area
browser.element('#component-13 input.svelte-tq78c3').press_enter() # css "debounce"
browser.element('#component-12 input.svelte-tq78c3').set_value('F') # main text area
browser.element('#component-12 input.svelte-tq78c3').press_enter() # css "debounce"
browser.element('textarea.svelte-1f354aw').set_value("electronica drum and bass liquid") # main text area
browser.element('[aria-label="number input for Duration"]').set_value(44) # set time that is 4X original
def runit():
els_progress = browser.all(".progress-text")
while True:
print("start new generation")
browser.element(by.text('Generate')).click()
sleep(5)
while len(els_progress) > 0:
print("waiting progress to complete")
sleep(5)
init_settings()
runit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment