From e8244d61b7ac80e31207b7181473877285ae2c10 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:57:50 +0800 Subject: [PATCH 01/14] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e2aa7b648..7e6114cd1 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ [English](/README_en.md) [Korean](/README_ko.md) ## What's New! +- v.1.5.3.17c + implement fcpe in RVC + warning: not stable + - v.1.5.3.17b - bugfix: - clear setting From 98ee26e353c404eb421dbcf43533ed79c1ae8c49 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:58:49 +0800 Subject: [PATCH 02/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e6114cd1..cba58b491 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## What's New! - v.1.5.3.17c - implement fcpe in RVC + - implement fcpe in RVC warning: not stable - v.1.5.3.17b From b96ba86be3df3abfe12b3cf505191ed0d38b7c06 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:00:50 +0800 Subject: [PATCH 03/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cba58b491..2dba92995 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## What's New! - v.1.5.3.17c - implement fcpe in RVC - warning: not stable + warning: not stable, see https://github.com/w-okada/voice-changer/issues/1066 - v.1.5.3.17b - bugfix: From 9f9e7016e2f61591900c2bd34ac75f98982e31cc Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:03:41 +0800 Subject: [PATCH 04/14] Update GUI.json --- client/demo/dist/assets/gui_settings/GUI.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/demo/dist/assets/gui_settings/GUI.json b/client/demo/dist/assets/gui_settings/GUI.json index ccf3be9e5..e234f1a40 100644 --- a/client/demo/dist/assets/gui_settings/GUI.json +++ b/client/demo/dist/assets/gui_settings/GUI.json @@ -21,7 +21,7 @@ { "name": "configArea", "options": { - "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx"], + "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx", "fcpe"], "inputChunkNums": [1, 2, 4, 6, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384] } } From 5fd31999e72f3a522173a5583c915559d1b6a339 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:04:15 +0800 Subject: [PATCH 05/14] implement fcpe --- client/demo/dist/assets/gui_settings/GUI.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/demo/dist/assets/gui_settings/GUI.json b/client/demo/dist/assets/gui_settings/GUI.json index e234f1a40..c43596283 100644 --- a/client/demo/dist/assets/gui_settings/GUI.json +++ b/client/demo/dist/assets/gui_settings/GUI.json @@ -21,7 +21,7 @@ { "name": "configArea", "options": { - "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx", "fcpe"], + "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx", "fcpe" ], "inputChunkNums": [1, 2, 4, 6, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384] } } From cc4783b85c5dc2a6488484a0eefe067628e2af77 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:04:54 +0800 Subject: [PATCH 06/14] implement fcpe --- client/demo/public/assets/gui_settings/GUI.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/demo/public/assets/gui_settings/GUI.json b/client/demo/public/assets/gui_settings/GUI.json index ccf3be9e5..e234f1a40 100644 --- a/client/demo/public/assets/gui_settings/GUI.json +++ b/client/demo/public/assets/gui_settings/GUI.json @@ -21,7 +21,7 @@ { "name": "configArea", "options": { - "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx"], + "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx", "fcpe"], "inputChunkNums": [1, 2, 4, 6, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384] } } From cc72b93198868507c4ac2224516521a8e1a9c188 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:05:57 +0800 Subject: [PATCH 07/14] implement fcpe --- client/lib/src/const.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/lib/src/const.ts b/client/lib/src/const.ts index 69d3f1939..76db00f65 100644 --- a/client/lib/src/const.ts +++ b/client/lib/src/const.ts @@ -56,6 +56,7 @@ export const F0Detector = { crepe_tiny: "crepe_tiny", rmvpe: "rmvpe", rmvpe_onnx: "rmvpe_onnx", + fcpe: "fcpe", } as const; export type F0Detector = (typeof F0Detector)[keyof typeof F0Detector]; From 4e254e42f7d9cdefac9056ba3ff944684939b630 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:07:03 +0800 Subject: [PATCH 08/14] implement fcpe --- server/const.py | 1 + 1 file changed, 1 insertion(+) diff --git a/server/const.py b/server/const.py index 15f758c39..eaa1a9ceb 100644 --- a/server/const.py +++ b/server/const.py @@ -82,6 +82,7 @@ class EnumInferenceTypes(Enum): "crepe_tiny", "rmvpe", "rmvpe_onnx", + "fcpe", ] ServerAudioDeviceType: TypeAlias = Literal["audioinput", "audiooutput"] From 8e4292788022fee0ec6fe83ab116b61fc81af995 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:07:38 +0800 Subject: [PATCH 09/14] implement fcpe --- server/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/server/requirements.txt b/server/requirements.txt index 4a5e79e7c..8cbebe89b 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -27,3 +27,4 @@ websockets==11.0.2 sounddevice==0.4.6 dataclasses_json==0.5.7 onnxsim==0.4.28 +torchfcpe From fbf69cda199b9522288db8d59c30cea4378b0a5a Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:08:47 +0800 Subject: [PATCH 10/14] implement fcpe --- .../RVC/pitchExtractor/FcpePitchExtractor.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py diff --git a/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py b/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py new file mode 100644 index 000000000..6a0c0997e --- /dev/null +++ b/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py @@ -0,0 +1,44 @@ +import numpy as np +from const import PitchExtractorType +from voice_changer.RVC.deviceManager.DeviceManager import DeviceManager +from voice_changer.RVC.pitchExtractor.PitchExtractor import PitchExtractor +import torchfcpe + +class FcpePitchExtractor(PitchExtractor): + + def __init__(self, gpu: int): + super().__init__() + self.pitchExtractorType: PitchExtractorType = "fcpe" + self.device = DeviceManager.get_instance().getDevice(gpu) + self.fcpe = torchfcpe.spawn_bundled_infer_model(self.device) + + # I merge the code of Voice-Changer-CrepePitchExtractor and RVC-fcpe-infer, sry I don't know how to optimize the function. + def extract(self, audio, pitchf, f0_up_key, sr, window, silence_front=0): + start_frame = int(silence_front * sr / window) + real_silence_front = start_frame * window / sr + + silence_front_offset = int(np.round(real_silence_front * sr)) + audio = audio[silence_front_offset:] + + f0_min = 50 + f0_max = 1100 + f0_mel_min = 1127 * np.log(1 + f0_min / 700) + f0_mel_max = 1127 * np.log(1 + f0_max / 700) + + f0 = self.fcpe.infer( + audio.to(self.device_fcpe).unsqueeze(0).float(), + sr=16000, + decoder_mode="local_argmax", + threshold=0.006, + ) + f0 = f0.squeeze() + + f0 *= pow(2, f0_up_key / 12) + pitchf[-f0.shape[0]:] = f0.detach().cpu().numpy()[:pitchf.shape[0]] + f0bak = pitchf.copy() + f0_mel = 1127.0 * np.log(1.0 + f0bak / 700.0) + f0_mel = np.clip( + (f0_mel - f0_mel_min) * 254.0 / (f0_mel_max - f0_mel_min) + 1.0, 1.0, 255.0 + ) + pitch_coarse = f0_mel.astype(int) + return pitch_coarse, pitchf From 04f93b193fa36bff939035910236b9a96c9f3ab0 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:09:57 +0800 Subject: [PATCH 11/14] implement fcpe --- .../voice_changer/RVC/pitchExtractor/PitchExtractorManager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/voice_changer/RVC/pitchExtractor/PitchExtractorManager.py b/server/voice_changer/RVC/pitchExtractor/PitchExtractorManager.py index 6df0e894a..1032e7bc4 100644 --- a/server/voice_changer/RVC/pitchExtractor/PitchExtractorManager.py +++ b/server/voice_changer/RVC/pitchExtractor/PitchExtractorManager.py @@ -43,6 +43,9 @@ def loadPitchExtractor( return RMVPEPitchExtractor(cls.params.rmvpe, gpu) elif pitchExtractorType == "rmvpe_onnx": return RMVPEOnnxPitchExtractor(cls.params.rmvpe_onnx, gpu) + elif pitchExtractorType == "fcpe": + # add the FcpePitchExtractor + return FcpePitchExtractor(gpu) else: # return hubert as default print("[Voice Changer] PitchExctractor not found", pitchExtractorType) From 303a15fef3085634c890251c09f3f428577880d4 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:10:44 +0800 Subject: [PATCH 12/14] implement fcpe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2dba92995..6b0a235e8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## What's New! - v.1.5.3.17c - implement fcpe in RVC - warning: not stable, see https://github.com/w-okada/voice-changer/issues/1066 + - warning: not stable, see https://github.com/w-okada/voice-changer/issues/1066 - v.1.5.3.17b - bugfix: From 1cf9be54c707692eae1b75331de107a39630cb20 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Thu, 11 Jan 2024 22:02:36 +0800 Subject: [PATCH 13/14] undo modification --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 6b0a235e8..e2aa7b648 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,6 @@ [English](/README_en.md) [Korean](/README_ko.md) ## What's New! -- v.1.5.3.17c - - implement fcpe in RVC - - warning: not stable, see https://github.com/w-okada/voice-changer/issues/1066 - - v.1.5.3.17b - bugfix: - clear setting From 8f230e5c455f708225a2685ad091e61e08115251 Mon Sep 17 00:00:00 2001 From: icecoins <92659856+icecoins@users.noreply.github.com> Date: Fri, 12 Jan 2024 02:28:17 +0800 Subject: [PATCH 14/14] Update FcpePitchExtractor.py --- server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py b/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py index 6a0c0997e..d90c3421f 100644 --- a/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py +++ b/server/voice_changer/RVC/pitchExtractor/FcpePitchExtractor.py @@ -26,7 +26,7 @@ def extract(self, audio, pitchf, f0_up_key, sr, window, silence_front=0): f0_mel_max = 1127 * np.log(1 + f0_max / 700) f0 = self.fcpe.infer( - audio.to(self.device_fcpe).unsqueeze(0).float(), + audio.to(self.device).unsqueeze(0).float(), sr=16000, decoder_mode="local_argmax", threshold=0.006,