Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.81 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "import os\n",
  10. "import numpy as np\n",
  11. "import glob\n",
  12. "import shutil\n",
  13. "import datetime"
  14. ]
  15. },
  16. {
  17. "cell_type": "code",
  18. "execution_count": 33,
  19. "metadata": {},
  20. "outputs": [],
  21. "source": [
  22. "done_convert_files_path = [\n",
  23. " glob.glob(os.sep.join([\"..\", \"Voice_Converter_CycleGAN\", \"output_files\", \"*\", \"*.wav\"])),\n",
  24. " # i don't know why. but need this\n",
  25. " glob.glob(os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"b_bak_auto_*\", \"*.wav\"]))\n",
  26. "]"
  27. ]
  28. },
  29. {
  30. "cell_type": "code",
  31. "execution_count": 34,
  32. "metadata": {},
  33. "outputs": [],
  34. "source": [
  35. "done_convert_files_path = [p for d in done_convert_files_path for p in d]"
  36. ]
  37. },
  38. {
  39. "cell_type": "code",
  40. "execution_count": 35,
  41. "metadata": {},
  42. "outputs": [],
  43. "source": [
  44. "done_convert_files_name = [os.path.basename(i) for i in done_convert_files_path]"
  45. ]
  46. },
  47. {
  48. "cell_type": "code",
  49. "execution_count": 36,
  50. "metadata": {},
  51. "outputs": [],
  52. "source": [
  53. "check_not_convert_files_path = [\n",
  54. " glob.glob(os.sep.join([\"..\", \"vc_mix_test\", \"*.wav\"])),\n",
  55. " glob.glob(os.sep.join([\"..\", \"vc_mix_test.bak\", \"*.wav\"])),\n",
  56. " glob.glob(os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"*\", \"*.wav\"])),\n",
  57. " glob.glob(os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"*\", \"*\", \"*.wav\"]))\n",
  58. "]"
  59. ]
  60. },
  61. {
  62. "cell_type": "code",
  63. "execution_count": 37,
  64. "metadata": {},
  65. "outputs": [],
  66. "source": [
  67. "check_not_convert_files_path = [y for x in check_not_convert_files_path for y in x]"
  68. ]
  69. },
  70. {
  71. "cell_type": "code",
  72. "execution_count": 38,
  73. "metadata": {},
  74. "outputs": [],
  75. "source": [
  76. "check_not_convert_files_name = [os.path.basename(i) for i in check_not_convert_files_path]"
  77. ]
  78. },
  79. {
  80. "cell_type": "code",
  81. "execution_count": 39,
  82. "metadata": {},
  83. "outputs": [],
  84. "source": [
  85. "not_convert_files_name = [f for f in check_not_convert_files_name if f not in done_convert_files_name]"
  86. ]
  87. },
  88. {
  89. "cell_type": "code",
  90. "execution_count": 40,
  91. "metadata": {},
  92. "outputs": [],
  93. "source": [
  94. "not_convert_files_path = [p for p in check_not_convert_files_path if os.path.basename(p) in not_convert_files_name]"
  95. ]
  96. },
  97. {
  98. "cell_type": "code",
  99. "execution_count": 41,
  100. "metadata": {
  101. "scrolled": false
  102. },
  103. "outputs": [
  104. {
  105. "data": {
  106. "text/plain": [
  107. "[]"
  108. ]
  109. },
  110. "execution_count": 41,
  111. "metadata": {},
  112. "output_type": "execute_result"
  113. }
  114. ],
  115. "source": [
  116. "not_convert_files_path"
  117. ]
  118. },
  119. {
  120. "cell_type": "code",
  121. "execution_count": 11,
  122. "metadata": {},
  123. "outputs": [],
  124. "source": [
  125. "org_path = os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"b\"])"
  126. ]
  127. },
  128. {
  129. "cell_type": "code",
  130. "execution_count": 12,
  131. "metadata": {},
  132. "outputs": [],
  133. "source": [
  134. "output_files_path = os.sep.join([\"..\", \"Voice_Converter_CycleGAN\", \"output_files\"])"
  135. ]
  136. },
  137. {
  138. "cell_type": "code",
  139. "execution_count": null,
  140. "metadata": {},
  141. "outputs": [],
  142. "source": []
  143. },
  144. {
  145. "cell_type": "code",
  146. "execution_count": 13,
  147. "metadata": {},
  148. "outputs": [],
  149. "source": [
  150. "#把未轉換的檔案放入代轉地區"
  151. ]
  152. },
  153. {
  154. "cell_type": "code",
  155. "execution_count": 14,
  156. "metadata": {},
  157. "outputs": [],
  158. "source": [
  159. "for f in not_convert_files_path:\n",
  160. " shutil.copyfile(f, os.sep.join([org_path, os.path.basename(f)]))"
  161. ]
  162. },
  163. {
  164. "cell_type": "code",
  165. "execution_count": null,
  166. "metadata": {},
  167. "outputs": [],
  168. "source": []
  169. },
  170. {
  171. "cell_type": "code",
  172. "execution_count": 15,
  173. "metadata": {},
  174. "outputs": [],
  175. "source": [
  176. "# 轉換檔案"
  177. ]
  178. },
  179. {
  180. "cell_type": "code",
  181. "execution_count": 16,
  182. "metadata": {},
  183. "outputs": [
  184. {
  185. "name": "stdout",
  186. "output_type": "stream",
  187. "text": [
  188. "\n",
  189. "D:\\code\\start_world>cd D:\\code\\Voice_Converter_CycleGAN \n",
  190. "\n",
  191. "D:\\code\\Voice_Converter_CycleGAN>python.exe convert.py --model_dir=\"./mod/\" --model_name=\"vec\" --data_dir=\"../vae-npvc-kevin-with-1v1/dataset/vcc2016/wav/Testing Set/b/\" --conversion_direction=\"B2A\" --output_dir=\"./output_files/\" \n",
  192. "\n",
  193. "D:\\code\\Voice_Converter_CycleGAN>explorer.exe D:\\code\\Voice_Converter_CycleGAN\\output_files \n"
  194. ]
  195. },
  196. {
  197. "name": "stderr",
  198. "output_type": "stream",
  199. "text": [
  200. "2019-07-12 10:25:43.886483: I T:\\src\\github\\tensorflow\\tensorflow\\core\\platform\\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2\n",
  201. "2019-07-12 10:25:44.064442: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:1356] Found device 0 with properties: \n",
  202. "name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6575\n",
  203. "pciBusID: 0000:01:00.0\n",
  204. "totalMemory: 11.00GiB freeMemory: 9.11GiB\n",
  205. "2019-07-12 10:25:44.064709: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:1435] Adding visible gpu devices: 0\n",
  206. "2019-07-12 10:25:46.186863: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:\n",
  207. "2019-07-12 10:25:46.187015: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:929] 0 \n",
  208. "2019-07-12 10:25:46.187112: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:942] 0: N \n",
  209. "2019-07-12 10:25:46.187723: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8816 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)\n",
  210. "D:\\code\\Voice_Converter_CycleGAN\\preprocess.py:170: RuntimeWarning: divide by zero encountered in log\n",
  211. " f0_converted = np.exp((np.log(f0) - mean_log_src) / std_log_src * std_log_target + mean_log_target)\n"
  212. ]
  213. }
  214. ],
  215. "source": [
  216. "!open_path.bat"
  217. ]
  218. },
  219. {
  220. "cell_type": "code",
  221. "execution_count": null,
  222. "metadata": {},
  223. "outputs": [],
  224. "source": []
  225. },
  226. {
  227. "cell_type": "code",
  228. "execution_count": null,
  229. "metadata": {},
  230. "outputs": [],
  231. "source": []
  232. },
  233. {
  234. "cell_type": "code",
  235. "execution_count": null,
  236. "metadata": {},
  237. "outputs": [],
  238. "source": []
  239. },
  240. {
  241. "cell_type": "code",
  242. "execution_count": 17,
  243. "metadata": {},
  244. "outputs": [],
  245. "source": [
  246. "#把輸出的檔案自動歸類"
  247. ]
  248. },
  249. {
  250. "cell_type": "code",
  251. "execution_count": 18,
  252. "metadata": {},
  253. "outputs": [],
  254. "source": [
  255. "time = datetime.datetime.now()"
  256. ]
  257. },
  258. {
  259. "cell_type": "code",
  260. "execution_count": 19,
  261. "metadata": {},
  262. "outputs": [],
  263. "source": [
  264. "time = (time.year, time.month, time.day, time.hour, time.minute)"
  265. ]
  266. },
  267. {
  268. "cell_type": "code",
  269. "execution_count": 20,
  270. "metadata": {},
  271. "outputs": [],
  272. "source": [
  273. "auto_path = os.sep.join([output_files_path, \"auto_%d_%d_%d-%d_%d\" % time])"
  274. ]
  275. },
  276. {
  277. "cell_type": "code",
  278. "execution_count": 21,
  279. "metadata": {},
  280. "outputs": [],
  281. "source": [
  282. "os.mkdir(auto_path)"
  283. ]
  284. },
  285. {
  286. "cell_type": "code",
  287. "execution_count": 22,
  288. "metadata": {},
  289. "outputs": [],
  290. "source": [
  291. "output_files = glob.glob(os.sep.join([output_files_path, \"*.wav\"]))"
  292. ]
  293. },
  294. {
  295. "cell_type": "code",
  296. "execution_count": 23,
  297. "metadata": {},
  298. "outputs": [],
  299. "source": [
  300. "for f in output_files:\n",
  301. " file_path = os.path.splitext(os.path.basename(f))[0] + \"-to_kevin.wav\"\n",
  302. " shutil.move(f, os.sep.join([auto_path, file_path]))"
  303. ]
  304. },
  305. {
  306. "cell_type": "code",
  307. "execution_count": null,
  308. "metadata": {},
  309. "outputs": [],
  310. "source": []
  311. },
  312. {
  313. "cell_type": "code",
  314. "execution_count": null,
  315. "metadata": {},
  316. "outputs": [],
  317. "source": []
  318. },
  319. {
  320. "cell_type": "code",
  321. "execution_count": null,
  322. "metadata": {},
  323. "outputs": [],
  324. "source": []
  325. },
  326. {
  327. "cell_type": "code",
  328. "execution_count": 24,
  329. "metadata": {},
  330. "outputs": [],
  331. "source": [
  332. "#把輸出完成的檔案保留"
  333. ]
  334. },
  335. {
  336. "cell_type": "code",
  337. "execution_count": 25,
  338. "metadata": {},
  339. "outputs": [],
  340. "source": [
  341. "auto_bak_path = os.sep.join([org_path, \"..\", \"b_bak_auto_%d_%d_%d-%d_%d\" % time])"
  342. ]
  343. },
  344. {
  345. "cell_type": "code",
  346. "execution_count": 26,
  347. "metadata": {},
  348. "outputs": [],
  349. "source": [
  350. "os.mkdir(auto_bak_path)"
  351. ]
  352. },
  353. {
  354. "cell_type": "code",
  355. "execution_count": 27,
  356. "metadata": {},
  357. "outputs": [],
  358. "source": [
  359. "not_bak_files = glob.glob(os.sep.join([org_path, \"*.wav\"]))"
  360. ]
  361. },
  362. {
  363. "cell_type": "code",
  364. "execution_count": 28,
  365. "metadata": {},
  366. "outputs": [],
  367. "source": [
  368. "for f in not_bak_files:\n",
  369. " shutil.move(f, os.sep.join([auto_bak_path, os.path.basename(f)]))"
  370. ]
  371. },
  372. {
  373. "cell_type": "code",
  374. "execution_count": null,
  375. "metadata": {},
  376. "outputs": [],
  377. "source": []
  378. },
  379. {
  380. "cell_type": "code",
  381. "execution_count": null,
  382. "metadata": {},
  383. "outputs": [],
  384. "source": []
  385. },
  386. {
  387. "cell_type": "code",
  388. "execution_count": 29,
  389. "metadata": {},
  390. "outputs": [],
  391. "source": [
  392. "#自動複製到正在作業的資料夾下"
  393. ]
  394. },
  395. {
  396. "cell_type": "code",
  397. "execution_count": null,
  398. "metadata": {},
  399. "outputs": [],
  400. "source": []
  401. },
  402. {
  403. "cell_type": "code",
  404. "execution_count": null,
  405. "metadata": {},
  406. "outputs": [],
  407. "source": []
  408. },
  409. {
  410. "cell_type": "code",
  411. "execution_count": 30,
  412. "metadata": {},
  413. "outputs": [],
  414. "source": [
  415. "now_workshop_path = \"E:\\\\minecraft\\\\隨機編劇\"\n",
  416. "now_kevin_path = \"E:\\\\minecraft\\\\隨機編劇\\\\r2_out_kevin\"\n",
  417. "now_lewis_path = \"E:\\\\minecraft\\\\隨機編劇\\\\r2_org_lewis\"\n",
  418. "now_script_path = \"D:\\\\code\\\\Voice_Converter_CycleGAN\""
  419. ]
  420. },
  421. {
  422. "cell_type": "code",
  423. "execution_count": null,
  424. "metadata": {},
  425. "outputs": [],
  426. "source": []
  427. },
  428. {
  429. "cell_type": "code",
  430. "execution_count": 31,
  431. "metadata": {},
  432. "outputs": [],
  433. "source": [
  434. "auto_kevin_path = os.sep.join([now_script_path, auto_path])\n",
  435. "auto_lewis_path = os.sep.join([now_script_path, auto_bak_path])\n",
  436. "done_auto_copy_kevin_path = os.sep.join([now_kevin_path, os.path.basename(auto_path)])\n",
  437. "done_auto_copy_lewis_path = os.sep.join([now_lewis_path, os.path.basename(auto_bak_path)])\n",
  438. "\n",
  439. "f = open(\"auto_copy.bat\", \"w\")\n",
  440. "f.write(f\"\"\"\n",
  441. "cp -r \"{auto_kevin_path}\" \"{now_kevin_path}\"\n",
  442. "cp -r \"{auto_lewis_path}\" \"{now_lewis_path}\"\n",
  443. "explorer.exe \"{done_auto_copy_kevin_path}\"\n",
  444. "explorer.exe \"{done_auto_copy_lewis_path}\"\n",
  445. "\"\"\")\n",
  446. "f.close()"
  447. ]
  448. },
  449. {
  450. "cell_type": "code",
  451. "execution_count": 32,
  452. "metadata": {},
  453. "outputs": [
  454. {
  455. "name": "stdout",
  456. "output_type": "stream",
  457. "text": [
  458. "\n",
  459. "D:\\code\\start_world>cp -r \"D:\\code\\Voice_Converter_CycleGAN\\..\\Voice_Converter_CycleGAN\\output_files\\auto_2019_7_12-10_26\" \"E:\\minecraft\\隨機編劇\\r2_out_kevin\" \n",
  460. "\n",
  461. "D:\\code\\start_world>cp -r \"D:\\code\\Voice_Converter_CycleGAN\\..\\vae-npvc-kevin-with-1v1\\dataset\\vcc2016\\wav\\Testing Set\\b\\..\\b_bak_auto_2019_7_12-10_26\" \"E:\\minecraft\\隨機編劇\\r2_org_lewis\" \n",
  462. "\n",
  463. "D:\\code\\start_world>explorer.exe \"E:\\minecraft\\隨機編劇\\r2_out_kevin\\auto_2019_7_12-10_26\" \n",
  464. "\n",
  465. "D:\\code\\start_world>explorer.exe \"E:\\minecraft\\隨機編劇\\r2_org_lewis\\b_bak_auto_2019_7_12-10_26\" \n"
  466. ]
  467. }
  468. ],
  469. "source": [
  470. "!auto_copy.bat"
  471. ]
  472. },
  473. {
  474. "cell_type": "code",
  475. "execution_count": null,
  476. "metadata": {},
  477. "outputs": [],
  478. "source": []
  479. },
  480. {
  481. "cell_type": "code",
  482. "execution_count": null,
  483. "metadata": {},
  484. "outputs": [],
  485. "source": []
  486. }
  487. ],
  488. "metadata": {
  489. "kernelspec": {
  490. "display_name": "Python 3",
  491. "language": "python",
  492. "name": "python3"
  493. },
  494. "language_info": {
  495. "codemirror_mode": {
  496. "name": "ipython",
  497. "version": 3
  498. },
  499. "file_extension": ".py",
  500. "mimetype": "text/x-python",
  501. "name": "python",
  502. "nbconvert_exporter": "python",
  503. "pygments_lexer": "ipython3",
  504. "version": "3.6.5"
  505. }
  506. },
  507. "nbformat": 4,
  508. "nbformat_minor": 2
  509. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement