Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import numpy as np\n",
- "import glob\n",
- "import shutil\n",
- "import datetime"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 33,
- "metadata": {},
- "outputs": [],
- "source": [
- "done_convert_files_path = [\n",
- " glob.glob(os.sep.join([\"..\", \"Voice_Converter_CycleGAN\", \"output_files\", \"*\", \"*.wav\"])),\n",
- " # i don't know why. but need this\n",
- " glob.glob(os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"b_bak_auto_*\", \"*.wav\"]))\n",
- "]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 34,
- "metadata": {},
- "outputs": [],
- "source": [
- "done_convert_files_path = [p for d in done_convert_files_path for p in d]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 35,
- "metadata": {},
- "outputs": [],
- "source": [
- "done_convert_files_name = [os.path.basename(i) for i in done_convert_files_path]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 36,
- "metadata": {},
- "outputs": [],
- "source": [
- "check_not_convert_files_path = [\n",
- " glob.glob(os.sep.join([\"..\", \"vc_mix_test\", \"*.wav\"])),\n",
- " glob.glob(os.sep.join([\"..\", \"vc_mix_test.bak\", \"*.wav\"])),\n",
- " glob.glob(os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"*\", \"*.wav\"])),\n",
- " glob.glob(os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"*\", \"*\", \"*.wav\"]))\n",
- "]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 37,
- "metadata": {},
- "outputs": [],
- "source": [
- "check_not_convert_files_path = [y for x in check_not_convert_files_path for y in x]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 38,
- "metadata": {},
- "outputs": [],
- "source": [
- "check_not_convert_files_name = [os.path.basename(i) for i in check_not_convert_files_path]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 39,
- "metadata": {},
- "outputs": [],
- "source": [
- "not_convert_files_name = [f for f in check_not_convert_files_name if f not in done_convert_files_name]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 40,
- "metadata": {},
- "outputs": [],
- "source": [
- "not_convert_files_path = [p for p in check_not_convert_files_path if os.path.basename(p) in not_convert_files_name]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 41,
- "metadata": {
- "scrolled": false
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "[]"
- ]
- },
- "execution_count": 41,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "not_convert_files_path"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [],
- "source": [
- "org_path = os.sep.join([\"..\", \"vae-npvc-kevin-with-1v1\", \"dataset\", \"vcc2016\", \"wav\", \"Testing Set\", \"b\"])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {},
- "outputs": [],
- "source": [
- "output_files_path = os.sep.join([\"..\", \"Voice_Converter_CycleGAN\", \"output_files\"])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {},
- "outputs": [],
- "source": [
- "#把未轉換的檔案放入代轉地區"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {},
- "outputs": [],
- "source": [
- "for f in not_convert_files_path:\n",
- " shutil.copyfile(f, os.sep.join([org_path, os.path.basename(f)]))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {},
- "outputs": [],
- "source": [
- "# 轉換檔案"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n",
- "D:\\code\\start_world>cd D:\\code\\Voice_Converter_CycleGAN \n",
- "\n",
- "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",
- "\n",
- "D:\\code\\Voice_Converter_CycleGAN>explorer.exe D:\\code\\Voice_Converter_CycleGAN\\output_files \n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "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",
- "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",
- "name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6575\n",
- "pciBusID: 0000:01:00.0\n",
- "totalMemory: 11.00GiB freeMemory: 9.11GiB\n",
- "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",
- "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",
- "2019-07-12 10:25:46.187015: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:929] 0 \n",
- "2019-07-12 10:25:46.187112: I T:\\src\\github\\tensorflow\\tensorflow\\core\\common_runtime\\gpu\\gpu_device.cc:942] 0: N \n",
- "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",
- "D:\\code\\Voice_Converter_CycleGAN\\preprocess.py:170: RuntimeWarning: divide by zero encountered in log\n",
- " f0_converted = np.exp((np.log(f0) - mean_log_src) / std_log_src * std_log_target + mean_log_target)\n"
- ]
- }
- ],
- "source": [
- "!open_path.bat"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {},
- "outputs": [],
- "source": [
- "#把輸出的檔案自動歸類"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {},
- "outputs": [],
- "source": [
- "time = datetime.datetime.now()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {},
- "outputs": [],
- "source": [
- "time = (time.year, time.month, time.day, time.hour, time.minute)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 20,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto_path = os.sep.join([output_files_path, \"auto_%d_%d_%d-%d_%d\" % time])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [],
- "source": [
- "os.mkdir(auto_path)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 22,
- "metadata": {},
- "outputs": [],
- "source": [
- "output_files = glob.glob(os.sep.join([output_files_path, \"*.wav\"]))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 23,
- "metadata": {},
- "outputs": [],
- "source": [
- "for f in output_files:\n",
- " file_path = os.path.splitext(os.path.basename(f))[0] + \"-to_kevin.wav\"\n",
- " shutil.move(f, os.sep.join([auto_path, file_path]))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {},
- "outputs": [],
- "source": [
- "#把輸出完成的檔案保留"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 25,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto_bak_path = os.sep.join([org_path, \"..\", \"b_bak_auto_%d_%d_%d-%d_%d\" % time])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 26,
- "metadata": {},
- "outputs": [],
- "source": [
- "os.mkdir(auto_bak_path)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 27,
- "metadata": {},
- "outputs": [],
- "source": [
- "not_bak_files = glob.glob(os.sep.join([org_path, \"*.wav\"]))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 28,
- "metadata": {},
- "outputs": [],
- "source": [
- "for f in not_bak_files:\n",
- " shutil.move(f, os.sep.join([auto_bak_path, os.path.basename(f)]))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 29,
- "metadata": {},
- "outputs": [],
- "source": [
- "#自動複製到正在作業的資料夾下"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 30,
- "metadata": {},
- "outputs": [],
- "source": [
- "now_workshop_path = \"E:\\\\minecraft\\\\隨機編劇\"\n",
- "now_kevin_path = \"E:\\\\minecraft\\\\隨機編劇\\\\r2_out_kevin\"\n",
- "now_lewis_path = \"E:\\\\minecraft\\\\隨機編劇\\\\r2_org_lewis\"\n",
- "now_script_path = \"D:\\\\code\\\\Voice_Converter_CycleGAN\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 31,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto_kevin_path = os.sep.join([now_script_path, auto_path])\n",
- "auto_lewis_path = os.sep.join([now_script_path, auto_bak_path])\n",
- "done_auto_copy_kevin_path = os.sep.join([now_kevin_path, os.path.basename(auto_path)])\n",
- "done_auto_copy_lewis_path = os.sep.join([now_lewis_path, os.path.basename(auto_bak_path)])\n",
- "\n",
- "f = open(\"auto_copy.bat\", \"w\")\n",
- "f.write(f\"\"\"\n",
- "cp -r \"{auto_kevin_path}\" \"{now_kevin_path}\"\n",
- "cp -r \"{auto_lewis_path}\" \"{now_lewis_path}\"\n",
- "explorer.exe \"{done_auto_copy_kevin_path}\"\n",
- "explorer.exe \"{done_auto_copy_lewis_path}\"\n",
- "\"\"\")\n",
- "f.close()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 32,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n",
- "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",
- "\n",
- "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",
- "\n",
- "D:\\code\\start_world>explorer.exe \"E:\\minecraft\\隨機編劇\\r2_out_kevin\\auto_2019_7_12-10_26\" \n",
- "\n",
- "D:\\code\\start_world>explorer.exe \"E:\\minecraft\\隨機編劇\\r2_org_lewis\\b_bak_auto_2019_7_12-10_26\" \n"
- ]
- }
- ],
- "source": [
- "!auto_copy.bat"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.5"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement