Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
blaise-tk committed Feb 20, 2024
1 parent 7abfcf4 commit 84df1a7
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 479 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/code_formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Code Formatter

on:
push:
branches:
- main

jobs:
push_format:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Black
run: pip install "black[jupyter]"

- name: Run Black
# run: black $(git ls-files '*.py')
run: black .

- name: Commit Back
continue-on-error: true
id: commitback
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
git commit -m "chore(format): run black on ${{github.ref_name}}"
- name: Create Pull Request
if: steps.commitback.outcome == 'success'
continue-on-error: true
uses: peter-evans/create-pull-request@v5
with:
delete-branch: true
body: "Automatically apply code formatter change"
title: "chore(format): run black on ${{github.ref_name}}"
commit-message: "chore(format): run black on ${{github.ref_name}}"
branch: formatter-${{github.ref_name}}
40 changes: 27 additions & 13 deletions modules/server/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@

from lib.voras.models import Synthesizer
from modules.cmd_opts import opts
from modules.models import (EMBEDDINGS_LIST, MODELS_DIR, get_embedder,
get_vc_model, update_state_dict)
from modules.models import (
EMBEDDINGS_LIST,
MODELS_DIR,
get_embedder,
get_vc_model,
update_state_dict,
)
from modules.shared import ROOT_DIR, device, is_half

MODELS_DIR = opts.models_dir or os.path.join(ROOT_DIR, "models")
Expand Down Expand Up @@ -95,20 +100,30 @@ def __init__(self, rvc_model_file: str) -> None:
self.device = device
self.is_half = is_half

def __call__(
self,
audio: np.ndarray,
sr: int,
sid: int
):
def __call__(self, audio: np.ndarray, sr: int, sid: int):
# bh, ah = signal.butter(N=5, Wn=48, btype="high", fs=16000)
# audio = signal.filtfilt(bh, ah, audio)
print(sr, audio.shape)
if sr != self.sr:
audio = torchaudio.functional.resample(torch.from_numpy(audio), sr, self.sr, rolloff=0.99).detach().cpu().numpy()
audio = (
torchaudio.functional.resample(
torch.from_numpy(audio), sr, self.sr, rolloff=0.99
)
.detach()
.cpu()
.numpy()
)
print(sr, audio.shape)
audio = (audio / np.maximum(np.max(np.abs(audio), keepdims=True), 1e-7) * (.95 * .8)) + 0.2 * audio
audio_pad = np.pad(audio, (self.window // 2, self.window // 2), mode="reflect" if audio.shape[0] > self.window // 2 else "constant")
audio = (
audio
/ np.maximum(np.max(np.abs(audio), keepdims=True), 1e-7)
* (0.95 * 0.8)
) + 0.2 * audio
audio_pad = np.pad(
audio,
(self.window // 2, self.window // 2),
mode="reflect" if audio.shape[0] > self.window // 2 else "constant",
)
print(audio_pad.shape)

opt_ts = []
Expand Down Expand Up @@ -143,7 +158,6 @@ def __call__(
torch.cuda.empty_cache()
return audio_opt


def _convert(
self,
sid: int,
Expand Down Expand Up @@ -193,4 +207,4 @@ def _convert(
del feats, padding_mask
if torch.cuda.is_available():
torch.cuda.empty_cache()
return audio1
return audio1
466 changes: 0 additions & 466 deletions notebook/API test.ipynb

This file was deleted.

0 comments on commit 84df1a7

Please sign in to comment.