| import time | |
| from lib.audio import play_audio_until_end | |
| from test_data import audio_clips | |
| if __name__ == '__main__': | |
| # report = Report() | |
| # report.from_logfile("/Users/jeqin/work/code/TestTranslator/logs/0508_zhen.log") | |
| # report.to_csv("/Users/jeqin/work/code/TestTranslator/reports/test.csv") | |
| # electron_app_path = '/Applications/YoYo Translator.app' | |
| # electron_app_path = "/Applications/YoYo\ Translator.app/Contents/MacOS/YoYo\ Translator" | |
| # pros = subprocess.Popen( | |
| # [APP_PATH, f"--remote-debugging-port={DEBUG_PORT}"], | |
| # stdout=subprocess.PIPE, | |
| # stderr=subprocess.PIPE, | |
| # text=True | |
| # ) | |
| # time.sleep(15) # 等待页面加载 | |
| # print(f"{APP_PATH} started") | |
| # # cmd(f"{electron_app_path} --remote-debugging-port=9222") | |
| # # print("cmd finished") | |
| # with sync_playwright() as p: | |
| # # 连接到已开启的 Electron 调试端口 | |
| # browser = p.chromium.connect_over_cdp("http://localhost:9222") | |
| # print(browser.is_connected()) | |
| # context = browser.contexts[0] | |
| # page = context.pages[0] | |
| # print(f"page title: {page.title()}") | |
| # # page.screenshot(path="electron2.png") | |
| # page.get_by_role("switch").click() | |
| # print("clicked switch") | |
| # print(f"page title: {page.title()}") | |
| # time.sleep(2) | |
| # page.screenshot(path="electron1.png") | |
| # | |
| # pros.terminate() | |
| # stdout, stderr = pros.communicate() | |
| # print("\n最终 STDOUT:") | |
| # print(stdout) | |
| # print("\n最终 STDERR:") | |
| # print(stderr) | |
| # p = PageRunner("electron").start() | |
| # p.start_en2zh() | |
| audios = audio_clips.get("zh") | |
| for a in audios: | |
| play_audio_until_end(a) | |
| time.sleep(5) |