import asyncio,sys from playwright.async_api import async_playwright w,kind=sys.argv[1],sys.argv[2] async def main(): async with async_playwright() as p: b=await p.chromium.launch(args=['--autoplay-policy=no-user-gesture-required','--use-fake-device-for-media-stream','--use-fake-ui-for-media-stream',f'--use-file-for-fake-audio-capture=/tmp/fakemic/{w}.wav']) pg=await b.new_page() await pg.goto('http://localhost:8771/index.html');await pg.wait_for_timeout(300) await pg.evaluate("document.getElementById('startBtn').click()");await pg.wait_for_timeout(1500) r=await pg.evaluate(f"""(async()=>{{newTok();const T=tok;const out=[];for(let i=0;i<3;i++){{const x=await listenTake(T,4200);const r=SoundEar.analyze(x,AC.sampleRate,'{kind}');out.push(r.verdict+' '+(x.length/AC.sampleRate).toFixed(1)+'s floor '+mic.floor.toFixed(0))}}return out}})()""") print(w,kind,r) await b.close() asyncio.run(main())